DeepSeek

DeepSeek API

DeepSeek V4 chat with thinking mode, streaming, tool calls, JSON output, context caching, FIM and prefix completion, plus balance checks.

AI & machine learningGuided#deepseek#llm#chat#reasoning#openai-compatible#function-calling#context-caching

Fork copies the collection into your workspace, without the publisher's secrets, so you can add your own key and send requests. Star saves it to your starred APIs (Account › Marketplace) and helps others find it.

Overview

DeepSeek's API serves the DeepSeek V4 family of large language models through an OpenAI-compatible Chat Completions interface (an Anthropic-compatible endpoint also exists at https://api.deepseek.com/anthropic). Both current models reason before they answer by default, support tool calls and JSON output, take a context of about one million tokens, and benefit automatically from disk-based context caching that makes repeated prompt prefixes much cheaper.

Get an API key

  1. Create an account or sign in on the DeepSeek Platform.
  2. Add funds to your account from the platform's billing/top-up area: calls fail with 402 when the balance is empty (granted promotional balance is used first).
  3. Open API keys, create a key and copy it straight away.
  4. Paste it into this collection's apiKey variable. It is marked secret, so it is never shared when you fork or publish.

Authentication

Every request sends Authorization: Bearer <your key>; the collection does this for you. Rate limits are counted per account, not per key.

Base URLs

  • https://api.deepseek.com: the main OpenAI-format API (/models, /chat/completions, /user/balance). OpenAI SDKs work with base_url set to it.
  • https://api.deepseek.com/beta: beta features: chat prefix completion, FIM (/completions) and strict tool schemas.

Models

Model IDWhat it is
deepseek-flashDeepSeek-V4.1-Flash: fast and cheap, accepts images, the default here.
deepseek-v4-proDeepSeek-V4-Pro: stronger and pricier, text only.

Both think by default (thinking / reasoning_effort control it). The old names deepseek-v4-flash and deepseek-v4-flash-vision-exp are retired and routed to Flash. See Models & Pricing.

How to use this collection

  1. Fill in apiKey. model defaults to deepseek-flash; proModel is deepseek-v4-pro.
  2. Run 1. Start here (models, balance, a first completion).
  3. 2. Thinking shows reasoning effort, streaming reasoning and the multi-turn rule.
  4. 3. Chat patterns covers system prompts, streaming and context caching (watch prompt_cache_hit_tokens).
  5. 4. Tool calls: run each numbered pair in order; step 1 saves the IDs step 2 needs.
  6. 5. JSON output and 6. Beta completions are single requests.

Common errors

StatusMeaningWhat to do
400Invalid formatFix the body; in thinking-mode tool loops, pass reasoning_content back.
401Authentication failedWrong or deleted API key.
402Insufficient balanceCheck Check your balance and top up.
422Invalid parametersA value is out of range; read the error message.
429Rate limit reachedToo many concurrent requests for your account; slow down or request more capacity.
500Server errorRetry after a short wait.
503Server overloadedRetry after a short wait.

Limits and pricing

Billing is per million tokens, with separate prices for cache-hit input, cache-miss input and output (reasoning counts as output); prices are lower outside the published peak hours. Concurrency limits are per account and per model. Details: Models & Pricing, Rate Limit, Error Codes, Context caching, Thinking mode and the API reference. Service health: status.deepseek.com.

Endpoints 19

1. Start here

  • GETList models/modelsReturns the models you can put in model. Today that is deepseek-flash (served by DeepSeek-V4.1-Flash) and deepseek-v4-pro. Each entry carries id, owned_by,…
  • GETCheck your balance/user/balanceShows whether your account can make paid calls (is_available) and the balance per currency in balance_infos[]: currency (CNY or USD), total_balance,…
  • POSTCreate a chat completion/chat/completionsThe core call: send a list of messages and get the assistant's reply in choices[0].message.content. The request and response follow the OpenAI Chat…

2. Thinking (reasoning)

  • POSTThink before answering (high effort)/chat/completionsBoth models think by default. Thinking mode returns the chain of thought in message.reasoning_content, next to the final answer in message.content. Reasoning…
  • POSTMaximum effort on the Pro model/chat/completionsSame call with reasoning_effort: "max" on deepseek-v4-pro (the proModel variable), for hard maths, planning and code review where answer quality matters more…
  • POSTStream reasoning and answer (SSE)/chat/completionsWith stream: true the reply arrives as server-sent events (chat.completion.chunk). In thinking mode the first chunks carry delta.reasoning_content, then…
  • POSTTurn thinking off (with sampling)/chat/completionsNon-thinking mode answers straight away with no reasoning_content, which is faster and cheaper for chat, extraction and rewriting. Turn it off with thinking:…
  • POSTMulti-turn with thinking/chat/completionsThe API keeps no conversation state: send the whole history in messages each time. The reasoning_content rule: in a plain conversation (no tools), do not send…

