Skip to content
Open app

Text models (Gemini)

Use Gemini request and response formats with your Moonez.ai key. Text models share the Gemini Text permission but have separate input and output token rates. Check your account’s Pricing page before sending requests.

ModelAPI ID
Gemini 4 Argongemini-4-argon
Gemini 3.8 Flashgemini-3.8-flash
Gemini 3.7 Flashgemini-3.7-flash
Gemini 3.6 Flashgemini-3.6-flash
Gemini 3.5 Flashgemini-3.5-flash
Gemini 3.5 Flash Litegemini-3.5-flash-lite
Gemini 3.1 Pro Previewgemini-3.1-pro-preview
Gemini 3.1 Flash Litegemini-3.1-flash-lite
Gemini 3 Flash Previewgemini-3-flash-preview

Gemini Omni (gemini-omni-1.1-flash) also uses token billing and the Gemini-compatible interface, but is managed as a multimedia model. See the complete catalog.

Set MOONEZ_API_KEY in your server environment. Do not embed it in browser code. Use this base URL, including /v1beta:

https://api.moonez.ai/api/gemini/v1beta

Send the key in x-goog-api-key. The official Python SDK adds the header for you; see SDK configuration.

Terminal window
curl -sS https://api.moonez.ai/api/gemini/v1beta/models/gemini-4-argon:generateContent \
-H "x-goog-api-key: $MOONEZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"role": "user",
"parts": [{"text": "Explain idempotency in one sentence."}]
}]
}'

The response uses the Gemini structure: generated text is in candidates[].content.parts[].text. Check the response for blocked or empty candidates rather than assuming text is always present. usageMetadata, when returned by the provider, contains the confirmed usage counters.

Use streamGenerateContent?alt=sse. The -N option disables cURL output buffering.

Terminal window
curl -sS -N 'https://api.moonez.ai/api/gemini/v1beta/models/gemini-3.8-flash:streamGenerateContent?alt=sse' \
-H "x-goog-api-key: $MOONEZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"role": "user",
"parts": [{"text": "Write a short welcome message for a developer dashboard."}]
}]
}'

Each data: event contains a Gemini response chunk. Handle the stream until completion or an error; do not treat the first chunk as the final response. Usage information is preserved when the provider supplies it.

For asynchronous text generation, use the same native jobs endpoint as image generation. aspect_ratio and resolution are required by the unified schema; use auto and 1K for text requests. They do not turn a text model into an image model.

Terminal window
curl -sS https://api.moonez.ai/api/v1/generations \
-H "Authorization: Bearer $MOONEZ_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-4-argon",
"prompt": "Explain idempotency in one sentence.",
"aspect_ratio": "auto",
"resolution": "1K"
}'

A successful submission returns 202 Accepted, a job_id, and status_url. Poll GET /api/v1/jobs/{job_id} with the same Bearer key until the status is done or failed. On success, text is in result.text.

Text models are billed for confirmed token usage, not a fixed fee per request. Each model has independent input and output rates per one million tokens. Use your account’s Pricing → Text models rates, including any individual rates; do not assume that Argon, Flash, and Lite models cost the same. Image models and Gemini Omni have separate pricing sections.

Before generation, Moonez.ai places an estimated hold on your balance, with a minimum reservation of $0.05. This is a temporary reservation, not a minimum charge. After settlement, unused funds become available again.

For new text requests, the input and output rates are saved when the request is accepted. Subsequent tariff changes do not reprice that request. Both the native jobs API and Gemini-compatible API use this calculation:

cost = (confirmed input tokens × input rate
+ confirmed output tokens, including thinking × output rate) / 1,000,000

The final charge is rounded to six decimal places and cannot exceed the initial reservation. Failed or interrupted requests can still incur a charge if the provider reports confirmed usage. Missing counters are not treated as estimated usage: only reported, valid counters are billed. If none are available, the reservation is released without a charge. An absent counter is different from a reported zero.

Open Jobs or Dashboard in your account. The Billing column shows the actual ledger amount with Charged, Reserved, or Not charged, rather than presenting the initial reservation as the price.

For text models, select Token details to see input tokens, response output, thinking tokens, saved rates, unrounded component costs, the initial hold, remaining reservation, and the amount actually charged. Thinking is already included in the billed output total; do not add it twice. The receipt also explains any cap at the reserved amount.

For requests completed before rate snapshots were introduced, historical rates may be unavailable. The actual charge still comes from transaction history; today’s prices are not used to reconstruct it. Requests accepted before the change but settled afterward identify their rates as recorded at settlement, not at submission. Existing transactions are not rewritten.

  • countTokens is free on Moonez.ai. Support depends on the model and provider.
  • Provider limits and supported parameters may differ between models. A shared request format does not imply identical capabilities or quotas.

See API errors and Gemini-compatible API.