Use this section when adapting an existing client or debugging a request that works against one vendor SDK but fails through the gateway.
Pick the endpoint by workload
| Workload | Endpoint | Model examples | Notes |
|---|---|---|---|
| Text chat | POST /v1/chat/completions |
gemini-3.1-pro, claude-sonnet-5, gpt-5.6-terra |
Standard OpenAI Chat Completions shape. |
| GPT reasoning / tool workflows | POST /v1/responses |
gpt-6.1-sol, gpt-5.6-sol, gpt-5.6-terra |
Recommended for GPT-5.x reasoning and tool state. |
| Text-to-image | POST /v1/images/generations |
gpt-image-2, gemini-3-pro-image, FLUX.2-pro |
JSON request body. |
| Image edit / image-to-image | POST /v1/images/edits |
gpt-image-2, gemini-3-pro-image |
Multipart form request with one or more image files. |
| Embeddings | POST /v1/embeddings |
gemini-embedding-001 |
Non-streaming vector output. |
| TTS | POST /v1/audio/speech |
gemini-3.1-flash-tts-preview |
Full audio body response; Gemini returns WAV. |
| Gemini native multimodal | /gemini/v1beta/models/{model}:generateContent |
gemini-* |
Use when your client already sends Google contents.parts with inline_data or fileData. |
Always call GET /v1/models with the same API key you will use in production
before exposing a model in your UI. The response is filtered by the token's
allowed models.
Multimodal request formats
OpenAI-compatible chat vision:
{
"model": "gemini-3.1-pro",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "Describe this image"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}]
}
Gemini-native multimodal:
{
"contents": [{
"role": "user",
"parts": [
{"text": "Describe this image"},
{"inline_data": {"mime_type": "image/jpeg", "data": "<BASE64_IMAGE_DATA>"}}
]
}]
}
Use the native Gemini route only when your client already speaks Gemini's
contents.parts format. OpenAI SDK clients should use the OpenAI-compatible
messages[].content[] format above.
For Gemini-native media, inlineData.data / inline_data.data and
thoughtSignature inputs accept either standard base64 or URL-safe base64,
with or without padding. API429 responses use canonical padded standard
base64. This makes response → next-request round trips safe without a client
re-encoding step.
Streaming clients
- Read SSE to termination and verify the successful terminal event;
[DONE]alone is not proof of success. Responses must finish withresponse.completedand statuscompleted. Treatresponse.failed,response.incomplete,errorand premature EOF as unsuccessful. - Ignore SSE comments and empty lines.
- Do not convert "stream returned 0 chunks" into an immediate second non-streaming request for long jobs; that can duplicate work and cost.
- If the HTTP request fails before any SSE data is processed, retry with exponential backoff.
- If an
event: errorarrives after text/audio/image work has started, treat it as a failed attempt and retry only according to your product's idempotency policy.
Retries and rate limits
- Respect
Retry-Afterwhen present. - Retry 429, 503, 504 and transient network errors with backoff.
- Do not hot-loop retries. Use jitter and cap retries.
- For long Claude text jobs, prefer
stream:truefor interactive UX orX-Async-Jobs-Optin: truefor non-streaming durable execution.
Common request fixes
| Symptom | Likely cause | Fix |
|---|---|---|
404 on a documentation .md link |
Separate markdown guides are not served publicly | Use this /documentation page; all public examples are here. |
model_not_found or model_not_allowed |
Token allowlist does not include the requested model | Call GET /v1/models with the same key and use one of those IDs. |
| Image edit fails with JSON body | /v1/images/edits expects multipart form |
Send -F "image=@file.png" and -F "prompt=...". |
| Gemini image-to-image payload is rejected | Client sends Google inline_data to an OpenAI-compatible endpoint |
Use the documented Gemini-native or JSON Images request shape. Use multipart /v1/images/edits only with an ID supported by that endpoint; see Nano endpoint limits. |
| TTS response cannot be parsed as JSON | /v1/audio/speech returns binary audio |
Read the response as bytes/blob and save/play it as WAV or MP3. |
| Claude streaming appears idle | Client waits for final response instead of reading SSE | Use stream:true, parse chunks incrementally, and keep a long read timeout. |
temperature rejected on a reasoning model |
Some reasoning modes require provider-specific sampling rules | Omit temperature unless you need it; use reasoning_effort for reasoning depth. |
Quickstart: the first request · Models and prices · Get an API key