StarMagicStarMagic
English
简体中文简繁體中文繁EnglishEN日本語日EspañolES한국어KO
Integration Guide
DeepSeek V4 - OpenAI-Compatible APIDeepSeek V4 - Anthropic-Compatible API
StarMagicStarMagic
English
简体中文简繁體中文繁EnglishEN日本語日EspañolES한국어KO
TextDeepSeekDeepseek.V4

DeepSeek V4 - Anthropic-Compatible API

  • Invoke DeepSeek V4 models using the Anthropic Messages protocol
  • Supports deepseek-v4-flash / deepseek-v4-pro
  • Request / response structures aligned with the Anthropic API
  • Plain text conversation (image / document content types are not yet supported)
  • System prompts: Passed via the top-level system field
  • Thinking mode: Controlled by the thinking object; thinking content is returned as a content[type=thinking] block
  • Streaming output: SSE event stream
  • Tool calling: Compatible with Anthropic tool_use / tool_result flow
<Note> **BaseURL**: The default BaseURL is `https://api.starmagic.ai`, which has better support for text models and long-lived connections. `https://api.starmagic.ai` is the primary endpoint for multimodal services and serves as a fallback address for text models. </Note>

Authorization

AuthorizationstringheaderRequired

##All APIs require Bearer Token authentication## **Get API Key**: Visit the [API Key Management Page](https://starmagic.ai/app/api-keys) to obtain your API Key **Add to request header**: ``` Authorization: Bearer YOUR_API_KEY ``` **Note**: Although Anthropic's native API uses the `x-api-key` header, EvoLink's `/v1/messages` uniformly uses Bearer Token authentication.

Authorization: Bearer YOUR_API_KEY

Request body

application/json
modelenum<deepseek-v4-flash | deepseek-v4-pro>Required

Model to invoke - `deepseek-v4-flash`: Fast general-purpose - `deepseek-v4-pro`: Deep reasoning **Tip**: Both models **have thinking enabled by default**, and responses always contain a `type="thinking"` content block; set `thinking.type="disabled"` explicitly to turn it off. An unspecified or unsupported model is automatically mapped to `deepseek-v4-flash`.

"deepseek-v4-flash"
max_tokensintegerRequired

Maximum number of tokens to generate (**required**) **Notes**: - The V4 series can reach up to **384,000** - Tokens produced by thinking also count toward the max_tokens limit

1024
messagesobject[]Required

List of conversation messages, alternating between user / assistant turns **Notes**: - At least one message must be included - The final message is typically `role=user` - `image` / `document` content types are not yet supported

[
  {
    "role": "user",
    "content": null
  }
]
systemobject

System prompt, used to define the AI's role and behavior **Notes**: - Accepts a string or an array of strings - Unlike the `system` message on the OpenAI endpoint, the Anthropic endpoint uses a top-level `system` field

temperaturenumber

Sampling temperature **Notes**: - Range `[0.0, 2.0]` - Default 1; higher values are more diverse, lower values are more deterministic

1
top_pnumber

Nucleus sampling threshold **Notes**: - Range `[0, 1]` - Do not adjust temperature and top_p simultaneously

1
stop_sequencesstring[]

Custom stop sequences **Notes**: - Generation stops when the model encounters any of these strings - Up to 4 entries (following Anthropic's specification)

[
  "string"
]
streamboolean

Whether to return via SSE streaming - `true`: Server-Sent Events streaming return - `false`: Return the complete response all at once (default)

false
thinkingobject

Thinking mode control (V4) **Notes**: - **Enabled by default on both models** (`type=enabled`) - When enabled, the response `content` array includes a `type="thinking"` reasoning block (billed as output tokens) - **Note**: The API **ignores** Anthropic's native `budget_tokens` field; use `output_config.effort` to control depth - In multi-turn conversations, simply place the thinking block from the previous response back into the assistant `content` array verbatim (the Anthropic protocol is more lenient — missing thinking will not cause an error, but preserving the signature helps context consistency)

{
  "type": "enabled",
  "budget_tokens": 0
}
output_configobject

Output configuration (V4 extension) **Notes**: DeepSeek only supports the `effort` field

{
  "effort": "medium"
}
toolsobject[]

List of tool definitions **Notes**: - Follows the Anthropic tool definition specification - `input_schema` uses a JSON Schema object

[
  {
    "name": "string",
    "description": "string",
    "input_schema": {}
  }
]
tool_choiceobject

Controls tool-calling behavior **Available types**: - `auto`: Model decides automatically (default when tools are provided) - `any`: Must call some tool (without specifying which) - `tool`: Must call the specified `name` - `none`: Forbid tool calls

{
  "type": "auto",
  "name": "string",
  "disable_parallel_tool_use": true
}

Response

application/json
成功

Response body

idstring

Unique message ID

"string"
typeenum<message>

Response object type

"message"
roleenum<assistant>
"assistant"
modelstring

Model actually used

"deepseek-v4-pro"
contentobject[]

List of response content blocks **Possible block types**: - `thinking`: Reasoning process (only when thinking is enabled) - `text`: Final answer text - `tool_use`: Tool call initiated by the model

[
  {
    "type": "text",
    "text": "string",
    "thinking": "string",
    "signature": "string",
    "id": "string",
    "name": "string",
    "input": {}
  }
]
stop_reasonenum<end_turn | max_tokens | stop_sequence | tool_use>

Stop reason - `end_turn`: Natural completion - `max_tokens`: Reached the max_tokens limit - `stop_sequence`: Hit a stop_sequences entry - `tool_use`: Model triggered a tool call

"end_turn"
stop_sequencestringnull

The specific sequence hit when stop_reason=`stop_sequence`; otherwise null

usageobject

Token usage statistics (Anthropic specification)

{
  "input_tokens": 10,
  "output_tokens": 30,
  "cache_creation_input_tokens": 0,
  "cache_read_input_tokens": 0,
  "service_tier": "standard"
}
POST/v1/messages
curl --request POST \
  --url https://api.starmagic.ai/v1/messages \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "deepseek-v4-flash",
  "max_tokens": 1024,
  "messages": [
    {
      "role": "user",
      "content": "Hello, world"
    }
  ]
}'
Response: 成功
{
  "id": "53ee6690-e14a-4e6b-890b-a135100d51c7",
  "type": "message",
  "role": "assistant",
  "model": "deepseek-v4-flash",
  "content": [
    {
      "type": "thinking",
      "thinking": "The user is asking about Japan's capital — a basic geography question. The answer is Tokyo, just give it directly.",
      "signature": "53ee6690-e14a-4e6b-890b-a135100d51c7"
    },
    {
      "type": "text",
      "text": "The capital of Japan is **Tokyo**."
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 7,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "output_tokens": 77,
    "service_tier": "standard"
  }
}