DeepSeek chat API

Use DeepSeek R1, V3.2, and V4 for chat, streaming, reasoning, and function calls.

Use an Official Group API key with the base URL https://app.apipool.dev/v1. Open an available model from the DeepSeek catalog for its playground and current price.

Models and capabilities

Model IDText and streamingFunction calls
deepseek-r1YesUnavailable
deepseek-r1-0528YesUnavailable
deepseek-v3.2YesYes
deepseek-v4-flashYesUnavailable
deepseek-v4-proYesUnavailable
deepseek-v4.1-flashYesUnavailable

Use the model IDs exactly as shown, including deepseek-r1-0528. The listed models accept text messages. Images, PDF, and OCR inputs are unavailable. Check the catalog for current availability.

Non-streaming and streaming calls

curl https://app.apipool.dev/v1/chat/completions \
  -H "Authorization: Bearer $APIPOOL_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v3.2",
    "messages": [{"role": "user", "content": "Explain recursion in two sentences."}],
    "max_tokens": 1024,
    "stream": false
  }'

Omit stream for a non-streaming response and read choices[0].message.content. For streaming, set stream: true and stream_options: {"include_usage": true}. Assemble choices[].delta.content and read through data: [DONE], keeping the final usage.

When R1 returns reasoning_content or the streaming field delta.reasoning_content, read it separately from the answer. R1-0528 can include reasoning and a </think> marker directly in the answer text. Preserve that text. Reasoning and answer tokens share the output budget. finish_reason: "length" indicates truncation. Increase max_tokens if the task needs a longer output.

The playground caps output at 2,048 tokens. For longer reasoning answers, set the output budget through the API.

Function calling

deepseek-v3.2 accepts function tools and tool_choice. Your application executes each returned message.tool_calls entry and sends its result in a role: "tool" message.

{
  "model": "deepseek-v3.2",
  "messages": [{ "role": "user", "content": "Check the weather in Beijing." }],
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "get_weather",
        "description": "Look up a city weather forecast.",
        "parameters": {
          "type": "object",
          "properties": { "city": { "type": "string" } },
          "required": ["city"]
        }
      }
    }
  ],
  "tool_choice": { "type": "function", "function": { "name": "get_weather" } },
  "stream": false,
  "max_tokens": 1024
}

Pricing

Prices are in US dollars per million tokens. Input, cached input, and output each use their own rate. Output usage includes reasoning tokens.

ModelInputCached inputOutput
R10.4760.4761.904
R1-05280.43350.43351.30917
V3.20.218450.218450.327675
V4 Flash0.3642850.0364281.092857
V4 Pro1.0928570.1092853.278572
V4.1 Flash0.2428570.0048110.971428

Rates stay the same throughout the day. A cache hit uses the cached-input rate for those tokens, and remaining tokens use the standard input rate. Check the model catalog for active prices and Usage for actual charges.

Parameters and troubleshooting

  • Use POST /v1/chat/completions. Responses, Messages, and text completion endpoints are unavailable for these models.
  • Use system, user, assistant, or tool for message roles. Provide text in content.
  • Optional fields include max_tokens, temperature, top_p, frequency_penalty, presence_penalty, stop, seed, and response_format. Remove a field if the model rejects it. Sampling behavior can vary by model.
  • Built-in web search, explicit caching, passthrough containers, and image input are unavailable. Unsupported requests return HTTP 400.
  • For HTTP 401, check your API key. If a model is unavailable, verify the Official Group and catalog status. For HTTP 429, reduce concurrency.
  • After a disconnect, save x-apipool-request-id and check usage records before retrying.