Skip to main content

Gemini

POST /gemini/v1beta/models/{model}:generateContent
POST /gemini/v1beta/models/{model}:streamGenerateContent?alt=sse

Google's native Gemini API. Requests and responses are Google's own format, streaming and non-streaming. Point Google's Gen AI SDK at https://api.tokhive.ai/gemini and call it as usual; the SDK adds /v1beta itself.

Gemini models are also available through Chat Completions and Responses, for tools that speak only OpenAI's format.

Who serves the request​

  1. Google subscription accounts, through Antigravity. They take only requests that Antigravity CLI sends.
  2. Providers' Gemini API and Vertex AI keys, ranked together. Every other request starts here.
  3. A vetted API service, as fallback, when no Provider can take the request. It is charged that service's price, and you can turn it off with Fallback Supply on the Account page.

When none of them can, the request returns 503 no_supply.

Example​

curl "https://api.tokhive.ai/gemini/v1beta/models/gemini-4-argon:generateContent" \
-H "x-goog-api-key: $HIVE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"role": "user", "parts": [{"text": "Hello"}]}]
}'

The models you can call are listed by /gemini/v1beta/models.

Request​

HeaderNotes
x-goog-api-key or Authorization: BearerYour TokHive API key. If you send both, they must be the same key. The key query parameter is not read, because URLs end up in logs.
FieldNotes
contentsRequired.
systemInstruction, tools, toolConfig, generationConfig, safetySettingsPassed through unchanged.
generationConfig.thinkingConfig.thinkingLevelPicks the model's thinking level. Without it, the model's default level is used.
cachedContentNot supported: 400 unsupported_gemini_request. A cache created in advance lives in your own API key's project, which none of TokHive's supply runs in. Repeated prefixes are cached implicitly instead, and the cached part is billed at the cache-read price.

The model comes from the path; a model field in the body is ignored.

Streaming​

streamGenerateContent needs alt=sse; without it the request returns 400. Chunks are the same as from Google's API. TokHive holds back the chunk that carries the finish reason until the result is verified and settled, so it can arrive a moment after the last content. The stream sends no keep-alive comments, because Google's SDKs treat them as malformed chunks.

generateContent returns a single response, which TokHive assembles from the upstream stream once it is verified.

If a stream fails after output has started, it ends with an error chunk, and nothing is charged.

Usage and billing​

The usage comes from the last chunk's usageMetadata:

Billed asFrom
InputpromptTokenCount + toolUsePromptTokenCount − cachedContentTokenCount
Cache readcachedContentTokenCount
OutputcandidatesTokenCount + thoughtsTokenCount

Credits can't pay for Gemini models. Like Claude models, they are charged to your withdrawable balance (deposits and transferred earnings), and a request needs at least 0.5 USD of it to start; otherwise it returns 402 withdrawable_balance_low.

Conversations​

A Gemini request carries its whole history and names no conversation, so TokHive doesn't keep it on one account or key. Thought signatures belong to whoever issued them. When a history signed elsewhere is refused, TokHive replaces its signatures with Google's documented placeholder and retries once.

Not supported​

  • countTokens returns 404.
  • cachedContent, as above.
  • When a request falls back to the API service, these return 400 unsupported_gemini_request, naming the field:
    • Google Search, code execution and the other built-in tools;
    • inline data other than images;
    • files that are not at a public HTTPS link;
    • more than one candidate.

Errors​

Errors under /gemini are in Google's shape. TokHive's error code is in details[0].reason:

{
"error": {
"code": 503,
"status": "UNAVAILABLE",
"message": "no provider is offering this model right now",
"details": [{ "reason": "no_supply" }]
}
}

When the upstream rejects the request itself (400, 413 or 422), its status and message are passed through, with an account's project ID masked. Other upstream failures return 502 upstream_error. A Gemini model sent to another API returns 400 wrong_protocol, with the right path in the message. See Errors for the codes.