Google Gemini Native API Guide

If you use the Google SDK or Gemini request format, call the paths below with your platform API key. Gemini API Official Docs

[!NOTE] Example model IDs are for reference only; use actual IDs from the Model Marketplace.

1. Text Generation (Non-stream)

  • Official Native Path: /v1/models/{model}:generateContent (compatible with /v1beta/models/{model}:generateContent)
  • Request Method: POST

2. Streaming Generation (Streaming)

  • Official Native Path: /v1/models/{model}:streamGenerateContent (compatible with /v1beta/models/{model}:streamGenerateContent)
  • Request Method: POST

Core Request Payload Example

{
  "contents": [
    {
      "role": "user",
      "parts": [
        {
          "text": "Please act as my personal travel assistant and plan a 3-day Kyoto cherry blossom itinerary."
        }
      ]
    }
  ],
  "systemInstruction": {
    "parts": [
      {
        "text": "You are a professional travel planner with a friendly and humorous tone."
      }
    ]
  },
  "generationConfig": {
    "temperature": 0.4,
    "maxOutputTokens": 2000,
    "responseMimeType": "text/plain"
  }
}

3. Interactions API (v1 / v1beta)

  • Path: /v1/interactions (Compatible with /v1beta/interactions)
  • Request Method: POST

Google Gemini unified Interactions API, allowing direct configuration of model (or agent) and input (text, multimodal, or multiturn items), with support for system_instruction, tools, response_format, and more.

Core Request Payload Example

{
  "model": "gemini-2.5-flash",
  "input": "Please help me plan a 3-day cherry blossom trip in Kyoto.",
  "system_instruction": "You are a professional travel planner with a friendly and humorous tone.",
  "stream": false
}

Authentication Methods (Choose One of Three)

  • Standard Header: Authorization: Bearer sk-your_token
  • Google Header: X-Goog-Api-Key: sk-your_token
  • Query Parameter: ?key=sk-your_token

Raw Markdown (.md) · llms.txt