Chat Completions
Call OpenGateway’s OpenAI-compatible chat endpoint with a current model ID, inspect request and response fields, and learn where to find model-specific support.
What is the Chat Completions endpoint?#
POST /v1/chat/completions accepts the OpenAI Chat Completions request shape and returns an OpenAI-style completion. OpenGateway routes the request to a provider that can serve the selected model and endpoint.
Model IDs use the creator/model form. Before calling this endpoint, check that the model’s endpoints field from GET /v1/models contains chat_completions. The catalog is public; a restricted API key sees only models allowed for that key.
Endpoint#
POST https://apis.opengateway.ai/v1/chat/completions
Send your API key in Authorization: Bearer <key>.
Request example#
curl https://apis.opengateway.ai/v1/chat/completions \-H "Authorization: Bearer $OPENGATEWAY_API_KEY" \-H "Content-Type: application/json" \-d '{"model": "deepseek/deepseek-v4.1-flash-ultrafast","messages": [{"role": "user", "content": "Say hello in Korean."}]}'
Parameters#
The request follows the Chat Completions shape. Common fields include:
| Field | Type | Description |
|---|---|---|
model | string | Required catalog model ID in creator/model form. |
messages | array | Required conversation history. |
max_completion_tokens | integer | Maximum number of generated tokens. |
temperature, top_p, stop | number, number, string or array | Sampling controls. Availability and accepted values depend on the model. |
reasoning_effort | string | Requests a reasoning level where supported. See compatibility for reasoning fields. |
tools, tool_choice | array, string or object | OpenAI-style function tools and selection. See tool calling. |
response_format | object | Text, JSON object, or JSON Schema output where supported by the model. |
stream | boolean | Set to true to receive server-sent events. See streaming. |
extra.fallbacks | array of strings | Optional model IDs to try after a retryable failure. See fallbacks. |
Supported parameters differ by model. OpenGateway adapts supported fields for the selected provider; consult compatibility for provider-specific behavior.
Response#
A non-streaming response uses the OpenAI Chat Completions response shape. A response contains choices with the assistant message and a finish_reason; token usage is reported in usage.
{"id": "chatcmpl_example","object": "chat.completion","created": 1792728000,"model": "deepseek/deepseek-v4.1-flash-ultrafast","choices": [{"index": 0,"message": {"role": "assistant", "content": "안녕하세요!"},"finish_reason": "stop"}],"usage": {"prompt_tokens": 14,"completion_tokens": 8,"total_tokens": 22}}
OpenAI SDK for Python#
import osfrom openai import OpenAIclient = OpenAI(api_key=os.environ["OPENGATEWAY_API_KEY"],base_url="https://apis.opengateway.ai/v1",)response = client.chat.completions.create(model="deepseek/deepseek-v4.1-flash-ultrafast",messages=[{"role": "user", "content": "Say hello in Korean."}],)print(response.choices[0].message.content)