Skip to content

Gemini generateContent

POST /v1beta/models/{model}:generateContent

Use the model name shown on the Pricing page.

x-goog-api-key: OMROUTER_API_KEY
Content-Type: application/json
Parameter Description
model Model name, URL-encoded before it is placed in the path.
Field Type Required Description
contents array Yes Conversation content.
contents[].role string No Common values are user and model.
contents[].parts array Yes Text or supported multimodal parts.
generationConfig object No Generation settings supported by the selected model.
systemInstruction object No System instruction in Gemini format.
tools array No Tool declarations where supported.
Terminal window
curl --silent --show-error \
"https://omrouter.com/v1beta/models/${OMROUTER_MODEL_ID}:generateContent" \
--header "x-goog-api-key: $OMROUTER_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
"contents": [
{
"role": "user",
"parts": [{"text": "Reply with one short sentence."}]
}
]
}'
{
"candidates": [
{
"content": {
"role": "model",
"parts": [{"text": "..."}]
},
"finishReason": "STOP"
}
],
"usageMetadata": {}
}

Some models return additional fields.

Gemini streaming differs from OpenAI streaming. Use a client that supports Gemini streaming responses.

See the Gemini-compatible API guide for a complete direct HTTP example.