Using the Responses API | DeepSeek API Docs
Skip to main content
On this page<br>Using the 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
Please refer to Integrate with Codex.
Calling DeepSeek Models via the Responses API
# Please install OpenAI SDK first: `pip3 install openai`<br>from openai import OpenAI
client = OpenAI(api_key="", base_url="https://api.deepseek.com")
response = client.responses.create(<br>model="deepseek-v4-flash",<br>instructions="You are a helpful assistant.",<br>input="Hi, how are you?",
print(response.output_text)
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(<br>model="deepseek-v4-flash",<br>instructions="You are a helpful assistant.",<br>input="Hi, how are you?",<br>stream=True,
for event in stream:<br>if event.type == "response.output_text.delta":<br>print(event.delta, end="")
The full list of events:
EventDescriptionresponse.createdThe first event; the response has been created with status in_progressresponse.in_progressThe response is being generatedresponse.output_item.added / response.output_item.doneAn output item (reasoning / message / function_call / custom_tool_call / web_search_call) starts / completesresponse.content_part.added / response.content_part.doneA content part within an output item starts / completesresponse.reasoning_text.delta / response.reasoning_text.doneIncremental chain-of-thought text / the full chain-of-thought textresponse.output_text.delta / response.output_text.doneIncremental output text / the full output textresponse.function_call_arguments.delta / response.function_call_arguments.doneIncremental function call arguments / the full argumentsresponse.custom_tool_call_input.delta / response.custom_tool_call_input.doneIncremental custom tool call (apply_patch) input / the full inputresponse.web_search_call.in_progress / response.web_search_call.searching / response.web_search_call.completedStatus updates of a server-side web search tool callresponse.completedThe final event when the response completes normally, carrying the full response object including usageresponse.incompleteThe final event when the response is truncated (e.g. reaching max_output_tokens), carrying the full response objectresponse.failedThe final event when the response fails, carrying the full response object with error details<br>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.
Top-level Request Parameters
ParameterSupport StatusmodelSupported. deepseek-v4-flash / deepseek-v4-pro, see Models & PricinginputSupported. String or input item list; at least one of input and instructions is requiredinstructionsSupported. Inserted as the first system messagestreamSupportedtemperatureSupported (range [0.0, 2.0]; no effect in thinking mode)top_pSupported (no effect in thinking mode)max_output_tokensSupportedtop_logprobsSupported (range [0, 20])toolsPartially supported. function / web_search supported; other types ignored, see the Tools table belowtool_choiceSupported. none / auto / required / a specific tool ({"type": "function", "name": ...} or {"type": "web_search"} / {"type": "web_search_2025_08_26"})reasoningPartially supported. effort supported; summary accepted but no summary is generatedtextPartially supported. format fully supported; verbosity accepted but has no effectuserSupported. See Rate Limit & Isolationparallel_tool_callsIgnored (parallel tool calling is always enabled)max_tool_callsIgnoredprevious_response_idNot supported (stateless API)conversationNot supported (stateless API)storeNot supported. The response always carries store: falsebackgroundNot supportedmetadataNot supportedincludeNot supportedpromptNot supportedtruncationNot supported. Requests exceeding the context window return a 400 errorservice_tierNot supportedsafety_identifierNot supportedprompt_cache_key / prompt_cache_retentionNot supported. Context caching is managed automatically, see Context Cachingcontext_managementNot supportedstream_optionsNot supported<br>Unsupported parameters are silently ignored and do not cause errors, so existing Responses API clients can connect without modification.
Input Items
TypeSupport StatusmessageSupported. 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...