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

HeaderRequiredDescription
AuthorizationYesBearer $OPENDOOR_API_KEY
Content-TypeYesapplication/json
HTTP-Referer / X-TitleNoOptional app attribution (logged on the request)
x-opendoor-service-tierNostandard or priority if not set on the body

Body

FieldTypeRequiredDescription
modelstringYesCatalog id. Start with gemma-4-26b-a4b-it or an id from GET /v1/models
messagesarrayYes{ role, content }content is a string or multimodal parts
streambooleanNoSSE when true
max_tokensintegerNoCompletion cap (estimate uses 1024 if omitted)
temperaturenumberNo0–2
top_pnumberNoNucleus sampling
frequency_penaltynumberNo−2 to 2
presence_penaltynumberNo−2 to 2
toolsarrayNoOpenAI-shaped tools
tool_choicestring/objectNoauto, none, required, or a named function
response_formatobjectNojson_object or json_schema
userstringNoEnd-user id (also used in prompt-cache fingerprint)
service_tierstringNostandard (default) or priority (Pro / Team / Enterprise)
prompt_cache_keystringNoSticky cache key; the gateway sets one if omitted
providerobjectNoOpenRouter-shaped routing (below)
transformsarrayNoMessage 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

bash
export 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

bash
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":"user","content":"Hello"}], "stream": true }'
data: {"id":"…","object":"chat.completion.chunk","choices":[{"delta":{"content":"Hello"}}]}

data: [DONE]

Provider routing

FieldTypeDefaultDescription
orderstring[]Try these slugs first (vertex, together, openai, …)
allow_fallbacksbooleantrueIf false, only the first remaining provider is tried
sortprice | latency | throughputRe-rank the candidate chain
onlystring[]Restrict to these slugs
ignorestring[]Drop these slugs

Org BYOK slugs (and alwaysUse keys) are preferred before platform env keys. Data-residency filters still apply.

bash
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":"user","content":"Hello"}], "provider": { "order": ["vertex"], "allow_fallbacks": true } }'

JavaScript / Python

ts
import { 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" }], });
python
from 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”.