This topic describes how to call DeepSeek series models on the Alibaba Cloud Model Studio platform using an OpenAI compatible interface or the DashScope SDK.
Service endpoints
The service endpoint is different for each region. Configure the Base URL based on your selected region (Replace {WorkspaceId} with the actual Workspace ID). The available models and rate limits also vary by region. For more information, see the Rate limiting document.
- OpenAI compatible
- OpenAI compatible - Responses API
- DashScope
- China (Beijing)
- US (Virginia)
- Singapore
- Germany (Frankfurt)
- Japan (Tokyo)
The
base_url for SDK call configuration is https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1The HTTP request address is POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completionsGetting started
deepseek-v4-pro is the flagship model in the DeepSeek series and excels at programming, math, and general tasks. deepseek-v4-flash-0731 is the latest released version. You can use the enable_thinking parameter to switch between thinking and non-thinking modes. The following example shows how to call the deepseek-v4-pro model in thinking mode.
You must obtain an API key and configure it as an environment variable. If you use an SDK, you must also install the OpenAI or DashScope SDK.
- OpenAI compatible
- DashScope
- Anthropic compatible
The
enable_thinking parameter is not a standard OpenAI parameter. The OpenAI Python SDK passes it through extra_body, while the Node.js SDK passes it as a top-level parameter. The reasoning_effort parameter is a standard OpenAI parameter and can be passed directly as a top-level parameter.- Python
- Node.js
- HTTP
Sample code
Response
Inference strength (reasoning_effort)
The deepseek-v4.1-flash, deepseek-v4-pro, deepseek-v4-flash-0731, and deepseek-v4-pro-0813 models have thinking mode enabled by default. You can adjust the inference strength using the reasoning_effort parameter. The valid values are low (supported only by deepseek-v4.1-flash, deepseek-v4-flash-0731, and deepseek-v4-pro-0813), high, and max. The default value is high.
For deepseek-v4-pro,
low and medium produce the same behavior as high, and xhigh produces the same behavior as max. For deepseek-v4.1-flash, minimal is mapped to low, medium and xhigh are mapped to high, and ultra is mapped to max.- OpenAI compatible
- DashScope
Python
Responses API
deepseek-v4.1-flash, deepseek-v4-flash-0731, deepseek-v4-pro, and deepseek-v4-pro-0813 support calls through the OpenAI-compatible Responses API. Only the China (Beijing) and Singapore regions are supported. For endpoints, see Service endpoints.
When calling the Responses API, you can add the web_search (Web search), web_extractor (Web extractor), and code_interpreter (Code Interpreter) tools to the tools parameter.
Other features
| Model | Multi-turn conversation | Function Calling | Context cache | Structured output | Prefix Completion |
|---|---|---|---|---|---|
| deepseek-v4.1-flash | Supported | Supported | Supported | Supported | Not supported |
| deepseek-v4-pro | Supported | Supported | Supported | Supported | Not supported |
| deepseek-v4-flash-0731 | Supported | Supported | Supported | Supported | Not supported |
| Distilled models | Supported | Not supported | Not supported | Not supported | Not supported |
Default parameter values
Model | temperature | top_p | repetition_penalty | presence_penalty | max_tokens | thinking_budget |
|---|---|---|---|---|---|---|
deepseek-v4.1-flash | 1.0 | 1.0 | - | - | 393,216 | - |
deepseek-v4-pro | 1.0 | 1.0 | - | - | 393,216 in total | |
deepseek-v4-flash-0731 | 1.0 | 1.0 | - | - | 393,216 in total | |
Distilled version | 0.6 | 0.95 | - | 1 | 16,384 | 16,384 |
- A hyphen (-) indicates that the parameter has no default value and cannot be set.
- The distilled models do not support setting these parameter values.
- "393,216 in total" indicates that for deepseek-v4 series models, max_tokens and thinking_budget share the same limit, and their combined maximum is 393,216 tokens (the maximum output length of the model).
- For parameter definitions, see OpenAI compatible - Chat.
Models and billing
- Hybrid thinking models (use the
enable_thinkingparameter to control thinking mode): deepseek-v4.1-flash, deepseek-v4-pro, and deepseek-v4-flash-0731
In thinking mode, the chain-of-thought is billed as output tokens.
FAQ
Can I upload images or documents to ask questions?
DeepSeek models support only text input, not image or document input. For image input, use the Qwen-VL model. For document input, use the Qwen-Long model.
How do I view token usage and the number of calls?
Within minutes after a model call occurs, you can view it in the monitoring charts. Log in to the Model Monitoring page. In the left navigation pane, select O&M Management > Model Monitoring to enter the monitoring overview page. Set the query conditions (for example, select the time range, workspace, etc.), then in the Models area, find the target model and click View Details to view the call statistics for the model. For more information, see the Model monitoring document.
Monitoring data is updated at minute-level and is for reference only. It is not used as a billing basis.