API reference

generateContent

POST https://api.flyrouter.ai/v1beta/models/{model}:generateContent

POST https://api.flyrouter.ai/v1beta/models/{model}:streamGenerateContent?alt=sse

The Gemini native API. Requests and responses match the Google Gemini API, which suits projects already using the Google Gen AI SDK or Gemini CLI.

Example request

curl "https://api.flyrouter.ai/v1beta/models/gemini-4-argon:generateContent" \
  -H "x-goog-api-key: $FLYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "systemInstruction": {"parts": [{"text": "You are a concise assistant."}]},
    "contents": [
      {"role": "user", "parts": [{"text": "Introduce yourself in one sentence"}]}
    ],
    "generationConfig": {"maxOutputTokens": 1024}
  }'

Streaming

Use streamGenerateContent with alt=sse. The response is SSE, and each event is a partial result:

Terminal
curl "https://api.flyrouter.ai/v1beta/models/gemini-4-argon:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: $FLYROUTER_API_KEY" \
  -H "Content-Type: application/json" \
  -N \
  -d '{"contents": [{"role": "user", "parts": [{"text": "Write a short poem about autumn"}]}]}'

Authentication

Use x-goog-api-key: sk-... or Authorization: Bearer sk-.... Avoid putting the key in URL parameters, since URLs tend to end up in logs.

Response

json
{
  "candidates": [
    {
      "content": { "role": "model", "parts": [{ "text": "I am..." }] },
      "finishReason": "STOP"
    }
  ],
  "usageMetadata": {
    "promptTokenCount": 12,
    "candidatesTokenCount": 30,
    "totalTokenCount": 42
  }
}

:countTokens isn't supported yet. If you'd rather use the OpenAI SDK, Gemini models can also be called through Chat Completions.

FlyRouter

One key, every top AI model