API Reference

Gemini Generate Content

Generates a model response using the Google Gemini API format. Compatible with the Gemini `generateContent` endpoint. Automatically routes to the best available provider (Google native, or other providers via protocol conversion). Set your Yolo Router API key via `Authorization: Bearer sk-...` or `x-goog-api-key: sk-...` header, and point the base URL to this server to use as a drop-in replacement for the Gemini SDK.

POST
/v1beta/models/{model}:generateContent

Authorization

AuthorizationBearer <token>

Your Yolo Router API key. Format: Authorization: Bearer sk-...

In: header

Path Parameters

model*string

Model name, e.g. gemini-2.0-flash or gemini-1.5-pro.

Request Body

application/json

TypeScript Definitions

Use the request body type in TypeScript.

Response Body

application/json

application/json

application/json

application/json

curl -X POST "https://api.yolorouter.com/v1beta/models/gemini-2.0-flash:generateContent" \  -H "Content-Type: application/json" \  -d '{    "contents": [      {        "role": "user",        "parts": [          {            "text": "Explain how AI works in simple terms."          }        ]      }    ]  }'
{
  "candidates": [
    {
      "content": {
        "role": "user",
        "parts": [
          {
            "text": "string",
            "inlineData": {
              "mimeType": "image/png",
              "data": "string"
            },
            "functionCall": {
              "name": "string",
              "args": {}
            },
            "functionResponse": {
              "name": "string",
              "response": {}
            },
            "thought": true
          }
        ]
      },
      "finishReason": "STOP",
      "index": 0
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 0,
    "candidatesTokenCount": 0,
    "totalTokenCount": 0,
    "cachedContentTokenCount": 0,
    "thoughtsTokenCount": 0
  },
  "modelVersion": "gemini-2.0-flash"
}
{
  "error": {
    "type": "invalid_request_error",
    "code": "invalid_api_key",
    "message": "Invalid API key"
  }
}
{
  "error": {
    "type": "insufficient_quota",
    "code": "insufficient_quota",
    "message": "Quota exceeded"
  }
}
{
  "error": {
    "type": "string",
    "code": "string",
    "message": "string"
  }
}