Docs

Model APIs

Gemini native content generation

Use generateContent and streamGenerateContent with contents, parts and generationConfig.

Updated

POST/v1beta/models/{model_action}

Generate content

The native endpoint is POST /v1beta/models/{model}:generateContent. contents holds conversation turns and parts holds text or multimodal input supported by the model. Use an available model id from your current catalog.

cURL
curl --fail-with-body "https://api.token4ai.cloud/v1beta/models/YOUR_MODEL_ID:generateContent" \
  -H "x-goog-api-key: $TOKEN4AI_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"contents":[{"role":"user","parts":[{"text":"Explain vector search."}]}],"generationConfig":{"maxOutputTokens":256}}' 

Read candidates

Text is typically under candidates[].content.parts[].text. Inspect finishReason and usageMetadata. Filtering or absent candidates can produce no ordinary text; present a clear no-result state rather than retry an empty array as a network failure.

Native streaming

Use :streamGenerateContent?alt=sse for streaming. The action name selects the stream; do not paste a Chat Completions messages body into it. Verify model, credentials and routing with native REST first, then configure your SDK’s custom endpoint.

cURL
curl -N --fail-with-body "https://api.token4ai.cloud/v1beta/models/YOUR_MODEL_ID:streamGenerateContent?alt=sse" \
  -H "x-goog-api-key: $TOKEN4AI_API_KEY" \
  -H "Content-Type: application/json" \
  --data '{"contents":[{"role":"user","parts":[{"text":"Hello"}]}]}' 

Related guides