DeepSeek

更新时间:
复制 MD 格式

This document describes how to call the DeepSeek series model inference service from Kuaishou Wanqing on the Alibaba Cloud Model Studio platform.

Important

This document applies only to the China (Beijing) region. To use the models, you must obtain an API key from the China (Beijing) region.

Activate the service

  1. Go to the Model Studio console, search for vanchin/deepseek, find the DeepSeek model card, and click Activate Now.

  2. In the pop-up window, confirm the activation and authorization.

After you complete these steps, you can call the DeepSeek model service provided by Vanchin.

Getting started

Before you begin, obtain an API key and configure the API key as an environment variable. If you use the software development kit (SDK), you must install the SDK.

The following example uses vanchin/deepseek-v4-pro to demonstrate how to enable thinking mode for streaming output in an OpenAI-compatible way.

Python

Sample code

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="vanchin/deepseek-v4-pro",
    messages=[{"role": "user", "content": "Who are you?"}],
    stream=True,
    extra_body={"enable_thinking": True},
)

reasoning_content = ""  # Complete thinking process
answer_content = ""     # Complete response
is_answering = False    # Indicates whether the model has started to respond

print("\n" + "=" * 20 + "Thinking Process" + "=" * 20 + "\n")

for chunk in completion:
    if chunk.choices:
        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
        # When content is received, 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

Response

====================Thinking Process====================

Okay, the user is asking for a simple self-introduction. This is a common opening, so no complex breakdown is needed.

I should state my identity and purpose directly, maintaining a friendly and warm tone. Mentioning my company background will add credibility. I'll also list my core abilities to quickly show my value.

I'll finish with an open invitation to encourage more interaction. I should avoid extra details to keep the response concise.

====================Complete Response====================

Hello! I am DeepSeek, an AI assistant created by DeepSeek. I am a plain text model skilled at answering various questions, assisting with analysis, writing, programming, and more. Is there anything I can help you with?

Node.js

Sample code

import OpenAI from "openai";
import process from 'process';

// Initialize the OpenAI client
const openai = new OpenAI({
    // If the environment variable is not configured, replace "sk-xxx" with your Model Studio API key.
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1'
});

let reasoningContent = ''; // Complete thinking process
let answerContent = ''; // Complete response
let isAnswering = false; // Indicates whether the model has started to respond

async function main() {
    const messages = [{ role: 'user', content: 'Who are you?' }];

    const stream = await openai.chat.completions.create({
        model: 'vanchin/deepseek-v4-pro',
        messages,
        stream: true,
        enable_thinking: true,
    });

    console.log('\n' + '='.repeat(20) + 'Thinking Process' + '='.repeat(20) + '\n');

    for await (const chunk of stream) {
        if (chunk.choices?.length) {
            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;
            }

            // When content is received, 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;
            }
        }
    }
}

main();

Response

====================Thinking Process====================

Okay, the user is asking for a simple self-introduction. This is a common opening, so no complex breakdown is needed.

I should state my identity and purpose directly, maintaining a friendly and warm tone. Mentioning my company background will add credibility. I'll also list my core abilities to quickly show my value.

I'll finish with an open invitation to encourage more interaction. I should avoid extra details to keep the response concise.

====================Complete Response====================

Hello! I am DeepSeek, an AI assistant created by DeepSeek. I am a plain text model skilled at answering various questions, assisting with analysis, writing, programming, and more. Is there anything I can help you with?

HTTP

Sample code

curl

curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "vanchin/deepseek-v4-pro",
    "enable_thinking": true,
    "messages": [
        {
            "role": "user",
            "content": "Who are you?"
        }
    ]
}'

Response

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": "Hello! I am DeepSeek, an AI assistant created by DeepSeek. I am a plain text model skilled at answering various questions, assisting with analysis, writing, programming, and more. Is there anything I can help you with?",
                "reasoning_content": "Okay, the user is asking for a simple self-introduction. This is a common opening, so no complex breakdown is needed.\n\nI should state my identity and purpose directly, maintaining a friendly and warm tone. Mentioning my company background will add credibility. I'll also list my core abilities to quickly show my value.\n\nI'll finish with an open invitation to encourage more interaction. I should avoid extra details to keep the response concise.",
                "role": "assistant"
            }
        }
    ],
    "created": 1775139549,
    "id": "as-j8iwhei6hm",
    "model": "vanchin/deepseek-v4-pro",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 213,
        "completion_tokens_details": {
            "reasoning_tokens": 75
        },
        "prompt_tokens": 11,
        "total_tokens": 224
    }
}

