Cached at:
08/12/26, 05:20 PM
# Using the Responses API | DeepSeek API Docs
Source: [https://api-docs.deepseek.com/guides/responses_api/](https://api-docs.deepseek.com/guides/responses_api/)
To meet the demand for Codex, our API now supports the Responses API format, with the`base\_url`being`https://api\.deepseek\.com`\.
With a simple configuration, you can use DeepSeek models in Codex\.
## Integrating DeepSeek Models into Codex[](https://api-docs.deepseek.com/guides/responses_api/#integrating-deepseek-models-into-codex)
Please refer to[Integrate with Codex](https://api-docs.deepseek.com/quick_start/agent_integrations/codex)\.
## Calling DeepSeek Models via the Responses API[](https://api-docs.deepseek.com/guides/responses_api/#calling-deepseek-models-via-the-responses-api)
```
# Please install OpenAI SDK first: `pip3 install openai`from openai import OpenAIclient = OpenAI(api_key="<your DeepSeek API Key>", base_url="https://api.deepseek.com")response = client.responses.create( model="deepseek-v4-flash", instructions="You are a helpful assistant.", input="Hi, how are you?",)print(response.output_text)
```
## Streaming[](https://api-docs.deepseek.com/guides/responses_api/#streaming)
Set`stream: true`to receive the response as a sequence of semantic server\-sent events \(SSE\)\. Each event carries an`event`field indicating the event type, and a monotonically increasing`sequence\_number`\. The stream ends with a`response\.completed`/`response\.incomplete`/`response\.failed`event — there is no`data: \[DONE\]`message\.
```
stream = client.responses.create( model="deepseek-v4-flash", instructions="You are a helpful assistant.", input="Hi, how are you?", stream=True,)for event in stream: if event.type == "response.output_text.delta": print(event.delta, end="")
```
The full list of events:
EventDescription`response\.created`The first event; the response has been created with status`in\_progress``response\.in\_progress`The response is being generated`response\.output\_item\.added`/`response\.output\_item\.done`An output item \(`reasoning`/`message`/`function\_call`/`custom\_tool\_call`/`web\_search\_call`\) starts / completes`response\.content\_part\.added`/`response\.content\_part\.done`A content part within an output item starts / completes`response\.reasoning\_text\.delta`/`response\.reasoning\_text\.done`Incremental chain\-of\-thought text / the full chain\-of\-thought text`response\.output\_text\.delta`/`response\.output\_text\.done`Incremental output text / the full output text`response\.function\_call\_arguments\.delta`/`response\.function\_call\_arguments\.done`Incremental function call arguments / the full arguments`response\.custom\_tool\_call\_input\.delta`/`response\.custom\_tool\_call\_input\.done`Incremental custom tool call \(`apply\_patch`\) input / the full input`response\.web\_search\_call\.in\_progress`/`response\.web\_search\_call\.searching`/`response\.web\_search\_call\.completed`Status updates of a server\-side web search tool call`response\.completed`The final event when the response completes normally, carrying the full`response`object including`usage``response\.incomplete`The final event when the response is truncated \(e\.g\. reaching`max\_output\_tokens`\), carrying the full`response`object`response\.failed`The final event when the response fails, carrying the full`response`object with`error`details## Compatibility Details[](https://api-docs.deepseek.com/guides/responses_api/#compatibility-details)
This section lists the compatibility details of the DeepSeek API with the Responses API\. For the full Responses API format definition, please refer to the[official OpenAI API reference](https://developers.openai.com/api/reference/resources/responses/methods/create)\.
### Top\-level Request Parameters[](https://api-docs.deepseek.com/guides/responses_api/#top-level-request-parameters)
ParameterSupport Status`model`Supported\.`deepseek\-v4\-flash`/`deepseek\-v4\-pro`, see[Models & Pricing](https://api-docs.deepseek.com/quick_start/pricing)`input`Supported\. String or input item list; at least one of`input`and`instructions`is required`instructions`Supported\. Inserted as the first system message`stream`Supported`temperature`Supported \(range \[0\.0, 2\.0\]; no effect in thinking mode\)`top\_p`Supported \(no effect in thinking mode\)`max\_output\_tokens`Supported`top\_logprobs`Supported \(range \[0, 20\]\)`tools`Partially supported\.`function`/`web\_search`supported; other types ignored, see the Tools table below`tool\_choice`Supported\.`none`/`auto`/`required`/ a specific tool \(`\{"type": "function", "name": \.\.\.\}`or`\{"type": "web\_search"\}`/`\{"type": "web\_search\_2025\_08\_26"\}`\)`reasoning`Partially supported\.`effort`supported;`summary`accepted but no summary is generated`text`Partially supported\.`format`fully supported;`verbosity`accepted but has no effect`user`Supported\. See[Rate Limit & Isolation](https://api-docs.deepseek.com/quick_start/rate_limit)`parallel\_tool\_calls`Ignored \(parallel tool calling is always enabled\)`max\_tool\_calls`Ignored`previous\_response\_id`Not supported \(stateless API\)`conversation`Not supported \(stateless API\)`store`Not supported\. The response always carries`store: false``background`Not supported`metadata`Not supported`include`Not supported`prompt`Not supported`truncation`Not supported\. Requests exceeding the context window return a`400`error`service\_tier`Not supported`safety\_identifier`Not supported`prompt\_cache\_key`/`prompt\_cache\_retention`Not supported\. Context caching is managed automatically, see[Context Caching](https://api-docs.deepseek.com/guides/kv_cache)`context\_management`Not supported`stream\_options`Not supportedUnsupported parameters are**silently ignored**and do not cause errors, so existing Responses API clients can connect without modification\.
### Input Items[](https://api-docs.deepseek.com/guides/responses_api/#input-items)
TypeSupport Status`message`Supported\. Roles`user`/`assistant`/`system`/`developer`\(`developer`is treated as`system`\); content supports strings and`input\_text`/`output\_text`content parts\. Image and file inputs are not supported \(`input\_image`parts do not cause an error, but are replaced with a placeholder text\)`function\_call`Supported\. Merged into the adjacent assistant message`function\_call\_output`Supported`reasoning`Supported\. Plain\-text`content`is merged into the adjacent assistant message;`summary`and`encrypted\_content`are not supported`web\_search\_call`Supported\. Pass back as\-is; the server automatically restores the search resultsOther typesIgnored### Tools[](https://api-docs.deepseek.com/guides/responses_api/#tools)
TypeSupport Status`function`Supported`web\_search`/`web\_search\_2025\_08\_26`Supported, executed on the server side\.`search\_context\_size`and`user\_location`are ignored`custom`Only`\{"type": "custom", "name": "apply\_patch"\}`is supported \(for Codex compatibility\); other names return a`400`error`file\_search`/`code\_interpreter`/`computer\_use`/`mcp`/ other built\-in toolsIgnored### Response Fields[](https://api-docs.deepseek.com/guides/responses_api/#response-fields)
The response object is compatible with the OpenAI Responses API`response`structure\. Fields that depend on unsupported capabilities always take fixed values \(e\.g\.`store: false`,`previous\_response\_id: null`,`parallel\_tool\_calls: true`\)\.
Token usage is returned in`usage`:
- `input\_tokens`: number of input tokens, where`input\_tokens\_details\.cached\_tokens`is the number of tokens hitting the[context cache](https://api-docs.deepseek.com/guides/kv_cache)
- `output\_tokens`: number of output tokens, where`output\_tokens\_details\.reasoning\_tokens`is the number of chain\-of\-thought tokens