← All Blogs

DeepSeek API for coding agents: direct integration vs Weave Router

By Sammy TouraniGTM Engineer at Weave
Published Read Time: 9 min

The DeepSeek API lets a coding agent call DeepSeek models directly. Weave Router adds a different capability: it selects a model and provider for each action your agent takes, so you can use DeepSeek alongside frontier models in the same workflow.

Use direct access when you want to choose a DeepSeek model explicitly and pay DeepSeek for its API usage. Use Weave Router when you want model selection across an approved pool, coding-agent setup, and a record of which model served each request. The useful comparison is the cost and quality of completed coding work.

API details and prices checked November 3, 2026.

Weave's published cost and quality evidence

Weave's Router 2.0 evaluation reports Astra quality at about half the cost and more than twice the speed on two agentic coding benchmarks. Router and GPT-6 Astra used the same Codex harness and tasks, with two attempts per task in paired runs.

Scroll horizontally if needed →

BenchmarkTasksRouter / Astra tasks solvedRouter / Astra cost per trialRouter / Astra mean time per trial
Terminal-Bench 4.06662.1% / 60.6%$5.22 / $10.0320.5 / 44.1 minutes
SWE-Atlas Codebase QnA12462.1% / 66.1%$2.31 / $5.046.8 / 16.7 minutes

Tasks solved is pass@2: a task counts when either attempt passes. Cost and time are per trial. The published comparison is Router versus GPT-6 Astra; it does not establish the result of a direct DeepSeek comparison.

That is the reason to evaluate routing on finished work. A token-price table describes the price of a model call. These results measure whether an agent completes a coding task, what its attempts cost, and how long they take. The published methodology makes the comparison inspectable.

Send a direct DeepSeek API request

DeepSeek's official quickstart uses https://api.deepseek.com for OpenAI-format requests. Its current API model IDs are deepseek-flash and deepseek-v4-pro.

With your DeepSeek API key already set in DEEPSEEK_API_KEY, this Bash example requests a small Python change:

curl --fail-with-body --silent --show-error \
  'https://api.deepseek.com/chat/completions' \
  -H "Authorization: Bearer ${DEEPSEEK_API_KEY}" \
  -H 'Content-Type: application/json' \
  --data-binary @- <<'JSON'
{
  "model": "deepseek-flash",
  "messages": [
    {
      "role": "user",
      "content": "Write a Python mean(values) function that returns 0 for an empty list. Include two unit tests."
    }
  ],
  "thinking": { "type": "enabled" },
  "reasoning_effort": "high",
  "stream": false
}
JSON

Read the generated answer in choices[0].message.content. This request returns suggested code. A coding agent also needs to apply edits, execute tools, and run tests in your repository.

For a custom tool loop, follow DeepSeek's Chat Completions contract and thinking-mode guide. Thinking mode is enabled by default. It rejects required and named tool_choice values, and requests that carry tools must retain the required reasoning_content in later messages. A successful text-only request does not exercise that tool loop.

Connect Claude Code or Codex

DeepSeek documents direct integrations for both clients. You can choose the service first, then follow its client-specific setup.

Scroll horizontally if needed →

Coding agentDirect DeepSeek setupWeave Router setup
Claude CodeDeepSeek's Claude Code guide uses its Anthropic-compatible endpoint and a DeepSeek keynpx @weave-os/router --claude configures the client for Weave
CodexDeepSeek's Codex guide uses its native Responses API and a DeepSeek model catalognpx @weave-os/router --codex configures the client for Weave

DeepSeek's Claude Code guide also documents model-name mapping. Claude Opus names select DeepSeek Pro; Claude Haiku and Sonnet names select DeepSeek Flash. Check the served model when comparing costs.

Weave's managed setup guide requires Node.js 18 or later, an organization-issued router key, and the credits, subscriptions, or provider keys appropriate to your plan. The installer handles the coding client's configuration. Self-hosting is a separate deployment path in the Router README.

Keep the credentials distinct. A DeepSeek key authenticates to DeepSeek. A Weave router key authenticates to Weave. For routed DeepSeek models, confirm the enabled model and its upstream provider in your Router configuration. The provider reference documents OpenRouter and other OpenAI-compatible endpoints; the custom-endpoint guide explains provider bindings and model aliases.

What per-action routing changes

A coding session contains many model requests. Reading a file, interpreting a tool result, proposing a patch, and responding to a failed test can each lead to another request with a different amount of work to do.

Weave's routing semantics define an action as one upstream API request to a model. That is the routing grain. One agent turn can contain several actions. Session state and explicit model pins can influence each decision; per-action routing does not mean switching models on every request.

This gives Weave a useful role even when DeepSeek is already part of your stack:

  • Use more than one model without changing coding clients. Keep DeepSeek in the eligible pool alongside the other models your organization enables.
  • Control the choices. Weave's models and routing controls let you exclude models or providers, set preferences, and pin a session when you want a specific model.
  • Inspect the work behind the bill. Router reporting connects requests to serving models, token counts, costs, users, and sessions. Decision exports provide the underlying rows for your own analysis.