Reasoning effort (reasoning_effort)

deepseek-v4-pro and deepseek-v4-flash have thinking mode enabled by default. You can use the reasoning_effort parameter to adjust inference intensity. Possible values are high and max, with the default being high.

Note

When set to low or medium, it is mapped to high. When set to xhigh, it is mapped to max.

Python

from openai import OpenAI
import os

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="vanchin/deepseek-v4-pro",
    messages=[{"role": "user", "content": "9.9和9.11哪个大"}],
    reasoning_effort="high",
)
print(completion.choices[0].message.content)

Node.js

import OpenAI from "openai";

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: "https://dashscope.aliyuncs.com/compatible-mode/v1",
});

const completion = await openai.chat.completions.create({
    model: "vanchin/deepseek-v4-pro",
    messages: [{ role: "user", content: "9.9和9.11哪个大" }],
    reasoning_effort: "high",
});
console.log(completion.choices[0].message.content);

curl

curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "vanchin/deepseek-v4-pro",
    "messages": [{"role": "user", "content": "9.9和9.11哪个大"}],
    "reasoning_effort": "high"
}'

Text extraction

Sample code

This section describes how to extract text from an image URL by calling the vanchin/deepseek-ocr model in an OpenAI-compatible way.

Python

Sample code

import os
from openai import OpenAI

client = OpenAI(
    api_key=os.getenv("DASHSCOPE_API_KEY"),
    base_url="https://dashscope.aliyuncs.com/compatible-mode/v1",
)

completion = client.chat.completions.create(
    model="vanchin/deepseek-ocr",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg",
                        "detail": "high",
                    },
                },
                {
                    "type": "text",
                    "text": "Read all the text in the image.",
                },
            ],
        }
    ],
)

print(completion.choices[0].message.content)

Response

 If you are a system administrator in a Linux environment, learning to write shell scripts will be very beneficial. This book does not detail every step of installing a Linux system. But as long as Linux is installed and running, you can start to think about how to automate some daily system administration tasks. This is where shell script programming comes into play, and that is the purpose of this book. This book will demonstrate how to use shell scripts to automate system administration tasks, from monitoring system statistics and data files to generating reports for you.

If you are a Linux enthusiast, you can also benefit from this book. Today, users can easily get lost in graphical environments built from many stacked components. Most desktop Linux distributions try to hide the internal details of the system from the average user. But sometimes you really need to know what is happening inside. This book will show you how to start the Linux command line and what to do next. Usually, for simple tasks (such as scf file management), operating on the command line is much more convenient than in a fancy graphical interface. Many commands are available on the command line, and this book will show how to use them.

Node.js

Sample code

import OpenAI from "openai";
import process from 'process';

const openai = new OpenAI({
    apiKey: process.env.DASHSCOPE_API_KEY,
    baseURL: 'https://dashscope.aliyuncs.com/compatible-mode/v1'
});

async function main() {
    const completion = await openai.chat.completions.create({
        model: 'vanchin/deepseek-ocr',
        messages: [
            {
                role: 'user',
                content: [
                    {
                        type: 'image_url',
                        image_url: {
                            url: 'https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg',
                            detail: 'high',
                        },
                    },
                    {
                        type: 'text',
                        text: 'Read all the text in the image.',
                    },
                ],
            },
        ],
    });

    console.log(completion.choices[0].message.content);
}

main();

Response

 If you are a system administrator in a Linux environment, learning to write shell scripts will be very beneficial. This book does not detail every step of installing a Linux system. But as long as Linux is installed and running, you can start to think about how to automate some daily system administration tasks. This is where shell script programming comes into play, and that is the purpose of this book. This book will demonstrate how to use shell scripts to automate system administration tasks, from monitoring system statistics and data files to generating reports for you.

If you are a Linux enthusiast, you can also benefit from this book. Today, users can easily get lost in graphical environments built from many stacked components. Most desktop Linux distributions try to hide the internal details of the system from the average user. But sometimes you really need to know what is happening inside. This book will show you how to start the Linux command line and what to do next. Usually, for simple tasks (such as scf file management), operating on the command line is much more convenient than in a fancy graphical interface. Many commands are available on the command line, and this book will show how to use them.

HTTP

Sample code

curl

curl -X POST https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
    "model": "vanchin/deepseek-ocr",
    "messages": [
        {
            "role": "user",
            "content": [
                {
                    "type": "image_url",
                    "image_url": {
                        "url": "https://help-static-aliyun-doc.aliyuncs.com/file-manage-files/zh-CN/20241108/ctdzex/biaozhun.jpg",
                        "detail": "high"
                    }
                },
                {
                    "type": "text",
                    "text": "Read all the text in the image."
                }
            ]
        }
    ]
}'

