Skip to main content
APIYI fully supports the official Gemini native format (the /v1beta generateContent endpoint): point the base_url at https://api.apiyi.com and your existing Gemini code and official SDKs migrate seamlessly — no format conversion needed. This page is based on the official Google documentation (ai.google.dev/gemini-api/docs, as of June 2026). All examples are copy-paste ready.

Why the Native Format

The OpenAI-compatible format can call Gemini too, but the following are native-only:
  • Full thinking controls: thinking_level (Gemini 3 series) / thinking_budget (2.5 series), thought summaries, thought signatures
  • Native multimodal Parts: inline images / audio / video, with media_resolution cost control — see Multimodal & Code Execution
  • Code execution tool: code_execution runs Python in a sandbox
  • Fine-grained usage fields: thoughts_token_count, cached_content_token_count, and more
For plain text chat, or one codebase across multiple vendors, use OpenAI Compatible Mode instead.

Quick Start

Use Google’s official unified SDK google-genai (the legacy google-generative-ai was sunset on November 30, 2025 (UTC)):
The base_url is https://api.apiyi.com (without /v1) — different from the OpenAI-compatible format’s https://api.apiyi.com/v1. Use your APIYI key, not a Google AI Studio key.

Streaming

Thinking Controls

Gemini models think by default, and the two generations use different parameters — mixing them raises an error:
Passing both thinking_level and thinking_budget to a Gemini 3 series model returns an error — pick one (use thinking_level for the 3 series).
Choosing a level: minimal for low-latency simple tasks (classification, extraction); low for routine chat; high for complex reasoning and code. Thinking tokens bill at the output rate — higher levels cost more.

Thought summaries and thought signatures

  • Thought summaries: include_thoughts=True returns a summary of the reasoning (parts where part.thought is True)
  • Thought signatures: encrypted reasoning state introduced with Gemini 3. In multi-turn conversations (especially function calling), pass the thought_signature from the response back unchanged so the model can continue its reasoning chain. Official SDKs handle this automatically; don’t strip the field in hand-written REST calls — see Function Calling

Common Config Parameters

Passed via config (GenerateContentConfig):

Usage Fields (usage_metadata)

Supported Models and Pricing

Some models have -thinking / -nothinking alias variants (e.g. gemini-3-flash-preview-nothinking) that pin thinking on/off — handy for clients where you can’t change request parameters. Full list: Models & Pricing.

Native vs OpenAI-Compatible

Notes

  • The Files API is not supported (client.files.upload()); media must be passed inline and each file must stay under 20MB — see Multimodal & Code Execution
  • Cache discounts and hit-rate expectations: Cache Billing