The agent executes local tools. Router selects the upstream model. For example, a request that produces a file-read tool call and the next request carrying that file's contents are separate routing actions, even though they belong to the same task.

Direct API access vs routed access

Scroll horizontally if needed →

DecisionDirect DeepSeek APIWeave Router
Model selectionYour client sends a DeepSeek model IDRouter chooses among enabled provider/model bindings; you can also request a pin
API connectionDeepSeek documents Chat Completions, Anthropic-compatible Messages, and ResponsesUse Weave's supported client setup or documented ingress for your deployment
Tools, streaming, and imagesFollow DeepSeek's request and reasoning contracts; its current model table lists vision for Flash, while Pro does not support itTest the same tool loop and image inputs through the selected client, model, and provider
CachingDeepSeek's cache-hit rules and direct rates applyCache behavior and charges follow the selected upstream and routing configuration
Cost accountingDeepSeek API usage and tool chargesYour Weave plan, provider usage, and any connected subscription or BYOK terms
Operational viewCollect usage through your DeepSeek integrationCentral model/provider controls, request costs, session drilldowns, and decision exports

DeepSeek API model IDs and Router catalog IDs are different namespaces. Record the exact served model and provider on both paths before treating two runs as a model-for-model comparison.

DeepSeek API pricing

These are DeepSeek's published direct API rates, checked November 3, 2026. All values are USD per one million tokens, shown as off-peak / peak. The official pricing page is the source of truth.

Scroll horizontally if needed →

API modelCached inputUncached inputOutput
deepseek-flash$0.003 / $0.006$0.15 / $0.30$0.60 / $1.20
deepseek-v4-pro$0.022 / $0.044$0.66 / $1.32$1.98 / $3.96

Peak windows are 01:00-04:00 and 06:00-10:00 UTC, Monday through Friday, excluding Chinese public holidays. The current deepseek-flash alias serves DeepSeek-V4.1-Flash-1017; the Pro version is DeepSeek-V4-Pro-0813. DeepSeek also lists Search and Fetch separately at $0.75 per 1,000 successful requests for each API. Include those charges when your agent uses those services.

Your effective cost depends on input/output mix, cache hits, reasoning, retries, and tool loops. DeepSeek caching is enabled by default, but hits depend on matching persisted prefixes. Use returned usage rather than assuming the whole repository context is cached.

These direct rates are not a Weave invoice estimate. Use the actual upstream and Weave billing terms for your selected path. Keep the estimate date with your budget because provider rates and model aliases change.

Compare the two paths on your repository

Start with direct DeepSeek as an explicit baseline, then compare it with Weave Router using the same coding agent, task mix, acceptance tests, and review standard. Record the exact model versions and reasoning settings. Include failed attempts and retries in both groups.

Scroll horizontally if needed →

MeasureWhat to record
API spendInput/output usage, cache hits, tool charges, retries, and the actual billed cost
Task completionWhether the requested change passes the same acceptance criteria
LatencyTime to first token and time to a completed, accepted change
Code qualityReview findings, post-merge defects, and follow-up work
PR keep rateThe same retention definition and follow-up window for both groups
Cost per merged PRTotal spend on all attempts divided by merged PRs in the tested work

Use Router's serving-model and session records to inspect its choices, then connect those sessions to your work items. Its dashboard's savings comparison uses the configured comparison model; a direct DeepSeek pilot needs a matched direct baseline as well.

Choose the path that matches your workload

Choose direct DeepSeek when you want an explicit DeepSeek integration with one provider's API and billing. Choose Weave Router when your coding workflow benefits from selecting among DeepSeek and other enabled models per action, with coding-client setup and centralized routing controls.

Set up Weave Router and compare the resulting model mix, spend, and completed work with your direct baseline.

Frequently asked questions

Can Claude Code and Codex use DeepSeek directly?

Yes. DeepSeek publishes client-specific guides for Claude Code through its Anthropic-compatible endpoint and Codex through its Responses API. Use the current guide for your client rather than reusing another client's configuration.

Can Weave select a different model within one agent turn?

Yes. Its documented routing grain is one upstream API request, and an agent turn can contain several requests. Session pins and deployment policy still affect which model is selected.

Does Weave Router provide DeepSeek's official API?

They are separate services. DeepSeek operates its direct API. Weave Router selects models and providers for supported agent requests, including enabled DeepSeek routes in your configuration.

Can I compare DeepSeek's token rate with Router's benchmark cost?

They measure different things. The pricing table is USD per million direct API tokens. The benchmark reports cost per trial on a stated task set. Compare both paths using the same tasks and include all attempts before drawing a cost conclusion.

Route your coding work with Weave

Use the right model for each coding task in the harness you already use.

Try Weave Router