Docs
POST /v1/chat/completions — OpenAI-shaped chat with streaming, tools, and provider routing.
Chat completions
POST /v1/chat/completions
OpenAI-compatible. Usage-billed to the calling key and org credits. This is the path Playground uses.
Base: https://opendoor-gcp.web.app. Auth: Authorization: Bearer $OPENDOOR_API_KEY.
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer $OPENDOOR_API_KEY |
Content-Type | Yes | application/json |
HTTP-Referer / X-Title | No | Optional app attribution (logged on the request) |
x-opendoor-service-tier | No | standard or priority if not set on the body |
Body
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Catalog id. Start with gemma-4-26b-a4b-it or an id from GET /v1/models |
messages | array | Yes | { role, content } — content is a string or multimodal parts |
stream | boolean | No | SSE when true |
max_tokens | integer | No | Completion cap (estimate uses 1024 if omitted) |
temperature | number | No | 0–2 |
top_p | number | No | Nucleus sampling |
frequency_penalty | number | No | −2 to 2 |
presence_penalty | number | No | −2 to 2 |
tools | array | No | OpenAI-shaped tools |
tool_choice | string/object | No | auto, none, required, or a named function |
response_format | object | No | json_object or json_schema |
user | string | No | End-user id (also used in prompt-cache fingerprint) |
service_tier | string | No | standard (default) or priority (Pro / Team / Enterprise) |
prompt_cache_key | string | No | Sticky cache key; the gateway sets one if omitted |
provider | object | No | OpenRouter-shaped routing (below) |
transforms | array | No | Message transforms (context window) |
Pick a live catalog id. Do not treat coming_soon as the way to chat — hosted Vertex MaaS ids such as gemma-4-26b-a4b-it, qwen3-next-80b-instruct, and deepseek-v3.2 are callable when the wholesale path is configured.
Example
bashexport OPENDOOR_API_KEY=opd_… export OPENDOOR_BASE_URL=https://opendoor-gcp.web.app curl "$OPENDOOR_BASE_URL/v1/chat/completions" \ -H "Authorization: Bearer $OPENDOOR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemma-4-26b-a4b-it", "messages": [ {"role": "system", "content": "You are a helpful assistant."}, {"role": "user", "content": "What is OpenDoor?"} ], "max_tokens": 200 }'
Successful responses set id (and x-generation-id) to the logged generation UUID. Fetch it with GET /v1/generation/:id (also mounted at /v1/generations/:id).
json{ "id": "generation-uuid", "object": "chat.completion", "created": 1777777777, "model": "gemma-4-26b-a4b-it", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "…" }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 20, "completion_tokens": 40, "total_tokens": 60 } }
Streaming
bashcurl "$OPENDOOR_BASE_URL/v1/chat/completions" \ -H "Authorization: Bearer $OPENDOOR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemma-4-26b-a4b-it", "messages": [{"role":"user","content":"Hello"}], "stream": true }'
data: {"id":"…","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]}
data: [DONE]
Provider routing
| Field | Type | Default | Description |
|---|---|---|---|
order | string[] | — | Try these slugs first (vertex, together, openai, …) |
allow_fallbacks | boolean | true | If false, only the first remaining provider is tried |
sort | price | latency | throughput | — | Re-rank the candidate chain |
only | string[] | — | Restrict to these slugs |
ignore | string[] | — | Drop these slugs |
Org BYOK slugs (and alwaysUse keys) are preferred before platform env keys. Data-residency filters still apply.
bashcurl "$OPENDOOR_BASE_URL/v1/chat/completions" \ -H "Authorization: Bearer $OPENDOOR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "gemma-4-26b-a4b-it", "messages": [{"role":"user","content":"Hello"}], "provider": { "order": ["vertex"], "allow_fallbacks": true } }'
JavaScript / Python
tsimport { OpenDoor } from "@opendoor/sdk"; const client = new OpenDoor({ apiKey: process.env.OPENDOOR_API_KEY, baseURL: "https://opendoor-gcp.web.app", }); const chat = await client.chat.completions.create({ model: "gemma-4-26b-a4b-it", messages: [{ role: "user", content: "Hello" }], });
pythonfrom opendoor import OpenDoor client = OpenDoor(base_url="https://opendoor-gcp.web.app") out = client.chat.completions.create( model="gemma-4-26b-a4b-it", messages=[{"role": "user", "content": "Hello"}], )
Errors
See Errors for 401 / 402 / 403 / 404 / 429 / 502 / 503 bodies, including insufficient balance and “all providers failed”.