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#

Bash
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:

FieldTypeDescription
modelstringRequired catalog model ID in creator/model form.
messagesarrayRequired conversation history.
max_completion_tokensintegerMaximum number of generated tokens.
temperature, top_p, stopnumber, number, string or arraySampling controls. Availability and accepted values depend on the model.
reasoning_effortstringRequests a reasoning level where supported. See compatibility for reasoning fields.
tools, tool_choicearray, string or objectOpenAI-style function tools and selection. See tool calling.
response_formatobjectText, JSON object, or JSON Schema output where supported by the model.
streambooleanSet to true to receive server-sent events. See streaming.
extra.fallbacksarray of stringsOptional 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.

JSON
{
"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#

Python
import os
from openai import OpenAI
client = 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)

See also#

Chat Completions — OpenGateway