Gemini native
Call Gemini 4 Argon, Gemini 3.8 Flash and Gemini 3.1 Pro with Gemini generateContent requests and one BeatAPI key.
POST /v1beta/models/{model}:generateContent, and:streamGenerateContent?alt=ssefor streaming, for every current Gemini model.- Text and image input, text output, streaming, function calling and thinking.
- Send the key in the
x-goog-api-keyheader or as a Bearer token. - The model is in the URL, not in the body.
Use https://direct.beatapi.io as the base URL for text requests: it is not subject to Cloudflare’s 100-second limit, so a long non-streaming request is not cut off. https://api.beatapi.io also works and is the fallback if direct.beatapi.io is unreachable from your network. The key, models and prices are the same on both. Image and video APIs use https://api.beatapi.io only.
Opens this endpoint in the API Explorer. Enter your BeatAPI API key and send: the call is real and is billed to your own balance.
Models
Put one of these IDs in the URL, in place of {model}.
- Prices are the base tier, discount already applied. A long-context tier, cached-input rates and cache writes are not in this table; see the price table.
—means the catalogue does not publish the number.
Older IDs of this family still work and are listed on Legacy models.
Quick start
Keep the key in BEATAPI_API_KEY and never put it in browser code. The model ID goes in the URL, so the body has no model field. These are request examples, not recorded model outputs.
Read the answer from candidates[0].content.parts[0].text, then check candidates[0].finishReason and usageMetadata. An HTTP 200 alone does not prove the answer satisfies your task: validate it in your application. Text requests return directly; do not poll /v1/tasks for them.
Endpoint and authentication
POST https://direct.beatapi.io/v1beta/models/{model}:generateContent
x-goog-api-key
string
Required
Your BeatAPI key in the x-goog-api-key header. Authorization: Bearer <BEATAPI_API_KEY> is also accepted.
For streaming, call POST /v1beta/models/{model}:streamGenerateContent?alt=sse. The key goes in the x-goog-api-key header or in Authorization: Bearer <key>; both work.
:countTokens is not available and returns 404.
Request parameters
These are the fields that take effect. Other Gemini fields are accepted in the request but have no effect: generationConfig.thinkingConfig, generationConfig.responseMimeType, generationConfig.responseSchema, generationConfig.seed, safetySettings, toolConfig and cachedContent. Do not rely on them.
contents
object[]
Required
The conversation, oldest turn first. Each item has a role (user or model) and parts. A part is text, inlineData (mimeType and base64 data), fileData (mimeType and fileUri), functionCall or functionResponse.
- Image input is supported by every current Gemini model; use
inlineData, orfileDatawith an image URL. For other media, test your file type before you depend on it. - An empty or missing
contentsis400 bad_request.
Example
systemInstruction
object
Optional
System prompt, as { "parts": [{ "text": "..." }] }. Only text parts are used.
Example
generationConfig
object
Optional
Generation options. These subfields take effect: maxOutputTokens, temperature, topP, topK, stopSequences and candidateCount.
Example
generationConfig.maxOutputTokens
integer
Optional
Upper bound on the generated tokens, thinking included.
- The largest accepted value is 1,073,741,823; a larger value is
400 bad_request. Keep it at or below the max output of the model in the table above. - Gemini models think by default, and thinking tokens are billed as output and count toward this limit. A small value can be used up by thinking, leaving an empty answer with
finishReason: "MAX_TOKENS". Budget at least 1,000 tokens for a short answer. maxOutputTokensis also used to estimate how much balance a request needs. A very large value can be refused with402 insufficient_creditseven when the real output would be small. Set it to what you need.
generationConfig.temperature
number
Optional
Sampling temperature.
generationConfig.topP
number
Optional
Nucleus sampling. A value of 0 is ignored.
generationConfig.topK
integer
Optional
Top-K sampling. A value of 0 is ignored.
generationConfig.stopSequences
string[]
Optional
Strings that stop generation. At most 4 are used.
generationConfig.candidateCount
integer
Optional
Number of candidates to return. Leave it unset unless you need more than one.
tools
object[]
Optional
Function declarations the model may call, as [{ "functionDeclarations": [...] }]. Each declaration has a name, a description and parameters (JSON Schema). A call comes back as a functionCall part; return the result as a functionResponse part in the next user turn.
- Only
functionDeclarationsare used. Built-in tools such asgoogleSearchandcodeExecutionare ignored.
Example
Response
A non-streaming call returns one JSON object. This is an abbreviated example.
Response fields
Streaming
Call :streamGenerateContent?alt=sse. Every event is a line data: {...} holding a candidates object, in the same shape as a non-streaming answer.
- The last event carries
finishReason, for example"STOP". - The response is
text/event-stream. A failure before the model is called is returned as a normal JSON error with an HTTP status, not as a stream event. - Set explicit timeouts and reconnect a streamed response safely.
Errors
HTTP errors at a glance
Errors on the Gemini-native endpoint have one shape, {"error": {"message", "type": "beatapi_error", "code"}}: the code is in error.code, the request id ends message, and there is no retryable field. See Errors.
Full code table and retry policy: Errors.
Notes
- Gemini models also answer on Chat Completions, Responses and Anthropic Messages. See the other Gemini pages.
- Thinking tokens are billed as output tokens. Budget output for thinking plus the answer, not just the answer.
- Keep API keys on trusted servers, log the response request ID, and retry only
429,500and503.
Authentication
Send your API key as Authorization: Bearer <BEATAPI_API_KEY>.
Path parameters
Request
The conversation, oldest turn first. Each item has a role (user or model) and parts. A part is text, inlineData (mimeType and base64 data), fileData (mimeType and fileUri), functionCall or functionResponse.
Image input is supported by every current Gemini model; use inlineData, or fileData with an image URL. For other media, test your file type before you depend on it.
An empty or missing contents is 400 bad_request.
System prompt, as { "parts": [{ "text": "..." }] }. Only text parts are used.
Generation options. These subfields take effect: maxOutputTokens, temperature, topP, topK, stopSequences and candidateCount.
Function declarations the model may call, as [{ "functionDeclarations": [...] }]. Each declaration has a name, a description and parameters (JSON Schema). A call comes back as a functionCall part; return the result as a functionResponse part in the next user turn.
Only functionDeclarations are used. Built-in tools such as googleSearch and codeExecution are ignored.
Response
A non-streaming call returns one JSON object. This is an abbreviated example.

