Native Gemini route: generateContent, streaming and video
https://1xai.ir/gemini/v1beta/models/{model}:generateContent forwards the request body to Google's own Generative Language API and returns the full usageMetadata. The 1xai-* key must be in the x-goog-api-key or Authorization: Bearer header, never in the URL. Gemini's implicit caching is automatic and its discount is applied to the bill; explicit caching (cachedContents) is not supported.
Last updated:
generateContent and streamGenerateContent
curl https://1xai.ir/gemini/v1beta/models/gemini-3.5-flash:generateContent \
-H "x-goog-api-key: 1xai-..." \
-H "Content-Type: application/json" \
-d '{
"contents": [
{"role": "user", "parts": [{"text": "Summarise this text in one paragraph."}]}
],
"generationConfig": {"maxOutputTokens": 1024, "temperature": 0.3}
}'from google import genai
from google.genai import types
client = genai.Client(
api_key="1xai-...",
http_options=types.HttpOptions(base_url="https://1xai.ir/gemini"),
)
resp = client.models.generate_content(
model="gemini-3.5-flash",
contents="Hello",
)
print(resp.text)- The versions
v1betaandv1are accepted. - The body is Google's:
contents,systemInstruction,generationConfig,tools,safetySettings. - The bill is computed from
usageMetadata: prompt tokens, output tokens and thinking tokens;cachedContentTokenCountat the cheaper cached rate. - When the balance cannot fund
maxOutputTokens, the gateway lowers it, as on the other routes. - Of the URL parameters only
alt,fieldsandprettyPrintreach Google. For streaming as SSE, call:streamGenerateContent?alt=sse. - When Google answers
429,503or529, the gateway tries up to 3 times.
Free routes
POST …/models/{model}:countTokens: counting tokens before sending.GET /gemini/v1beta/modelsandGET /gemini/v1beta/models/{model}: the model list and a model's details.
Grounding and image generation
- Google Search grounding is allowed and is billed apart from tokens, at the model's search rate. Google Maps grounding answers
402with codehosted_tool_unmetered(hosted tools). - Call Google's image models with the same
:generateContent; the image comes back in the response'sinlineDataand is billed by tokens.
Video with Gemini Omni
curl https://1xai.ir/gemini/v1beta/interactions \
-H "x-goog-api-key: 1xai-..." \
-H "Content-Type: application/json" \
--max-time 600 \
-d '{
"model": "gemini-omni-1.1-flash",
"input": "Calm sea waves at sunset",
"response_format": {"type": "video", "duration": "8s"}
}'- The request is synchronous: the answer arrives when the video is made, and the video itself is in the answer's
stepsas base64. background,"store": trueand"delivery": "uri"are not accepted and answer400with codeinvalid_request, because the video is stored nowhere. That error is not billed.durationis one of4s,6sor8s, and the resolution is720p. Input: text, or text with an inline image.- Billed by seconds of video, and only when a video was produced.
- If you close the connection before the answer arrives, the video that was made is billed and can no longer be fetched. Give your client a timeout of several minutes.
- The vendor has retired the Veo models, and
:predictLongRunningwith one of them answers410with codemodel_retired.
What is not on this route
cachedContents, file upload, batch processing, :embedContent and other API versions are not accepted. The full list is under unsupported endpoints. For embeddings use POST /v1/embeddings.
1xAi is an independent gateway. It is not affiliated with, endorsed by, or a reseller for OpenAI, Anthropic, Google, DeepSeek, xAI, Moonshot AI, Z.ai, Alibaba Qwen, MiniMax or Tencent Hunyuan. Requests are relayed upstream rather than answered by models of our own, so each provider's own usage policies apply to what their models will and will not do, and their model availability is theirs to change. Current reachability is published on the status page.