Skip to main content
Sign in

Website navigation

API referenceChat Completions

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.

POSThttps://api.saveapi.cc/v1/chat/completions
On this page

Request example

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.

Example language
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
}'

Headers

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.

Request parameters

This list covers common request fields. Optional settings depend on the selected model and API format.

modelstringRequired
Match a data[].id from GET /v1/models exactly. An unavailable model returns 404 model_not_found.
messagesarrayRequired
At least one conversation message. role is system, developer, user, assistant or tool; content is a string or an array of text parts.
max_tokensinteger
Set max_tokens or max_completion_tokens to an integer from 1 to 32768. The default is 4096. Some GPT models determine their own output length.
streamboolean
Set true to receive server-sent events. Omit for JSON.
toolsarray
Define client-executed function or custom tools. Select a tool with tool_choice and control parallel calls with parallel_tool_calls.
reasoning_effortstring
Set the effort on compatible reasoning models, for example low, medium, or high. 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.format in Responses. For Claude use Messages.
stopstring | array
Supply a stop sequence or an array of sequences. Claude uses stop_sequences for this setting. GPT models ignore stop.
temperaturenumber
Control sampling randomness. The availability and range of temperature and top_p depend 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.

How SaveAPI handles requests

  • 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 (n must be 1), and background responses are unavailable.

JSON response

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.

JSON
{
  "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-id response header when reporting an issue, if available. It identifies the request on this platform.
  • Claude models: prompt_tokens excludes cache; reads and writes are reported in cache_read_input_tokens and cache_creation_input_tokens.
  • GPT models: prompt_tokens includes cached tokens; the cached count is in input_tokens_details.cached_tokens.
  • Usage fields vary by model. For other models, cached tokens are usually listed in prompt_tokens_details.cached_tokens.

Streaming

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.

Example language
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_calls arrive 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 : keepalive comments 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 by data: [DONE].

Error format

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.

JSON
{
  "error": {
    "type": "model_not_found",
    "code": "model_not_found",
    "message": "This model is unavailable."
  }
}