To meet the request for Codex, our API now supports the Responses API format, pinch the base_url being https://api.deepseek.com.
With a elemental configuration, you tin usage DeepSeek models successful Codex.
Integrating DeepSeek Models into Codex
Please mention to Integrate pinch Codex.
Calling DeepSeek Models via the Responses API
from openai import OpenAI
client = 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 adjuvant assistant.",
input="Hi, really are you?",
)
print(response.output_text)
Streaming
Set stream: existent to person the consequence arsenic a series of semantic server-sent events (SSE). Each arena carries an arena section indicating the arena type, and a monotonically expanding sequence_number. The watercourse ends pinch a response.completed / response.incomplete / response.failed arena — location is nary data: [DONE] message.
model="deepseek-v4-flash",
instructions="You are a adjuvant assistant.",
input="Hi, really are you?",
stream=True,
)
for arena in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="")
The afloat database of events:
| response.created | The first event; the consequence has been created pinch position in_progress |
| response.in_progress | The consequence is being generated |
| response.output_item.added / response.output_item.done | An output point (reasoning / connection / function_call / custom_tool_call / web_search_call) starts / completes |
| response.content_part.added / response.content_part.done | A contented portion wrong an output point starts / completes |
| response.reasoning_text.delta / response.reasoning_text.done | Incremental chain-of-thought matter / the afloat chain-of-thought text |
| response.output_text.delta / response.output_text.done | Incremental output matter / the afloat output text |
| response.function_call_arguments.delta / response.function_call_arguments.done | Incremental usability telephone arguments / the afloat arguments |
| response.custom_tool_call_input.delta / response.custom_tool_call_input.done | Incremental civilization instrumentality telephone (apply_patch) input / the afloat input |
| response.web_search_call.in_progress / response.web_search_call.searching / response.web_search_call.completed | Status updates of a server-side web hunt instrumentality call |
| response.completed | The last arena erstwhile the consequence completes normally, carrying the afloat consequence entity including usage |
| response.incomplete | The last arena erstwhile the consequence is truncated (e.g. reaching max_output_tokens), carrying the afloat consequence object |
| response.failed | The last arena erstwhile the consequence fails, carrying the afloat consequence entity pinch correction details |
Compatibility Details
This conception lists the compatibility specifications of the DeepSeek API pinch the Responses API. For the afloat Responses API format definition, please mention to the official OpenAI API reference.
Top-level Request Parameters
| model | Supported. deepseek-v4-flash / deepseek-v4-pro, spot Models & Pricing |
| input | Supported. String aliases input point list; astatine slightest 1 of input and instructions is required |
| instructions | Supported. Inserted arsenic the first strategy message |
| stream | Supported |
| temperature | Supported (range [0.0, 2.0]; nary effect successful reasoning mode) |
| top_p | Supported (no effect successful reasoning mode) |
| max_output_tokens | Supported |
| top_logprobs | Supported (range [0, 20]) |
| tools | Partially supported. usability / web_search supported; different types ignored, spot the Tools array below |
| tool_choice | Supported. nary / car / required / a circumstantial instrumentality ({"type": "function", "name": ...} aliases {"type": "web_search"} / {"type": "web_search_2025_08_26"}) |
| reasoning | Partially supported. effort supported; summary accepted but nary summary is generated |
| text | Partially supported. format afloat supported; verbosity accepted but has nary effect |
| user | Supported. See Rate Limit & Isolation |
| parallel_tool_calls | Ignored (parallel instrumentality calling is ever enabled) |
| max_tool_calls | Ignored |
| previous_response_id | Not supported (stateless API) |
| conversation | Not supported (stateless API) |
| store | Not supported. The consequence ever carries store: false |
| background | Not supported |
| metadata | Not supported |
| include | Not supported |
| prompt | Not supported |
| truncation | Not supported. Requests exceeding the discourse model 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, spot Context Caching |
| context_management | Not supported |
| stream_options | Not supported |
Unsupported parameters are silently ignored and do not origin errors, truthful existing Responses API clients tin link without modification.
Input Items
| message | Supported. Roles personification / adjunct / strategy / developer (developer is treated arsenic system); contented supports strings and input_text / output_text contented parts. Image and record inputs are not supported (input_image parts do not origin an error, but are replaced pinch a placeholder text) |
| function_call | Supported. Merged into the adjacent adjunct message |
| function_call_output | Supported |
| reasoning | Supported. Plain-text contented is merged into the adjacent adjunct message; summary and encrypted_content are not supported |
| web_search_call | Supported. Pass backmost as-is; the server automatically restores the hunt results |
| Other types | Ignored |
Tools
| function | Supported |
| web_search / web_search_2025_08_26 | Supported, executed connected the server side. search_context_size and user_location are ignored |
| custom | Only {"type": "custom", "name": "apply_patch"} is supported (for Codex compatibility); different names return a 400 error |
| file_search / code_interpreter / computer_use / mcp / different built-in tools | Ignored |
Response Fields
The consequence entity is compatible pinch the OpenAI Responses API consequence structure. Fields that dangle connected unsupported capabilities ever return fixed values (e.g. store: false, previous_response_id: null, parallel_tool_calls: true).
Token usage is returned successful usage:
- input_tokens: number of input tokens, wherever input_tokens_details.cached_tokens is the number of tokens hitting the context cache
- output_tokens: number of output tokens, wherever output_tokens_details.reasoning_tokens is the number of chain-of-thought tokens
English (US) ·
Indonesian (ID) ·