DeepSeek V4.1 Flash INTL API Guide
Text chat, document analysis, structured extraction and tool calls through Chat Completions, Responses and Messages.
Get started
Use an APIMaster API key and the public model ID deepseek-v4.1-flash-intl. Send text as a JSON body. All three endpoints run synchronously and optionally stream via server-sent events (SSE).
| Protocol | Path | Success signal |
|---|---|---|
| Chat Completions | POST /v1/chat/completions |
[DONE] |
| Responses | POST /v1/responses |
response.completed |
| Messages | POST /v1/messages |
message_stop |
Use this model in Claude Code
Claude Code can send thinking.type: adaptive, which returns 400 invalid_parameter on this model’s Messages endpoint. Open ~/.claude/settings.json and merge the setting below into the existing env object. Create env if it is missing.
{
"env": {
"CLAUDE_CODE_DISABLE_THINKING": "1"
}
}
This setting makes Claude Code omit thinking from its requests, so the model uses the service default. Save the file, restart Claude Code, and run the following command using your APIMaster connection settings.
claude --model deepseek-v4.1-flash-intl
Use cases
- Chat and support. preserve conversation turns in Chat Completions and put system instructions first.
- Extraction and classification. use Chat JSON mode or a Responses schema to return fields your application can validate.
- Document analysis and coding. pass text and instructions separately in Responses. Enable thinking for tasks that need several steps.
- Agent tools. define functions in the protocol your SDK uses. Validate arguments, execute each function in your application and send back the result with its call ID.
Request parameters
Chat Completions
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string |
Yes | Use deepseek-v4.1-flash-intl in every request. |
messages |
array |
Yes | Text conversation with at least one message. In Chat put the system message first. In Messages put system instructions in the top-level system field. |
messages[].role |
string |
Yes | system / user / assistant / tool |
messages[].content |
string / array / null |
No | text / null + tool_calls |
messages[].tool_call_id |
string |
No | role: tool → tool_calls[].id |
max_tokens |
integer |
No | Positive integer output limit. Messages requires it, when thinking is enabled it must exceed the thinking budget. |
stream |
boolean |
No | Turn SSE on with true, false returns a JSON object. Set the field explicitly when switching modes. |
temperature |
number |
No | Sampling temperature. Chat and Responses accept 0 ≤ temperature < 2, Messages accepts 0 ≤ temperature ≤ 2. |
top_p |
number |
No | Nucleus sampling: 0 < top_p ≤ 1. Omit sampling parameters to use service defaults. |
top_k |
integer |
No | Positive candidate count for Chat or Messages. Omit to use the service default. |
frequency_penalty, presence_penalty |
number |
No | Chat frequency and presence penalties each range from -2 to 2. |
stop |
string / string[] |
No | Chat accepts a stop string or array of strings. Messages uses the separate stop_sequences array. |
reasoning_effort |
string |
No | Chat sets reasoning_effort, Responses sets reasoning.effort. none disables thinking, medium is a starting point for enabling it. none, minimal, low, medium, high, xhigh, max. |
tools |
array |
No | Function declarations. Chat places the definition inside function, Responses declares name, description and parameters at the top level, Messages uses input_schema. |
tool_choice |
string / object |
No | Select automatically or specify a named tool using the shape for the endpoint. auto / {"type":"function","function":{"name":"lookup"}} |
response_format |
object |
No | JSON output mode or JSON Schema. Give an explicit JSON instruction when using JSON object mode. type: json_object / type: json_schema → json_schema.name, json_schema.schema |
stream_options.include_usage |
boolean |
No | true → usage |
seed |
integer |
No | seed: 42 |
n |
integer |
No | n: 1 |
logprobs |
boolean |
No | true → choices[].logprobs |
user |
string |
No | Use opaque identifiers for end users. |
Chat accepts one candidate (n: 1), seed reproducibility is best effort. Request token log probabilities with logprobs, omit top_logprobs. For streaming, set include_usage: true in stream_options and read the usage chunk before [DONE].
Responses
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string |
Yes | Use deepseek-v4.1-flash-intl in every request. |
input |
string / array |
Yes | User text or a list of standard Responses input items. Put system-level guidance in instructions. |
instructions |
string |
No | instructions → input |
max_output_tokens |
integer |
No | Set an integer of at least 16 when supplying a Responses output limit. |
stream |
boolean |
No | Turn SSE on with true, false returns a JSON object. Set the field explicitly when switching modes. |
temperature |
number |
No | Sampling temperature. Chat and Responses accept 0 ≤ temperature < 2, Messages accepts 0 ≤ temperature ≤ 2. |
top_p |
number |
No | Nucleus sampling: 0 < top_p ≤ 1. Omit sampling parameters to use service defaults. |
reasoning.effort |
string |
No | Chat sets reasoning_effort, Responses sets reasoning.effort. none disables thinking, medium is a starting point for enabling it. none, minimal, low, medium, high, xhigh, max. |
tools |
array |
No | Function declarations. Chat places the definition inside function, Responses declares name, description and parameters at the top level, Messages uses input_schema. |
tool_choice |
string / object |
No | Select automatically or specify a named tool using the shape for the endpoint. auto / {"type":"function","name":"lookup"} |
text.format |
object |
No | JSON output mode or JSON Schema. Give an explicit JSON instruction when using JSON object mode. type: json_object / type: json_schema → name, schema |
metadata |
object |
No | Optional metadata object. Use opaque identifiers for end users. |
Responses supports creation and streaming. Keep conversation context in your application, use the Responses fields listed here and omit stop, stop_sequences, top_k, frequency_penalty, and presence_penalty.
Messages
| Parameter | Type | Required | Description |
|---|---|---|---|
model |
string |
Yes | Use deepseek-v4.1-flash-intl in every request. |
messages |
array |
Yes | Text conversation with at least one message. In Chat put the system message first. In Messages put system instructions in the top-level system field. |
messages[].role |
string |
Yes | user / assistant |
messages[].content |
string / array |
Yes | text / tool_use / tool_result |
max_tokens |
integer |
Yes | Positive integer output limit. Messages requires it, when thinking is enabled it must exceed the thinking budget. |
system |
string / array |
No | system → messages. |
thinking |
object |
No | Messages uses {"type":"enabled","budget_tokens":1024} with an integer budget_tokens of at least 1024 and below max_tokens, or {"type":"disabled"}. Omit the field for the service default. |
stream |
boolean |
No | Turn SSE on with true, false returns a JSON object. Set the field explicitly when switching modes. |
temperature |
number |
No | Sampling temperature. Chat and Responses accept 0 ≤ temperature < 2, Messages accepts 0 ≤ temperature ≤ 2. |
top_p |
number |
No | Nucleus sampling: 0 < top_p ≤ 1. Omit sampling parameters to use service defaults. |
top_k |
integer |
No | Positive candidate count for Chat or Messages. Omit to use the service default. |
stop_sequences |
string[] |
No | Chat accepts a stop string or array of strings. Messages uses the separate stop_sequences array. |
tools |
array |
No | Function declarations. Chat places the definition inside function, Responses declares name, description and parameters at the top level, Messages uses input_schema. |
tool_choice |
object |
No | Select automatically or specify a named tool using the shape for the endpoint. {"type":"auto"} / {"type":"tool","name":"lookup"} |
metadata.user_id |
string |
No | Use opaque identifiers for end users. |
Send one thinking control per request. Messages accepts the enabled or disabled forms above, leave out adaptive and output_config.effort.
Copyable requests
Use Authorization: Bearer $APIMASTER_API_KEY for all three examples. Messages also sends anthropic-version: 2023-06-01. Set the environment variable in your terminal before running the examples.
export APIMASTER_API_KEY="YOUR_APIMASTER_API_KEY"
Chat Completions
curl --fail-with-body 'https://apimaster.ai/v1/chat/completions' \
-H "Authorization: Bearer $APIMASTER_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "deepseek-v4.1-flash-intl",
"messages": [
{
"role": "system",
"content": "Return a JSON object with category and priority."
},
{
"role": "user",
"content": "Ticket: My invoice link expired. Please send a new one."
}
],
"max_tokens": 256,
"reasoning_effort": "none",
"response_format": {
"type": "json_object"
},
"stream": false
}'
Responses
curl --fail-with-body --no-buffer 'https://apimaster.ai/v1/responses' \
-H "Authorization: Bearer $APIMASTER_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "deepseek-v4.1-flash-intl",
"instructions": "Summarize in two bullets. Preserve dates and owners.",
"input": "On May 12, Leila will publish the migration checklist. On May 19, Arun will review rollback tests.",
"max_output_tokens": 256,
"reasoning": {
"effort": "none"
},
"stream": true
}'
Messages
curl --fail-with-body 'https://apimaster.ai/v1/messages' \
-H "Authorization: Bearer $APIMASTER_API_KEY" \
-H 'Content-Type: application/json' \
-H 'anthropic-version: 2023-06-01' \
-d '{
"model": "deepseek-v4.1-flash-intl",
"system": "Write a concise, friendly support reply.",
"messages": [
{
"role": "user",
"content": "Explain how to download my invoice again."
}
],
"max_tokens": 256,
"thinking": {
"type": "disabled"
},
"stream": false
}'
Read the response
Read text from choices[].message.content, output[].content[] where type is output_text, or content[].text, respectively.
| Protocol | Description | Success signal |
|---|---|---|
| Chat Completions | choices[].delta.content |
[DONE] |
| Responses | response.output_text.delta → delta |
response.completed |
| Messages | content_block_delta → delta.text |
message_stop |
For SSE, append the text deltas and wait for the protocol's terminal event. In Responses handle response.incomplete separately and inspect incomplete_details, treat an error event or a disconnect before completion as an unfinished request. Ignore heartbeat comments. Messages usage updates are cumulative.
After a tool call, return Chat {"role":"tool","tool_call_id":"...","content":"..."}, Responses {"type":"function_call_output","call_id":"...","output":"..."}, or Messages {"type":"tool_result","tool_use_id":"...","content":"..."} with the matching identifier before asking for the next answer.
On HTTP 400, check the protocol fields and sampling or thinking limits. On 401, check the APIMaster key, on 429, reduce concurrency and back off.
Usage and pricing
Bill uncached input, cache reads and output separately. Chat usage.prompt_tokens and Responses usage.input_tokens already include cached input, so subtract the cache-read tokens before computing uncached input. Messages usage.input_tokens excludes cache_read_input_tokens. Read Chat's final usage chunk even when choices is empty.
Daily UTC schedule. peak 00:00–14:00, off-peak 14:00–24:00. See the model card for current rates.
