curl --request POST \
--url https://api.opper.ai/v3/compat/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": "<unknown>",
"input": "<unknown>"
}
'import requests
url = "https://api.opper.ai/v3/compat/v1beta/models/{model}:generateContent"
payload = {
"contents": "<unknown>",
"input": "<unknown>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({contents: '<unknown>', input: '<unknown>'})
};
fetch('https://api.opper.ai/v3/compat/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"candidates": [
{
"content": {
"parts": [
{
"codeExecutionResult": {},
"executableCode": {},
"functionCall": {},
"inlineData": {},
"text": "<string>",
"thought": true,
"thoughtSignature": "<string>"
}
],
"role": "<string>"
},
"index": 123,
"finishReason": "<string>",
"groundingMetadata": {},
"urlContextMetadata": {}
}
],
"modelVersion": "<string>",
"responseId": "<string>",
"usageMetadata": {
"cachedContentTokenCount": 123,
"candidatesTokenCount": 123,
"opper": {},
"promptTokenCount": 123,
"thoughtsTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}Generate Content
Google Gemini-compatible generateContent endpoint — the drop-in surface for SDKs calling models.generate_content(). The request body is the Gemini GenerateContentRequest shape (camelCase contents / systemInstruction / generationConfig); the response is candidates[].content.parts[] + usageMetadata. The {model} path segment accepts a bare Gemini id (e.g. gemini-2.5-flash, defaults to the Gemini-direct provider) or an Opper-canonical id (e.g. vertexai/gemini-2.5-flash).
curl --request POST \
--url https://api.opper.ai/v3/compat/v1beta/models/{model}:generateContent \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"contents": "<unknown>",
"input": "<unknown>"
}
'import requests
url = "https://api.opper.ai/v3/compat/v1beta/models/{model}:generateContent"
payload = {
"contents": "<unknown>",
"input": "<unknown>"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({contents: '<unknown>', input: '<unknown>'})
};
fetch('https://api.opper.ai/v3/compat/v1beta/models/{model}:generateContent', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));{
"candidates": [
{
"content": {
"parts": [
{
"codeExecutionResult": {},
"executableCode": {},
"functionCall": {},
"inlineData": {},
"text": "<string>",
"thought": true,
"thoughtSignature": "<string>"
}
],
"role": "<string>"
},
"index": 123,
"finishReason": "<string>",
"groundingMetadata": {},
"urlContextMetadata": {}
}
],
"modelVersion": "<string>",
"responseId": "<string>",
"usageMetadata": {
"cachedContentTokenCount": 123,
"candidatesTokenCount": 123,
"opper": {},
"promptTokenCount": 123,
"thoughtsTokenCount": 123,
"totalTokenCount": 123
}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}{
"error": {
"code": "<string>",
"message": "<string>",
"details": "<unknown>"
},
"meta": {}
}Authorizations
API key authentication. Pass your API key as a Bearer token.
Headers
Function name for tracing and project-level guardrail function-scope filtering.
Parent span ID for distributed tracing context.
Comma-separated key:value usage-attribution tags (e.g. tenant:acme,project:demo, max 8). Recorded on the generation's billing/metrics rows; group spend by any key via GET /v2/analytics/usage?group_by=. Header-borne twin of the /v3/session URL prefix tags (which win per key when both are present); opper.-prefixed keys and session_id are reserved. Malformed values return 400.
Path Parameters
Model id — a bare Gemini name (e.g. gemini-2.5-flash, resolved against the Gemini-direct provider) or an Opper-canonical id (e.g. vertexai/gemini-2.5-flash).
Body
Any value
Any value
Opt in to automatic prompt caching for Anthropic-family models routed through this Gemini-shape endpoint: {"type":"ephemeral"} (optionally "ttl":"1h"). Places one moving cache breakpoint on the largest cacheable prefix. Caching is off unless set; no-op on Gemini and other providers with automatic server-side caching. Cache writes cost 1.25x input and reads 0.1x
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes
Show child attributes