Chat Completions
An OpenAI Chat Completions compatible endpoint. OpenAI SDKs, most chat clients and agent frameworks connect directly, and non-OpenAI models such as Claude and DeepSeek can also be called in this format.
https://api.saveapi.cc/v1/chat/completionsOn this page
Set the base URL to https://api.saveapi.cc/v1; the OpenAI SDKs need no other change. Under https://api.saveapi.cc, /chat/completions without /v1 works too.
curl -sS "https://api.saveapi.cc/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash",
"messages": [
{
"role": "system",
"content": "You are a helpful assistant."
},
{
"role": "user",
"content": "Hello"
}
],
"max_tokens": 1024
}'AuthorizationBearer YOUR_API_KEYRequired- Use your platform API key. You can also send
x-api-key: YOUR_API_KEY. Content-Typeapplication/json- The request body is JSON.
This list covers common request fields. Optional settings depend on the selected model and API format.
modelstringRequired- Match a
data[].idfromGET /v1/modelsexactly. An unavailable model returns404model_not_found. messagesarrayRequired- At least one conversation message.
roleissystem,developer,user,assistantortool;contentis a string or an array oftextparts. max_tokensinteger- Set
max_tokensormax_completion_tokensto an integer from 1 to 32768. The default is 4096. Some GPT models determine their own output length. streamboolean- Set
trueto receive server-sent events. Omit for JSON. toolsarray- Define client-executed
functionorcustomtools. Select a tool withtool_choiceand control parallel calls withparallel_tool_calls. reasoning_effortstring- Set the effort on compatible reasoning models, for example
low,medium, orhigh. Claude uses its default here. Use Messages to configure Claude thinking. response_formatobject- Request JSON or JSON Schema with compatible models such as DeepSeek. For GPT use
text.formatin Responses. For Claude use Messages. stopstring | array- Supply a stop sequence or an array of sequences. Claude uses
stop_sequencesfor this setting. GPT models ignorestop. temperaturenumber- Control sampling randomness. The availability and range of
temperatureandtop_pdepend on the model. prompt_cache_keystring- Use a prompt cache key of up to 64 characters on compatible models. Reuse the key across turns in a session.
cache_controlobject- For Claude, set prompt caching at the top level. The default is 5 minutes. Use
{"type":"ephemeral","ttl":"1h"}for an hour at a higher write rate.
- For multi-turn chat, send the earlier messages and tool results in order in
messages. - Only stateless text input is supported; image, audio, video and PDF inputs return
400. - Each request returns one completion (
nmust be1), andbackgroundresponses are unavailable.
Read text from choices[].message.content. finish_reason may indicate completion (stop), the output limit (length), or a tool call (tool_calls). usage reports input, output and total tokens.
{
"id": "chatcmpl_example",
"object": "chat.completion",
"created": 1793952000,
"model": "deepseek-v4.1-flash",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello!"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 7,
"completion_tokens": 4,
"total_tokens": 11
}
}- Include the
x-request-idresponse header when reporting an issue, if available. It identifies the request on this platform. - Claude models:
prompt_tokensexcludes cache; reads and writes are reported incache_read_input_tokensandcache_creation_input_tokens. - GPT models:
prompt_tokensincludes cached tokens; the cached count is ininput_tokens_details.cached_tokens. - Usage fields vary by model. For other models, cached tokens are usually listed in
prompt_tokens_details.cached_tokens.
Append delta.content from data events by choice index. On successful completion, the final JSON chunk includes finish_reason and usage. The gateway includes usage by default, so you can omit stream_options.include_usage. Stop reading at data: [DONE] and handle a premature close as an interruption.
curl -NsS "https://api.saveapi.cc/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4.1-flash",
"messages": [
{
"role": "user",
"content": "Hello"
}
],
"stream": true
}'- Tool calls are not streamed piece by piece; the complete
tool_callsarrive at the end of the stream. - Claude and other reasoning models may stream thinking in
delta.reasoning_content; GPT models return no thinking text. - The stream may send
: keepalivecomments while the first data is pending. Clients can ignore them. - If an error occurs after the stream starts, a
data: {"error": …}event may arrive, followed bydata: [DONE].
Errors use the OpenAI shape: error.code is the code to branch on, and error.type matches the code. See error codes and troubleshooting for what each status means.
{
"error": {
"type": "model_not_found",
"code": "model_not_found",
"message": "This model is unavailable."
}
}