3. Chat patterns

  • POSTSystem prompt and conversation/chat/completionsA system message sets the assistant's role and rules; the following user and assistant messages are the history. Because the server is stateless, your app…
  • POSTStream the answer (SSE)/chat/completionsStreaming without thinking: chunks carry delta.content pieces, the last one has finish_reason, and data: [DONE] closes the stream. Append the deltas to build…
  • POSTContext caching: send the same prefix twice/chat/completionsContext caching is on for every account and needs no parameter. The API stores the start of each request on disk; when a later request begins with the same…

4. Tool calls (function calling)

  • POST1) Offer a tool/chat/completionsList your functions in tools (each {"type": "function", "function": {name, description, parameters}}, parameters is a JSON Schema). When the model wants one…
  • POST2) Send the tool result back/chat/completionsReplays the conversation: the user message, the assistant message holding the tool_calls from step 1 (ID and arguments filled from variables), and one tool…
  • POST1) Tool call while thinking/chat/completionsThinking mode can reason, call tools, reason again and call more tools before answering. The response carries reasoning_content, possibly some content, and…
  • POST2) Return the result while thinking/chat/completionsSends the assistant turn back exactly as received, including reasoning_content, plus the tool result. The model continues reasoning and either calls another…
  • POSTStrict tool schema (beta){{betaUrl}}/chat/completionsWith strict: true on every function, the server validates your schema and makes the arguments follow it exactly. Strict mode is a beta feature: the request…

5. JSON output

  • POSTJSON output/chat/completionsSet response_format: {"type": "json_object"}. The prompt must also ask for JSON (use the word "json") and should show the exact shape you want. Watch out: if…

6. Beta completions

  • POSTChat prefix completion{{betaUrl}}/chat/completionsYou write the start of the assistant's reply and the model continues from there. Make the last message an assistant message with prefix: true and your…
  • POSTFIM completion (fill in the middle){{betaUrl}}/completionsCode infilling: give the text before the gap in prompt and the text after it in suffix; the model writes what goes between. Uses the OpenAI-style Completions…

API details

Base URL
https://api.deepseek.com
https://api.deepseek.com/beta
Authentication
A bearer token in the Authorization header
Operations
19 operations on 19 pathsPOST 17GET 2
Main resources
1. Start here 32. Thinking (reasoning) 53. Chat patterns 34. Tool calls (function calling) 55. JSON output 16. Beta completions 2
Description format
Swastik Codes guided collection, API version checked against the docs on 2026-11-17

How to test the DeepSeek API in Swastik Codes

  1. Open the APISelect “Fork & run in Swastik Codes” on this page. Sign in or create a free account if asked.
  2. Fork it into your workspaceChoose a workspace. You get your own copy of the DeepSeek API collection, without the publisher's secrets.
  3. Add your credentialsThis API uses A bearer token in the Authorization header. Add yours in the collection's variables or an environment; the requests already reference it.
  4. Send a requestPick an endpoint, for example “List models” (GET /models), and press Send. Check the response, add tests and run the whole collection with the runner.

Frequently asked questions

What is the DeepSeek API?

DeepSeek V4 chat with thinking mode, streaming, tool calls, JSON output, context caching, FIM and prefix completion, plus balance checks. It is listed under AI & machine learning and has 19 endpoints.

Who publishes the DeepSeek API?

It is listed from DeepSeek's public API description (an OpenAPI document), not published by DeepSeek on Swastik Codes. Anyone who controls deepseek.com can claim the profile by adding a DNS TXT record.

What is the base URL of the DeepSeek API?

Its description lists 2 base URLs: https://api.deepseek.com, https://api.deepseek.com/beta. The first is the usual one; the others are typically sandbox or regional servers.

How do I authenticate with the DeepSeek API?

With A bearer token in the Authorization header.

How many endpoints does the DeepSeek API have?

19 operations on 19 paths (17 POST, 2 GET). The largest groups are 1. Start here, 2. Thinking (reasoning), 3. Chat patterns, 4. Tool calls (function calling).

Is forking the DeepSeek API free?

Yes. Forking copies the collection into your workspace for free. It has been starred 0 times and forked 0 times.

Suggest an API

Tell us which public API is missing. We check it, then add it here with its endpoints when it has an OpenAPI (Swagger) description.