IN ENGLISH · API DOCS

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:

[01]GEMINI (NATIVE)

generateContent and streamGenerateContent

POST /gemini/v1beta/models/{model}:generateContentcurl
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}
  }'
The official Google GenAI SDKpython
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 v1beta and v1 are accepted.
  • The body is Google's: contents, systemInstruction, generationConfig, tools, safetySettings.
  • The bill is computed from usageMetadata: prompt tokens, output tokens and thinking tokens; cachedContentTokenCount at 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, fields and prettyPrint reach Google. For streaming as SSE, call :streamGenerateContent?alt=sse.
  • When Google answers 429, 503 or 529, the gateway tries up to 3 times.
[02]GEMINI (NATIVE)

Free routes

  • POST …/models/{model}:countTokens: counting tokens before sending.
  • GET /gemini/v1beta/models and GET /gemini/v1beta/models/{model}: the model list and a model's details.
[03]GEMINI (NATIVE)

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 402 with code hosted_tool_unmetered (hosted tools).
  • Call Google's image models with the same :generateContent; the image comes back in the response's inlineData and is billed by tokens.
[04]GEMINI (NATIVE)

Video with Gemini Omni

POST /gemini/v1beta/interactionscurl
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 steps as base64.
  • background, "store": true and "delivery": "uri" are not accepted and answer 400 with code invalid_request, because the video is stored nowhere. That error is not billed.
  • duration is one of 4s, 6s or 8s, and the resolution is 720p. 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 :predictLongRunning with one of them answers 410 with code model_retired.
[05]GEMINI (NATIVE)

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.