EN ▾
Get API key

Does DeepSeek Support Tool Calling? What Works Here

Function calling is the feature agent frameworks check first. Here is what this endpoint accepts, a full round trip in code, and the mistakes that break agent loops.

Updated

Key points

  • This endpoint supports tools, tool_choice, streamed tool_calls and role tool results on the model ID uncensored.
  • JSON mode is available through response_format when you want a plain structured reply instead of a function call.
  • An agent loop costs fractions of a cent per run at $0.15 / $0.50 per 1M tokens.
  • This is not the official DeepSeek API, so check DeepSeek's own docs for what their service supports.
Isometric scene of modules passing glowing cubes in a loop, representing a tool-calling agent cycle

The short answer

People who type does deepseek support tool calling into a search box usually want one of two things: a yes or no for their agent framework, or a working request they can copy. I can answer both for this service, and I will be careful about the first part. This site is not the official DeepSeek API and does not speak for it. What DeepSeek's own hosted API accepts is documented by DeepSeek, so read their current docs before you plan around it.

For the endpoint on this site the answer is yes. It exposes POST /v1/chat/completions with the standard OpenAI tools and tool_choice fields, returns tool_calls on the assistant message, accepts your results as role: "tool" messages, and streams partial tool calls over SSE. The model ID is uncensored. It is a single open-weight model run by an independent provider, tuned to answer without content refusals for lawful adult use.

That last point matters for tool use. A model that refuses less also tends to call your function when you ask it to, instead of talking its way around the request. It will still make mistakes with arguments, so the code later in this article validates everything the model sends back.

What the API accepts

Everything below goes to the same chat completions route. There is no separate "functions" endpoint and no special header. If your code already talks to an OpenAI-style server, you change two values: the base URL https://api.uncensoreddeepseek.cc/v1 and the key.

Field or featureStatusNotes
toolsSupportedArray of type: "function" definitions with a JSON Schema for parameters.
tool_choiceSupportedUse "auto" to let the model decide, or name a function to force it.
Tool resultsSupportedSend them back as messages with role: "tool" and the matching tool_call_id.
Streaming tool callsSupportedstream: true, with usage reported at the end of the stream.
JSON modeSupportedresponse_format: {"type":"json_object"}.
Sampling controlsPassed throughtemperature, top_p, stop, seed and the penalties.
Image, audio, embeddings, fine-tuningNot availableThe service is text only.

The context window is 100,000 tokens, prompt plus completion. Tool definitions count against it, which rarely matters for five or ten functions but does matter if you paste in a large tool catalog. The quickstart in the docs lists the same parameters in a shorter form.

A full round trip in Python

A tool-calling exchange has four steps. You send the question and the function definitions. The model answers with one or more tool_calls instead of text. You run the functions yourself and append the results. Then you call the API again so the model can write the final answer. The model never executes anything; your code does.

import json
from openai import OpenAI

client = OpenAI(base_url="https://api.uncensoreddeepseek.cc/v1", api_key="YOUR_KEY")

tools = [{
    "type": "function",
    "function": {
        "name": "get_order_status",
        "description": "Look up the shipping status of an order by its numeric ID.",
        "parameters": {
            "type": "object",
            "properties": {"order_id": {"type": "integer"}},
            "required": ["order_id"],
        },
    },
}]

messages = [{"role": "user", "content": "Where is order 4821?"}]

resp = client.chat.completions.create(
    model="uncensored", messages=messages, tools=tools, tool_choice="auto"
)
msg = resp.choices[0].message

if msg.tool_calls:
    messages.append(msg)
    for call in msg.tool_calls:
        args = json.loads(call.function.arguments)
        result = {"order_id": args["order_id"], "status": "shipped"}
        messages.append({
            "role": "tool",
            "tool_call_id": call.id,
            "content": json.dumps(result),
        })
    final = client.chat.completions.create(
        model="uncensored", messages=messages, tools=tools
    )
    print(final.choices[0].message.content)
else:
    print(msg.content)

Two details trip people up. First, the assistant message that contains tool_calls must stay in the history before the tool messages, otherwise the tool_call_id values point at nothing. Second, function.arguments arrives as a string, not an object. Always run it through json.loads inside a try block, because a model can produce a malformed string now and then.

The same first request in curl, handy for checking a key before you touch any framework code:

