Chat Completions
The Chat Completions endpoint is OpenAI-compatible. Use it with OpenAI models and any OpenAI-protocol model in the catalog.
POST https://api.smartapi.cc/api/openapi/v1/chat/completionsAuthentication#
Authorization: Bearer sk-your-key-here
Content-Type: application/jsonRequest body#
SmartAPI proxies the request body to the upstream provider, so all standard OpenAI Chat Completions parameters are supported. The most common fields:
| Field | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model identifier, e.g. gpt-4.1. |
messages | array | Yes | Conversation messages, each with role and content. |
stream | boolean | No | Stream the response as server-sent events. Defaults to false. |
temperature | number | No | Sampling temperature. |
max_tokens | integer | No | Maximum tokens to generate. |
Only model is validated by SmartAPI itself; all other parameters are
forwarded to the upstream provider unchanged.
Thinking / Reasoning#
Whether to enable thinking/reasoning is controlled by request parameters. Models
that support thinking carry a thinking tag on the Models page.
Thinking is off by default when none of the parameters below are sent.
| Field | Type | Description |
|---|---|---|
reasoning_effort | string | Reasoning level: none / minimal / low / medium / high / xhigh. none disables it; any other value enables it. |
thinking | object | Extended thinking config (aligned with Anthropic / Bedrock Claude). When present alongside reasoning_effort, thinking.type takes precedence. |
thinking object fields:
| Field | Type | Description |
|---|---|---|
type | string | enabled / disabled. |
budget_tokens | number | Thinking token budget; ensure max_tokens > budget_tokens. |
display | string | e.g. omitted; forwarded when the upstream supports it. |
{
"model": "gpt-5.5",
"messages": [{ "role": "user", "content": "Hello" }],
"reasoning_effort": "medium"
}Basic example#
curl https://api.smartapi.cc/api/openapi/v1/chat/completions \
-H "Authorization: Bearer $SMARTAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4.1",
"messages": [
{ "role": "system", "content": "You are a helpful assistant." },
{ "role": "user", "content": "What is SmartAPI?" }
]
}'Response#
{
"id": "chatcmpl-...",
"object": "chat.completion",
"created": 1730000000,
"model": "gpt-4.1",
"choices": [
{
"index": 0,
"message": { "role": "assistant", "content": "SmartAPI is..." },
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 88,
"total_tokens": 112
}
}Streaming#
Set stream to true to receive the response incrementally as
text/event-stream server-sent events. SmartAPI automatically requests usage data
in the final chunk.
from openai import OpenAI
client = OpenAI(
api_key="sk-your-key-here",
base_url="https://api.smartapi.cc/api/openapi/v1",
)
stream = client.chat.completions.create(
model="gpt-4.1",
messages=[{"role": "user", "content": "Write a haiku about APIs."}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="")Each SSE chunk looks like:
data: {"id":"chatcmpl-...","choices":[{"delta":{"content":"Hello"}}]}
data: [DONE]The stream terminates with a data: [DONE] line.
Usage and billing#
The usage object reports prompt_tokens, completion_tokens, and
total_tokens. When the provider supports prompt caching, usage may also include
prompt_tokens_details.cached_tokens. Token usage drives
billing.