Este tópico descreve como chamar os modelos da série DeepSeek na plataforma Alibaba Cloud Model Studio usando uma interface compatível com OpenAI ou o DashScope SDK.
Os modelos deepseek-v3, deepseek-v3.1, deepseek-v3.2, deepseek-v3.2-exp, deepseek-r1, deepseek-r1-0528 e deepseek-r1-distill-qwen-7b/14b/32b serão descontinuados em 10 de outubro de 2026. Recomendamos o uso dos seguintes modelos como alternativa: qwen3.7-plus, qwen3.7-max e qwen3.6-flash.
O endpoint do service varia conforme a região. Configure a Base URL de acordo com a região selecionada (substitua {WorkspaceId} pelo ID real do Workspace). Os modelos disponíveis e os limites de taxa também variam por região. Para mais informações, consulte o documento Rate limiting.
OpenAI compatible
OpenAI compatible - Responses API
DashScope
China (Beijing)
US (Virginia)
Singapore
Germany (Frankfurt)
Japan (Tokyo)
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
A Responses API atualmente suporta apenas deepseek-v4-flash, deepseek-v4-flash-0731, deepseek-v4-pro e deepseek-v4-pro-0813, estando disponível somente nas regiões China (Beijing) e Singapore.
China (Beijing)
Singapore
O base_url para chamadas via SDK: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1Endpoint HTTP: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/responses
O base_url para chamadas via SDK: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1Endpoint HTTP: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/responses
China (Beijing)
US (Virginia)
Singapore
Germany (Frankfurt)
Japan (Tokyo)
O endereço de requisição HTTP é POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1"
OpenAI compatible
OpenAI compatible - Responses API
DashScope
China (Beijing)
US (Virginia)
Singapore
Germany (Frankfurt)
Japan (Tokyo)
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
O base_url para configuração de chamada via SDK é https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions
A Responses API atualmente suporta apenas deepseek-v4-flash, deepseek-v4-flash-0731, deepseek-v4-pro e deepseek-v4-pro-0813, estando disponível somente nas regiões China (Beijing) e Singapore.
Singapore
China (Beijing)
O base_url para chamadas via SDK: https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1Endpoint HTTP: POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/responses
O base_url para chamadas via SDK: https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1Endpoint HTTP: POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1/responses
China (Beijing)
US (Virginia)
Singapore
Germany (Frankfurt)
Japan (Tokyo)
O endereço de requisição HTTP é POST https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.us-east-1.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.eu-central-1.maas.aliyuncs.com/api/v1"
O endereço de requisição HTTP é POST https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1/services/aigc/text-generation/generationO base_url para configuração de chamada via SDK é dashscope.base_http_api_url = "https://{WorkspaceId}.ap-northeast-1.maas.aliyuncs.com/api/v1"
O deepseek-v4-pro é o modelo principal da série DeepSeek, destacando-se em programação, matemática e tarefas gerais. O deepseek-v4-flash-0731 é a versão mais recente lançada. Use o parâmetro enable_thinking para alternar entre os modos de raciocínio ativo e inativo. O exemplo a seguir demonstra como chamar o modelo deepseek-v4-pro no modo de raciocínio ativo.É necessário obtain an API key e configure it as an environment variable. Caso utilize um SDK, também será preciso instale the OpenAI or DashScope SDK.
OpenAI compatible
DashScope
Anthropic compatible
O parâmetro enable_thinking não é um parâmetro padrão da OpenAI. O SDK Python da OpenAI o transmite via extra_body, enquanto o SDK Node.js o passa como um parâmetro de nível superior. Já o parâmetro reasoning_effort é padrão da OpenAI e pode ser passado diretamente como parâmetro de nível superior.
Python
Node.js
HTTP
Código de exemplo
Copy
from openai import OpenAIimport os# Initialize the OpenAI clientclient = OpenAI( # If the environment variable is not configured, replace it with your Alibaba Cloud Model Studio API key: api_key="sk-xxx" api_key=os.getenv("DASHSCOPE_API_KEY"), # Singapore region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",)messages = [{"role": "user", "content": "Who are you?"}]completion = client.chat.completions.create( model="deepseek-v4-pro", messages=messages, # Use extra_body to set enable_thinking and enable thinking mode extra_body={"enable_thinking": True}, stream=True, stream_options={ "include_usage": True },)reasoning_content = "" # Complete thinking processanswer_content = "" # Complete responseis_answering = False # Indicates whether the response phase has startedprint("\n" + "=" * 20 + "Thinking Process" + "=" * 20 + "\n")for chunk in completion: if not chunk.choices: print("\n" + "=" * 20 + "Token Usage" + "=" * 20 + "\n") print(chunk.usage) print("Request ID:", chunk.id) continue delta = chunk.choices[0].delta # Collect only the thinking content if hasattr(delta, "reasoning_content") and delta.reasoning_content is not None: if not is_answering: print(delta.reasoning_content, end="", flush=True) reasoning_content += delta.reasoning_content # After receiving content, start generating the response if hasattr(delta, "content") and delta.content: if not is_answering: print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n") is_answering = True print(delta.content, end="", flush=True) answer_content += delta.content
Resposta
Copy
====================Thinking Process====================Okay, the user asked a very simple self-introduction question: "Who are you?".I need to clarify my identity, introduce myself as DeepSeek in a concise and friendly way, mention my creator, basic features, and the help I can provide.I can organize the answer like this: first, state my identity directly, mention I was created by the DeepSeek company, then list some key features (free, long context, file upload, etc.), and finally end with a friendly invitation, asking if I can help.====================Complete Response====================Hello! I am DeepSeek, an AI assistant created by the DeepSeek company.I can help you answer various questions, create text, analyze documents, assist with programming, and more. My main features are that I am **free to use**, have a **super long context** (I can process the entire 'The Three-Body Problem' trilogy at once), and support **file uploads** and **web search** (must be enabled manually).Is there anything I can help you with? Whether it's for study, work, or just a casual chat, I'm happy to talk with you!====================Token Usage====================CompletionUsage(completion_tokens=238, prompt_tokens=5, total_tokens=243, completion_tokens_details=CompletionTokensDetails(accepted_prediction_tokens=None, audio_tokens=None, reasoning_tokens=93, rejected_prediction_tokens=None), prompt_tokens_details=None)Request ID: chatcmpl-a1b2c3d4-e5f6-7890-abcd-ef1234567890
Código de exemplo
Copy
import OpenAI from "openai";import process from 'process';// Initialize the OpenAI clientconst openai = new OpenAI({ // If the environment variable is not configured, replace it with your Alibaba Cloud Model Studio API key: apiKey: "sk-xxx" apiKey: process.env.DASHSCOPE_API_KEY, // Singapore region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region. baseURL: 'https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1'});let reasoningContent = ''; // Complete thinking processlet answerContent = ''; // Complete responselet isAnswering = false; // Indicates whether the response phase has startedasync function main() { try { const messages = [{ role: 'user', content: 'Who are you?' }]; const stream = await openai.chat.completions.create({ model: 'deepseek-v4-pro', messages, // Note: In the Node.js SDK, non-standard parameters like enable_thinking are passed as top-level properties, not within extra_body. enable_thinking: true, stream: true, stream_options: { include_usage: true }, }); console.log('\n' + '='.repeat(20) + 'Thinking Process' + '='.repeat(20) + '\n'); for await (const chunk of stream) { if (!chunk.choices?.length) { console.log('\n' + '='.repeat(20) + 'Token Usage' + '='.repeat(20) + '\n'); console.log(chunk.usage); console.log('Request ID:', chunk.id); continue; } const delta = chunk.choices[0].delta; // Collect only the thinking content if (delta.reasoning_content !== undefined && delta.reasoning_content !== null) { if (!isAnswering) { process.stdout.write(delta.reasoning_content); } reasoningContent += delta.reasoning_content; } // After receiving content, start generating the response if (delta.content !== undefined && delta.content) { if (!isAnswering) { console.log('\n' + '='.repeat(20) + 'Complete Response' + '='.repeat(20) + '\n'); isAnswering = true; } process.stdout.write(delta.content); answerContent += delta.content; } } } catch (error) { console.error('Error:', error); }}main();
Resposta
Copy
====================Thinking Process====================Okay, the user asked a very simple self-introduction question: "Who are you?".I need to clarify my identity, introduce myself as DeepSeek in a concise and friendly way, mention my creator, basic features, and the help I can provide.I can organize the answer like this: first, state my identity directly, mention I was created by the DeepSeek company, then list some key features (free, long context, file upload, etc.), and finally end with a friendly invitation, asking if I can help.====================Complete Response====================Hello! I am DeepSeek, an AI assistant created by the DeepSeek company.I can help you answer various questions, create text, analyze documents, assist with programming, and more. My main features are that I am **free to use**, have a **super long context** (I can process the entire 'The Three-Body Problem' trilogy at once), and support **file uploads** and **web search** (must be enabled manually).Is there anything I can help you with? Whether it's for study, work, or just a casual chat, I'm happy to talk with you!====================Token Usage===================={ prompt_tokens: 5, completion_tokens: 243, total_tokens: 248, completion_tokens_details: { reasoning_tokens: 83 }}Request ID: chatcmpl-a1b2c3d4-e5f6-7890-abcd-ef1234567890
Código de exemplo
curl
Copy
# Singapore region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1/chat/completions \-H "Authorization: Bearer $DASHSCOPE_API_KEY" \-H "Content-Type: application/json" \-d '{ "model": "deepseek-v4-pro", "messages": [ { "role": "user", "content": "Who are you?" } ], "stream": true, "stream_options": { "include_usage": true }, "enable_thinking": true}'
Python
Java
HTTP
Código de exemplo
Copy
import osimport dashscopefrom dashscope import Generation# Singapore region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.dashscope.base_http_api_url = "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"# Initialize the request parametersmessages = [{"role": "user", "content": "Who are you?"}]completion = Generation.call( # If the environment variable is not configured, replace it with your Alibaba Cloud Model Studio API key: api_key="sk-xxx" api_key=os.getenv("DASHSCOPE_API_KEY"), model="deepseek-v4-pro", messages=messages, result_format="message", # Set the result format to message enable_thinking=True, stream=True, # Enable streaming output incremental_output=True, # Enable incremental output)reasoning_content = "" # Complete thinking processanswer_content = "" # Complete responseis_answering = False # Indicates whether the response phase has startedprint("\n" + "=" * 20 + "Thinking Process" + "=" * 20 + "\n")for chunk in completion: message = chunk.output.choices[0].message # Collect only the thinking content if "reasoning_content" in message: if not is_answering: print(message.reasoning_content, end="", flush=True) reasoning_content += message.reasoning_content # After receiving content, start generating the response if message.content: if not is_answering: print("\n" + "=" * 20 + "Complete Response" + "=" * 20 + "\n") is_answering = True print(message.content, end="", flush=True) answer_content += message.contentprint("\n" + "=" * 20 + "Token Usage" + "=" * 20 + "\n")print(chunk.usage)print("Request ID:", chunk.request_id)
Resposta
Copy
====================Thinking Process====================Okay, the user asked a very simple self-introduction question: "Who are you?".I need to clarify my identity, introduce myself as DeepSeek in a concise and friendly way, mention my creator, basic features, and the help I can provide.I can organize the answer like this: first, state my identity directly, mention I was created by the DeepSeek company, then list some key features (free, long context, file upload, etc.), and finally end with a friendly invitation, asking if I can help.====================Complete Response====================Hello! I am DeepSeek, an AI assistant created by the DeepSeek company.I can help you answer various questions, create text, analyze documents, assist with programming, and more. My main features are that I am **free to use**, have a **super long context** (I can process the entire 'The Three-Body Problem' trilogy at once), and support **file uploads** and **web search** (must be enabled manually).Is there anything I can help you with? Whether it's for study, work, or just a casual chat, I'm happy to talk with you!====================Token Usage===================={"input_tokens": 6, "output_tokens": 240, "total_tokens": 246, "output_tokens_details": {"reasoning_tokens": 92}}Request ID: 85735883-9062-9c33-a963-0bc12584ee68
Código de exemplo
A versão do DashScope Java SDK deve ser 2.19.4 ou superior.
Copy
// DashScope SDK version >= 2.19.4import com.alibaba.dashscope.aigc.generation.Generation;import com.alibaba.dashscope.aigc.generation.GenerationParam;import com.alibaba.dashscope.aigc.generation.GenerationResult;import com.alibaba.dashscope.common.Message;import com.alibaba.dashscope.common.Role;import com.alibaba.dashscope.exception.ApiException;import com.alibaba.dashscope.exception.InputRequiredException;import com.alibaba.dashscope.exception.NoApiKeyException;import io.reactivex.Flowable;import java.lang.System;import java.util.Arrays;public class Main { private static StringBuilder reasoningContent = new StringBuilder(); private static StringBuilder finalContent = new StringBuilder(); private static boolean isFirstPrint = true; private static String requestId = ""; private static void handleGenerationResult(GenerationResult message) { requestId = message.getRequestId(); String reasoning = message.getOutput().getChoices().get(0).getMessage().getReasoningContent(); String content = message.getOutput().getChoices().get(0).getMessage().getContent(); if (reasoning != null && !reasoning.isEmpty()) { reasoningContent.append(reasoning); if (isFirstPrint) { System.out.println("====================Thinking Process===================="); isFirstPrint = false; } System.out.print(reasoning); } if (content != null && !content.isEmpty()) { finalContent.append(content); if (!isFirstPrint) { System.out.println("\n====================Complete Response===================="); isFirstPrint = true; } System.out.print(content); } } private static GenerationParam buildGenerationParam(Message userMsg) { return GenerationParam.builder() // If the environment variable is not configured, replace the following line with your Alibaba Cloud Model Studio API key: .apiKey("sk-xxx") .apiKey(System.getenv("DASHSCOPE_API_KEY")) .model("deepseek-v4-pro") .enableThinking(true) .incrementalOutput(true) .resultFormat("message") .messages(Arrays.asList(userMsg)) .build(); } public static void streamCallWithMessage(Generation gen, Message userMsg) throws NoApiKeyException, ApiException, InputRequiredException { GenerationParam param = buildGenerationParam(userMsg); Flowable<GenerationResult> result = gen.streamCall(param); result.blockingForEach(message -> handleGenerationResult(message)); } public static void main(String[] args) { try { // Singapore region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region. Generation gen = new Generation("http", "https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/api/v1"); Message userMsg = Message.builder().role(Role.USER.getValue()).content("Who are you?").build(); streamCallWithMessage(gen, userMsg); System.out.println("\nRequest ID: " + requestId); } catch (ApiException | NoApiKeyException | InputRequiredException e) { System.err.println("An exception occurred: " + e.getMessage()); } }}
Resposta
Copy
====================Thinking Process====================Okay, the user asked a very simple self-introduction question: "Who are you?".I need to clarify my identity, introduce myself as DeepSeek in a concise and friendly way, mention my creator, basic features, and the help I can provide.I can organize the answer like this: first, state my identity directly, mention I was created by the DeepSeek company, then list some key features (free, long context, file upload, etc.), and finally end with a friendly invitation, asking if I can help.====================Complete Response====================Hello! I am DeepSeek, an AI assistant created by the DeepSeek company.I can help you answer various questions, create text, analyze documents, assist with programming, and more. My main features are that I am **free to use**, have a **super long context** (I can process the entire 'The Three-Body Problem' trilogy at once), and support **file uploads** and **web search** (must be enabled manually).Is there anything I can help you with? Whether it's for study, work, or just a casual chat, I'm happy to talk with you!
Autenticação: Passe sua chave de API do Model Studio no cabeçalho x-api-key ou no cabeçalho Authorization: Bearer. Para detalhes sobre parâmetros como o modo de raciocínio, consulte Anthropic-compatible Messages.
Python
HTTP
Código de exemplo
Copy
import anthropicimport osclient = anthropic.Anthropic( # If the environment variable is not configured, replace the value with your Model Studio API key: api_key="sk-xxx" api_key=os.getenv("DASHSCOPE_API_KEY"), # When you make a call, replace {WorkspaceId} with your actual Workspace ID. base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic",)message = client.messages.create( model="deepseek-v4-pro", max_tokens=1024, messages=[ {"role": "user", "content": "Who are you?"} ], stream=True,)for event in message: if event.type == "content_block_delta": if hasattr(event.delta, "thinking"): print(event.delta.thinking, end="", flush=True) if hasattr(event.delta, "text"): print(event.delta.text, end="", flush=True)
Código de exemplo
curl
Copy
# Singapore region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region.curl -X POST https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/apps/anthropic/v1/messages \-H "Authorization: Bearer $DASHSCOPE_API_KEY" \-H "Content-Type: application/json" \-H "anthropic-version: 2023-06-01" \-d '{ "model": "deepseek-v4-pro", "max_tokens": 1024, "messages": [ { "role": "user", "content": "Who are you?" } ]}'
Os modelos deepseek-v4-pro, deepseek-v4-flash e deepseek-v4-flash-0731 possuem o modo de raciocínio ativado por padrão. Ajuste a intensidade da inferência através do parâmetro reasoning_effort. Os valores válidos são low, medium, high, xhigh e max. O valor padrão é high.
Os valores low e medium produzem o mesmo comportamento que high. Já o valor xhigh gera o mesmo comportamento que max.
OpenAI compatible
DashScope
Python
Copy
from openai import OpenAIimport osclient = OpenAI( api_key=os.getenv("DASHSCOPE_API_KEY"), # China (Beijing) region. Replace {WorkspaceId} with your Bailian workspace ID. URLs vary by region. base_url="https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1",)completion = client.chat.completions.create( model="deepseek-v4-pro", messages=[{"role": "user", "content": "Which is greater, 9.9 or 9.11?"}], reasoning_effort="high",)print(completion.choices[0].message.content)
Copy
import osimport dashscopefrom dashscope import Generation# The following is the configuration for the China (Beijing) region. Replace {WorkspaceId} with your actual workspace ID when making a call. Configurations vary by region.dashscope.base_http_api_url = "https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/api/v1"response = Generation.call( api_key=os.getenv("DASHSCOPE_API_KEY"), model="deepseek-v4-pro", messages=[{"role": "user", "content": "Which is greater, 9.9 or 9.11?"}], reasoning_effort="high", result_format="message",)print(response.output.choices[0].message.content)
Os modelos deepseek-v4-flash, deepseek-v4-flash-0731, deepseek-v4-pro e deepseek-v4-pro-0813 aceitam chamadas pela Responses API compatível com OpenAI. Apenas as regiões China (Beijing) e Singapore são suportadas. Para endpoints, consulte Service endpoints.Ao invocar a Responses API, adicione as ferramentas web_search (Web search), web_extractor (Web extractor) e code_interpreter (Code Interpreter) ao parâmetro tools.
Python
Copy
from openai import OpenAIimport osclient = OpenAI( # If the environment variable is not configured, replace the following line with your Model Studio API key: api_key="sk-xxx" api_key=os.getenv("DASHSCOPE_API_KEY"), # The following URL is for the Singapore region. For the other region, use https://{WorkspaceId}.cn-beijing.maas.aliyuncs.com/compatible-mode/v1 base_url="https://{WorkspaceId}.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1",)response = client.responses.create( model="deepseek-v4-flash", input="Hello! Please introduce yourself in one sentence.", # Optional: enable the web search, web extractor, and code interpreter tools tools=[ {"type": "web_search"}, {"type": "web_extractor"}, {"type": "code_interpreter"}, ],)# Get the model responseprint(response.output_text)
Um hífen (-) indica que o parâmetro não possui valor padrão e não pode ser definido.
Os modelos deepseek-r1, deepseek-r1-0528 e as versões destiladas não permitem a configuração desses valores de parâmetro.
"393.216 in total" significa que, para os modelos da série deepseek-v4, max_tokens e thinking_budget compartilham o mesmo limite, somando no máximo 393.216 tokens (comprimento máximo de saída do modelo).
Modelos de raciocínio híbrido (use o parâmetro enable_thinking para controlar o modo de raciocínio): deepseek-v4-pro, deepseek-v4-flash, deepseek-v4-flash-0731, deepseek-v3.2, deepseek-v3.2-exp e deepseek-v3.1
Modelos exclusivos de raciocínio (sempre raciocinam antes de responder): deepseek-r1 e deepseek-r1-0528
Modelos sem raciocínio: deepseek-v3
O deepseek-v4-pro destaca-se em programação, matemática e tarefas gerais. O deepseek-v4-flash-0731 oferece rapidez e custo-benefício. Priorize o uso do deepseek-v4-pro.Para informações sobre comprimento de contexto e preços dos modelos, acesse o console do Model Studio.O faturamento baseia-se na quantidade de tokens de entrada e saída.
No modo de raciocínio, a cadeia de pensamento é cobrada como tokens de saída.
Posso enviar imagens ou documentos para fazer perguntas?
Os modelos DeepSeek aceitam apenas entrada de texto, não suportando imagens ou documentos. Para entrada de imagens, utilize o modelo Qwen-VL. Para documentos, use o modelo Qwen-Long.
Como visualizar o uso de tokens e a quantidade de chamadas?
Uma hora após a conclusão de uma chamada de modelo, acesse a página de Monitoramento de Modelos e defina os critérios de consulta, como intervalo de tempo e workspace. Em seguida, na área Models, localize o modelo desejado e clique em Monitor na coluna Actions para visualizar as estatísticas de chamadas do modelo. Para mais detalhes, consulte o documento Model monitoring.
Os dados são atualizados a cada hora. Em horários de pico, a atualização pode atrasar em até uma hora.