curl https://api.uncensoreddeepseek.cc/v1/chat/completions \
  -H "Authorization: Bearer YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "uncensored",
    "messages": [{"role": "user", "content": "Where is order 4821?"}],
    "tools": [{
      "type": "function",
      "function": {
        "name": "get_order_status",
        "description": "Look up the shipping status of an order by its numeric ID.",
        "parameters": {
          "type": "object",
          "properties": {"order_id": {"type": "integer"}},
          "required": ["order_id"]
        }
      }
    }],
    "tool_choice": "auto"
  }'

Streaming tool calls

With stream: true the function name and the argument string arrive in pieces. Each chunk carries an index that tells you which call it belongs to. The name usually shows up in the first chunk for that index, and the arguments are appended fragment by fragment. You cannot parse the JSON until the stream ends, so buffer the fragments per index and parse once.

from openai import OpenAI

client = OpenAI(base_url="https://api.uncensoreddeepseek.cc/v1", api_key="YOUR_KEY")

calls = {}
stream = client.chat.completions.create(
    model="uncensored",
    messages=[{"role": "user", "content": "Where is order 4821?"}],
    tools=[{
        "type": "function",
        "function": {
            "name": "get_order_status",
            "description": "Look up the shipping status of an order.",
            "parameters": {
                "type": "object",
                "properties": {"order_id": {"type": "integer"}},
                "required": ["order_id"],
            },
        },
    }],
    stream=True,
)

for chunk in stream:
    if not chunk.choices:
        continue
    delta = chunk.choices[0].delta
    for tc in delta.tool_calls or []:
        slot = calls.setdefault(tc.index, {"id": None, "name": "", "args": ""})
        if tc.id:
            slot["id"] = tc.id
        if tc.function and tc.function.name:
            slot["name"] += tc.function.name
        if tc.function and tc.function.arguments:
            slot["args"] += tc.function.arguments

print(calls)

Remember that a streamed request holds its concurrency slot until the stream closes. A full key allows 8 concurrent requests, a trial key 2. If your agent opens a stream and then forgets to read it to the end, you will see HTTP 429 with the error code concurrency long before you reach the per-minute limit.

JSON mode or tool calling

Both features give you structured output, and they solve different problems. Pick tool calling when the model should choose between actions: search, fetch a record, write a file. Pick JSON mode when every reply has the same shape and no action follows, for example extracting fields from a paragraph or classifying a message.

JSON mode is one parameter. Put the word JSON in your prompt as well, so the model knows which keys you expect.

from openai import OpenAI
import json

client = OpenAI(base_url="https://api.uncensoreddeepseek.cc/v1", api_key="YOUR_KEY")

resp = client.chat.completions.create(
    model="uncensored",
    response_format={"type": "json_object"},
    messages=[
        {"role": "system", "content": "Reply with JSON: {\"sentiment\": \"pos|neg|neutral\", \"summary\": \"...\"}"},
        {"role": "user", "content": "The export feature is slow but the new editor is great."},
    ],
)
print(json.loads(resp.choices[0].message.content))

A rule of thumb: if you find yourself defining a single function only to get JSON back, use JSON mode instead. It is one call instead of two, and you skip the tool message round trip.

Using it from agent tools and editors

Most agent frameworks and coding assistants ask for three values: a base URL, an API key and a model name. Enter https://api.uncensoreddeepseek.cc/v1, your key and uncensored. Tools such as Cursor, Cline and Continue, and libraries such as LangChain and the OpenAI SDKs, can be pointed at an OpenAI-compatible endpoint this way. Menus and field names change between versions, and some tools limit custom models to certain modes, so check the current settings screen of the tool you use rather than trusting a screenshot from last year.

If you want an editor walkthrough, the VS Code article on this site covers the Continue and Cline fields step by step. For plain scripts, the quickstart in the docs is enough.

One caution for agent frameworks that fire several tool calls in parallel: each model request is a separate API request. An agent that runs ten branches at once will hit the 8-request concurrency cap of a full key. Set the framework's concurrency to 4 or 6 and leave headroom for retries.

