Gemini generateContent
POST /v1beta/models/{model}:generateContentUse the model name shown on the Pricing page.
Authentication
Section titled “Authentication”x-goog-api-key: OMROUTER_API_KEYContent-Type: application/jsonPath parameter
Section titled “Path parameter”| Parameter | Description |
|---|---|
model |
Model name, URL-encoded before it is placed in the path. |
Request body
Section titled “Request body”| 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. |
Example
Section titled “Example”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."}] } ] }'Response
Section titled “Response”{ "candidates": [ { "content": { "role": "model", "parts": [{"text": "..."}] }, "finishReason": "STOP" } ], "usageMetadata": {}}Some models return additional fields.
Streaming
Section titled “Streaming”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.