Chat Completions (OpenAI-compatible)
POST /v1/chat/completions — OpenAI Chat Completions, parameter by parameter
Fully compatible with OpenAI Chat Completions. Point base_url at ModelSite and call Claude, GPT, DeepSeek, GLM, Qwen, MiniMax and every other model with the same code — no business-logic changes. The platform handles authentication, billing and multi-vendor failover.
Example
from openai import OpenAI
client = OpenAI(
base_url="https://api.modelsite.ai/v1",
api_key="ms_live_sk_xxxxxxxx", # env var MODELSITE_API_KEY
)
resp = client.chat.completions.create(
model="claude-sonnet-4.6",
messages=[{"role": "user", "content": "Explain quantum entanglement in one sentence"}],
)
print(resp.choices[0].message.content)model is required (both billing and routing depend on it). The API card below is rendered from the OpenAPI spec: HTTP method & path, an interactive Request-body parameter table, and the Response schema.
Authorization
BearerAuth Authorization: Bearer $MODELSITE_API_KEY
In: header
Request Body
application/json
TypeScript Definitions
Use the request body type in TypeScript.
Response Body
application/json
curl -X POST "https://example.com/chat/completions" \ -H "Content-Type: application/json" \ -d '{ "model": "string", "messages": [ { "role": "system" } ] }'{ "id": "string", "object": "string", "created": 0, "model": "string", "choices": [ { "index": 0, "message": { "role": "system", "content": "string", "name": "string", "tool_calls": [ { "id": "string", "type": "function", "function": { "name": "string", "arguments": "string" } } ], "tool_call_id": "string", "refusal": "string" }, "finish_reason": "stop", "logprobs": {} } ], "usage": { "prompt_tokens": 0, "completion_tokens": 0, "total_tokens": 0, "prompt_tokens_details": { "cached_tokens": 0, "text_tokens": 0, "audio_tokens": 0 }, "completion_tokens_details": { "reasoning_tokens": 0, "audio_tokens": 0, "accepted_prediction_tokens": 0, "rejected_prediction_tokens": 0 } }}Multimodal input
Vision models take images via an object array in content:
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/cat.png"}}
]
}]Streaming
stream: true returns Server-Sent Events, pushing tokens as they arrive:
for chunk in client.chat.completions.create(
model="claude-sonnet-4.6",
messages=[{"role": "user", "content": "Tell me a story"}],
stream=True,
stream_options={"include_usage": True},
):
delta = chunk.choices[0].delta.content if chunk.choices else None
if delta:
print(delta, end="")Tool calling (Function Calling)
Declare tools; the model returns tool_calls. Reply with a tool-role message to continue:
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the weather for a city",
"parameters": {"type": "object", "properties": {"city": {"type": "string"}}}
}
}]Vendor-specific parameter pass-through: as an aggregation proxy, the platform forwards the request body to the underlying model vendor. Vendor-specific parameters (e.g. Qwen's enable_thinking, thinking_budget, top_k, enable_search; DeepSeek's reasoning_effort) are passed through unchanged — in the Python SDK put them in extra_body, e.g. extra_body={"enable_thinking": True}. Whether they take effect depends on the vendor supporting them.
The platform performs automatic multi-vendor failover on every request, switching transparently on upstream failure. See Failover.