Pitfalls and how to fix them

  • Endless loops. If the model keeps calling tools without reaching an answer, cap the loop at a fixed number of rounds, for example 8, and return whatever you have. A runaway loop is the fastest way to spend credit by accident.
  • Bad arguments. Validate every argument against your own schema. If it fails, send the validation error back as the tool result. The model usually corrects itself on the next turn.
  • Vague function descriptions. The description is the model's only guide for choosing between functions. Write one concrete sentence per function and describe each parameter.
  • Too many tools. Ten sharp tools beat forty overlapping ones. Remove functions the task does not need.
  • 429 responses. The code rate_limited means too many requests per minute (300 on a full key, 60 on a trial key). The code concurrency means too many at once. A 429 with a Retry-After: 5 header means temporary overload; wait five seconds and retry with a small random delay.
  • Large bodies. The body limit is 8 MB. Tool results that dump whole files into the history hit the 100,000-token window long before that. Trim tool output to what the model needs.

Every response carries X-Request-Id and X-Balance-USD headers. Log the request ID with each tool round, since it is the first thing support will ask for if a call looks wrong.

What an agent loop costs

Agent loops resend the whole history on every round, so input tokens dominate. Take a run with 6 model calls, each carrying about 3,000 input tokens and producing about 200 output tokens. That is 18,000 input tokens and 1,200 output tokens in total.

  • Input: 18,000 / 1,000,000 x $0.15 = $0.0027
  • Output: 1,200 / 1,000,000 x $0.50 = $0.0006
  • Total: $0.0033 per run

A thousand such runs cost $3.30. Failed or refused requests are not charged, which keeps retries cheap. The pricing page shows the top-up bonuses, and the DeepSeek API pricing comparison goes deeper on per-token math.

New accounts can claim $0.50 of trial credit with one click on the API key page, valid for 7 days and without a card. At $0.0033 per run, that covers roughly 150 test runs, enough to try every example above. The trial key is limited to 2 concurrent requests and 60 per minute, so keep your tests sequential.

FAQ: Pricing and Billing

How is token usage calculated?

Tokens are counted based on the input prompt and the generated output. The API uses a tokenizer to split text into tokens. You can estimate token counts using standard tokenizers or by checking the response headers. Input tokens are charged at $0.15 per million, and output tokens at $0.50 per million.

Do I get charged for errors?

No. If a request fails due to a server error or a timeout, you are not charged for those tokens. You only pay for successful completions or partial completions that were generated.

Can I use a credit card?

We accept crypto (USDT on TRC20, USDC on Base) payments for top-ups. You can also start with a free trial credit without a card. Once you need more credit, you can top up via crypto.

What happens to my unused credit?

Your prepaid credit never expires. You can top up at any time, and the bonus credits are applied instantly. There are no monthly fees or subscription renewals, so your balance remains available until you use it.

Optimizing Your API Usage

To minimize costs, optimize your prompts. Use concise instructions and avoid redundant information. Since input tokens are cheaper, you can afford longer prompts, but be mindful of the context window. Our API supports 100,000 tokens, which is ample for most use cases.

Use streaming to reduce latency. Streaming allows you to receive tokens as they are generated, improving the user experience. Our API supports Server-Sent Events (SSE) for streaming. You can also use JSON mode to get structured output, which reduces the need for post-processing.

Monitor your usage regularly. The API provides token counts in the response headers. Use these metrics to track your spending and adjust your prompts accordingly. By combining optimization with our crypto bonuses, you can achieve significant savings.

Getting Started with the API

Getting started is simple. Sign up for an account using Google or email. You will receive a $0.50 trial credit valid for 7 days. This allows you to test the API without any financial commitment. Claim this credit with one click on your API key page.

To use the API, install the OpenAI SDK or any compatible client. Set the base URL to https://api.uncensoreddeepseek.cc/v1 and provide your API key. You can then make requests just like you would with OpenAI.

For example, you can send a chat completion request with a simple prompt. The API will return the generated text, along with token usage statistics. You can then integrate this into your application. If you need more credit, top up via crypto to receive bonus credits.

Questions and answers

Does this API support parallel tool calls?

The model can return several entries in tool_calls in one reply, and you answer each with its own tool message. Whether it chooses to depends on your prompt and tool definitions, so test with your own functions.

Can I force the model to call a specific function?

Yes. Pass tool_choice with the function name and the model is directed to call it. Use "auto" when you want it to decide.

Is this the official DeepSeek API?

No. It is an independent OpenAI-compatible service running one open-weight model under the ID uncensored. For the official DeepSeek API, use DeepSeek's own documentation.

Are failed tool-calling requests billed?

Failed or refused requests are not charged. Successful ones are billed per token at $0.15 per 1M input and $0.50 per 1M output.

Your key is one form away

Create an account, copy the key, change the base URL. That is the whole setup.