DeepSeek V4
DeepSeek V4 is available through the OpenAI-compatible Chat Completions API. It supports long context, reasoning, streaming, and function calling. Both input and output are text-only.
Endpoint
POST /v1/chat/completionsSupported Models
| Model | Description |
|---|---|
deepseek-v4-pro | General DeepSeek V4 Pro version |
deepseek-v4-pro-0813 | Stable 2026-08-13 snapshot for applications that require a fixed model version |
The models support a context window of approximately one million tokens. Actual availability and context limits depend on your account permissions and platform configuration.
Basic Request
curl https://cubicspaces.cloud/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro-0813",
"messages": [
{ "role": "system", "content": "You are a precise and concise technical assistant." },
{ "role": "user", "content": "Explain idempotency in one sentence." }
],
"max_completion_tokens": 2048,
"stream": false
}'Reasoning Mode
DeepSeek V4 enables reasoning by default. Use these fields to control it:
| Parameter | Type | Description |
|---|---|---|
enable_thinking | boolean | Set to true to enable reasoning or false to disable it |
reasoning_effort | string | Use high or max; max generally produces deeper and longer reasoning |
{
"model": "deepseek-v4-pro-0813",
"messages": [
{ "role": "user", "content": "Analyze the race conditions in this concurrency design." }
],
"enable_thinking": true,
"reasoning_effort": "high",
"max_completion_tokens": 8192
}In a non-streaming response, reasoning text is returned in choices[0].message.reasoning_content, while the final answer is returned in choices[0].message.content.
{
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"reasoning_content": "First, inspect the shared state and lock scope...",
"content": "The primary issue is a race window between the check and the write."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 42,
"completion_tokens": 318,
"total_tokens": 360
}
}If your application only displays the final answer, you can ignore reasoning_content.
Streaming
curl https://cubicspaces.cloud/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{ "role": "user", "content": "List three common reasons why a database index is not used." }
],
"enable_thinking": true,
"reasoning_effort": "high",
"stream": true,
"stream_options": {
"include_usage": true
}
}'Streaming responses use SSE. Parse these fields separately:
choices[0].delta.reasoning_content: reasoning chunks.choices[0].delta.content: final-answer chunks.usage: usually returned near the end whenstream_options.include_usageis enabled.data: [DONE]: end-of-stream marker.
Function Calling
DeepSeek V4 supports OpenAI-compatible function calling.
{
"model": "deepseek-v4-pro-0813",
"messages": [
{ "role": "user", "content": "Check the current weather in Tokyo." }
],
"tools": [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get the weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": { "type": "string" }
},
"required": ["city"]
}
}
}
],
"tool_choice": "auto"
}When finish_reason is tool_calls:
- Read
choices[0].message.tool_calls. - Execute the requested tools.
- Append each result as a
role: "tool"message. - Continue with the same model to obtain the final answer.
Each tool result's tool_call_id must exactly match its corresponding tool_calls[].id.
Python SDK
from openai import OpenAI
client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://cubicspaces.cloud/v1",
)
response = client.chat.completions.create(
model="deepseek-v4-pro-0813",
messages=[
{"role": "user", "content": "Explain idempotency in one sentence."}
],
max_completion_tokens=2048,
extra_body={
"enable_thinking": True,
"reasoning_effort": "high",
},
)
message = response.choices[0].message
print(message.content)Parameters
| Parameter | Type | Description |
|---|---|---|
model | string | deepseek-v4-pro or deepseek-v4-pro-0813 |
messages | array | OpenAI Chat message array |
max_completion_tokens | integer | Maximum output tokens; preferred for reasoning models |
enable_thinking | boolean | Whether to enable reasoning mode |
reasoning_effort | string | Reasoning effort; use high or max |
stream | boolean | Whether to stream the response |
stream_options | object | Streaming options such as include_usage |
tools | array | Function definitions |
tool_choice | string/object | Tool selection policy |
Notes
- DeepSeek V4 accepts text input only. Do not include images or videos in messages.
- The model does not support
top_k; omit that parameter. - Reasoning and final-answer tokens may both count toward output usage, so set a suitable output limit.
- Tool definitions must use valid JSON Schema, and function names must be unique.
- Use
deepseek-v4-pro-0813when you need a fixed model version; usedeepseek-v4-profor the general version. - If the model is unavailable, verify that it is enabled for your account.