Google Gemini API Guide: Models, Multimodality, and SDK

Google positions the Gemini API as a fast path "from prompt to production": with the official SDK, you can get an API key and make your first call within minutes. Compared with text-only models, the biggest differentiator of the Gemini family is native multimodal support, where images, video, audio, documents, and text can be mixed in a single request. For developers who want to add AI to a website or product and ingest multiple input types at once, this route is worth understanding systematically.

1. The Gemini 3 Model Matrix

The Gemini API currently leads with the Gemini 3 family, split by "intelligence x speed x cost":

  • Gemini 3.1 Pro: The most capable multimodal understanding model, suited to complex reasoning, deep analysis, and coding.
  • Gemini 3.5 Flash: Near-frontier performance at a much lower cost than large models, balancing speed and intelligence for agent and coding workloads.
  • Gemini 3 Flash / 3.1 Flash-Lite: Best for high-throughput, cost-sensitive, low-latency traffic.
  • Multimodal creation: Nano Banana (native image generation and editing), Veo 3.1 (video generation), and Lyria 3 (music creation) media models.
  • Tools and agent models: Computer Use (operating digital screens), Gemini Deep Research (autonomous multi-step research), and Antigravity Agent (running code autonomously in an isolated sandbox).
  • Specialized task models: Gemini Embedding (multimodal embeddings for semantic search and RAG; see the RAG implementation guide).

The version naming rules deserve attention: models come in stable, preview, latest, and experimental flavors. Production should pin a specific stable version rather than the hot-swapping latest alias, and experimental models are not appropriate online.

For everyday selection, this quick table helps:

Model Positioning Best for Cost tier
Gemini 3.1 Pro Strongest understanding Complex reasoning, deep analysis High
Gemini 3.5 Flash Balance of speed and intelligence Agents, coding Medium
Gemini 3 Flash / Flash-Lite High-throughput, lightweight Classification, extraction, batch Low
Gemini Embedding Multimodal embeddings Semantic search, RAG Low

2. Multimodality and Long Context

Native multimodality is the core selling point: a single request can include text, images, PDFs, and video clips, and the model understands visual content directly without a separate OCR or transcription pipeline. Combined with million-token-level long context, you can place an entire document or a full meeting recording in context at once.

Practical tips: for long documents, prefer file upload plus context over concatenating snippets; for large private knowledge bases, still vectorize and retrieve first (RAG), then let the model answer from retrieved results to balance quality and cost.

3. Official SDK and the Interactions API

Google maintains the google-genai SDK (Python, JavaScript, and others). The docs now recommend the Interactions API as the primary way to interact with Gemini: one call returns structured output with very compact code:

from google import genai
client = genai.Client()
interaction = client.interactions.create(
    model="gemini-3.5-flash",
    input="Explain how AI works in a few words",
)
print(interaction.output_text)

Other common capabilities include structured output (constrained JSON), function calling (connecting the model to external APIs and tools for agent workflows), streaming, and context caching (reducing token cost for repeated input).

Function calling is the most common building block for agents. Declare a tool for the model, and when needed the model returns structured call arguments that your code executes against the real system, then hands the result back — closing the loop:

@client.interactions.tool
def get_stock_price(symbol: str) -> float:
    """Return the latest price for a given stock symbol."""
    return query_market_data(symbol)  # your real data source

response = client.interactions.create(
    model="gemini-3.5-flash",
    input="How much did NVDA move today?",
    tools=[get_stock_price],
)
print(response.output_text)

In AI Studio, open the Tools panel on the right to debug the function declaration while you write it, confirming when the model triggers the call and whether the arguments match the JSON Schema.

4. Google AI Studio and Vertex AI

Gemini offers two integration routes; choose by "prototype vs production":

  • Google AI Studio: A free/low-cost environment for fast experimentation. Tune prompts in the browser, generate API keys, and run your first call, ideal for learning and small-scale validation.
  • Vertex AI: Google Cloud's enterprise platform with managed deployment, IAM, audit logs, data residency, and SLAs, suitable for production systems with compliance and operations requirements.

A practical path: validate effects and cost in AI Studio first, then move to Vertex AI for launch; both routes share the same models and SDK, so migration cost is low.

5. Pricing and Cost Strategy

Gemini billing is also per input/output token. Flash models are significantly cheaper; Pro models cost more but are more capable. Cost-control tactics match the mainstream approach: use Flash for lightweight tasks, Batch API for non-realtime jobs, Context Caching for fixed context, and prefer RAG over feeding large volumes wholesale. With multiple models running in parallel, introduce a unified gateway for budgets and logs; see the AI gateway spend limits guide.

6. 16IDC Takeaways

A concrete example: for a multilingual support bot, vectorize your FAQ with Embeddings, retrieve 3-5 candidate answers when a user asks, then let Gemini 3.5 Flash compose the reply from the retrieved results, and finally use structured output to constrain the answer's language and source fields. This leverages Gemini's multilingual strength while keeping per-request token spend within a reasonable range.

When wiring Gemini into a website or business, the highest-value path is "validate in AI Studio + integrate with the official SDK + combine long context with RAG." If you run a multilingual site or a support bot, Gemini's multimodal and translation capabilities can be reused directly for content generation and chatbots; see integrating an AI chatbot into a website. Also reserve compute for vector retrieval and log processing in your server selection: preprocessing and caching layers for multimodal requests still live on your own infrastructure.

Reference: Gemini API pricing https://ai.google.dev/gemini-api/pricing
Reference: Function calling docs https://ai.google.dev/gemini-api/docs/function-calling

Source: https://ai.google.dev/gemini-api/docs