Response

{
    "choices": [
        {
            "finish_reason": "stop",
            "index": 0,
            "message": {
                "content": " If you are a system administrator in a Linux environment, learning to write shell scripts will be very beneficial. This book does not detail every step of installing a Linux system. But as long as Linux is installed and running, you can start to think about how to automate some daily system administration tasks. This is where shell script programming comes into play, and that is the purpose of this book. This book will demonstrate how to use shell scripts to automate system administration tasks, from monitoring system statistics and data files to generating reports for you.\\n\\nIf you are a Linux enthusiast, you can also benefit from this book. Today, users can easily get lost in graphical environments built from many stacked components. Most desktop Linux distributions try to hide the internal details of the system from the average user. But sometimes you really need to know what is happening inside. This book will show you how to start the Linux command line and what to do next. Usually, for simple tasks (such as scf file management), operating on the command line is much more convenient than in a fancy graphical interface. Many commands are available on the command line, and this book will show how to use them.",
                "role": "assistant"
            }
        }
    ],
    "created": 1775181785,
    "id": "defa065808104e4a880272f86543f961",
    "model": "vanchin/deepseek-ocr",
    "object": "chat.completion",
    "usage": {
        "completion_tokens": 198,
        "prompt_tokens": 498,
        "reasoning_tokens": 0,
        "total_tokens": 696
    }
}

File input methods

  • Public URL: The URL of a publicly accessible image. The URL must use the HTTP or HTTPS protocol.

  • Base64 encoding: The image file as a Base64-encoded string. For more information, see Upload using Base64 encoding.

Image limits

There are no hard limits on image size, resolution, format, or quantity. However, actual processing performance depends on engine resources. To ensure the best response speed, manage the data volume for each request.

Other features

Model

Multi-turn conversation

Deep thinking

Function Calling

Structured output

Web search

Partial mode

Context cache

vanchin/deepseek-v4-pro

Supported

Supported

Supported

Supported

Not supported

Supported

Supported

vanchin/deepseek-v3.2-think

Supported

Supported

Supported

Supported

Not supported

Supported

Supported

vanchin/deepseek-v3.1-terminus

Supported

Supported

Supported

Not supported

Not supported

Not supported

Supported

vanchin/deepseek-r1

Supported

Supported

Supported

Not supported

Not supported

Supported

Supported

vanchin/deepseek-v3

Supported

Not supported

Supported

Supported

Not supported

Supported

Supported

vanchin/deepseek-ocr

Not supported

Not supported

Not supported

Supported

Not supported

Not supported

Not supported

The following parameters are not supported by vanchin/deepseek-v4-pro: repetition_penalty, preserve_thinking, thinking_budget, tool_stream, enable_code_interpreter, seed, logprobs, top_logprobs, enable_search, search_options, skill.

For supported parameters, some have different value ranges or behavior compared to Model Studio:

Parameter

Model Studio

DeepSeek-V4-Pro

n

Value range: 1-4

Only supports value 1 in thinking mode

  • Context cache is supported and enabled by default for all models except vanchin/deepseek-ocr. For a cache hit, the input is billed at the following discounted rates:

    • vanchin/deepseek-v4-pro: Billed at 8.33% of the input price.

    • vanchin/deepseek-v3.2-think: Billed at 10% of the input price.

    • vanchin/deepseek-v3.1-terminus, vanchin/deepseek-r1, and vanchin/deepseek-v3: Billed at 40% of the input price.

Default parameter values

Model

temperature

top_p

enable_thinking

detail

vanchin/deepseek-v4-pro

0.6

0.95

true

-

vanchin/deepseek-v3.2-think

0.6

0.95

false

-

vanchin/deepseek-v3.1-terminus

0.7

0.95

false

-

vanchin/deepseek-r1

1.0

0.8

- (Thinking mode only)

-

vanchin/deepseek-v3

1.0

1.0

- (Thinking mode not supported)

-

vanchin/deepseek-ocr

1.0

1.0

- (Thinking mode not supported)

auto (Possible values: auto, high, low)

Model list and billing

The vanchin/deepseek-v4-pro model is recommended because it balances high computational efficiency with excellent inference capabilities. For Optical Character Recognition (OCR) tasks, use the deepseek-ocr model provided by Vanchin.

For model context lengths and pricing, see the Model Studio console.

Billing is based on the number of input and output tokens.

Error codes

If a model call fails and returns an error message, see Error messages for troubleshooting information.