DeepSeek - Complete API Reference
- Call DeepSeek models using OpenAI SDK format
- Synchronous processing mode, real-time response
- Supports
deepseek-chat(general conversation) anddeepseek-reasoner(deep reasoning) models - Text Chat: Single or multi-turn contextual conversation
- System Prompts: Customize AI role and behavior
- Streaming: SSE streaming output support
- Tool Calling: Function Calling support
Authorization
##All APIs require Bearer Token authentication## **Get API Key:** Visit [API Key Management Page](https://starmagic.ai/app/api-keys) to get your API Key **Add to request header:** ``` Authorization: Bearer YOUR_API_KEY ```
Authorization: Bearer YOUR_API_KEYRequest body
application/jsonChat model name - `deepseek-chat`: General conversation model - `deepseek-reasoner`: Deep reasoning model, excels at math, coding and complex logical reasoning **Note**: `deepseek-reasoner` does not support `temperature`, `top_p`, `tools`, `tool_choice`, `response_format` parameters. Passing these will be rejected by upstream
"deepseek-chat"Conversation message list, supports multi-turn conversation Different roles have different field structures, select the corresponding role to view
[
null
]Thinking mode control (Beta) **Details**: - Controls the deep thinking feature of `deepseek-reasoner` model - When enabled, the model will perform deep reasoning before responding
{
"type": "enabled"
}Frequency penalty parameter to reduce repetitive content **Details**: - Positive values penalize tokens based on their frequency in the generated text - Higher values make it less likely to repeat existing content - Default: 0 (no penalty)
0Maximum number of tokens to generate **Details**: - The model will stop generating when this limit is reached - If not set, the model decides the generation length
4096Presence penalty parameter to encourage new topics **Details**: - Positive values penalize tokens based on whether they have appeared in the text - Higher values encourage discussing new topics - Default: 0 (no penalty)
0Specify response format **Details**: - Set to `{"type": "json_object"}` to enable JSON mode - In JSON mode, the model will output valid JSON content
{
"type": "text"
}Stop sequences. The model will stop generating when encountering these strings **Details**: - Can be a single string or an array of strings - Maximum 16 stop sequences
Whether to stream the response - `true`: Stream via SSE (Server-Sent Events), returning content in real-time chunks - `false`: Wait for the complete response before returning
falseStreaming response options Only effective when `stream=true`
{
"include_usage": true
}Sampling temperature, controls output randomness **Details**: - Lower values (e.g. 0.2): More deterministic, focused output - Higher values (e.g. 1.5): More random, creative output - Default: 1
1Nucleus Sampling parameter **Details**: - Controls sampling from tokens whose cumulative probability reaches the threshold - For example, 0.9 means sampling from tokens reaching 90% cumulative probability - Default: 1.0 (consider all tokens) **Tip**: Avoid adjusting both temperature and top_p simultaneously
1Tool definition list for Function Calling **Details**: - Maximum 128 tool definitions - Each tool requires a name, description and parameter schema
[
{
"type": "function",
"function": {
"name": "string",
"description": "string",
"parameters": {},
"strict": false
}
}
]Controls tool calling behavior **Options**: - `none`: Do not call any tools - `auto`: Model decides whether to call tools - `required`: Force the model to call one or more tools **Default**: `none` when no tools provided, `auto` when tools are provided
Whether to return token log probabilities **Details**: - When set to `true`, the response will include log probability information for each token
falseReturn log probabilities of the top N most likely tokens **Details**: - Requires `logprobs` to be set to `true` - Range: `[0, 20]`
0Response
application/jsonResponse body
Unique identifier for the chat completion
"930c60df-bf64-41c9-a88e-3ec75f81e00e"Actual model name used
"deepseek-chat"Response type
"chat.completion"Creation timestamp
1770617860List of chat completion choices
[
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm DeepSeek, a powerful AI assistant. I excel at general conversation, code generation, mathematical reasoning and many other tasks.",
"reasoning_content": "Let me analyze this problem...",
"tool_calls": [
{
"id": null,
"type": null,
"function": null
}
]
},
"finish_reason": "stop"
}
]Token usage statistics
{
"prompt_tokens": 16,
"completion_tokens": 10,
"total_tokens": 26,
"prompt_cache_hit_tokens": 0,
"prompt_cache_miss_tokens": 16
}System fingerprint identifier
"fp_eaab8d114b_prod0820_fp8_kvcache"
