DeepSeek Chat Completions
Call DeepSeek V4.1 Flash, V4 Pro and their high-cache versions through one OpenAI Chat Completions endpoint with a BeatAPI key.
- One endpoint,
POST /v1/chat/completions, for every current DeepSeek model. Changemodelto switch. - Text input and text output, streaming, function calling, and 1M-token context on the models in the table below.
- Works with the OpenAI SDK: change the base URL and use a BeatAPI key.
- The same models also answer on OpenAI Responses and Anthropic Messages.
Use https://direct.beatapi.io as the base URL for text requests: it is not subject to Cloudflare’s 100-second limit, so a long non-streaming request is not cut off. https://api.beatapi.io also works and is the fallback if direct.beatapi.io is unreachable from your network. The key, models and prices are the same on both. Image and video APIs use https://api.beatapi.io only.
Opens this endpoint in the API Explorer. Enter your BeatAPI API key and send: the call is real and is billed to your own balance.
Models
Send one of these IDs as model. Each is a separate model; do not treat them as aliases of each other.
- Prices are the base tier, discount already applied. A long-context tier, cached-input rates and cache writes are not in this table; see the price table.
—means the catalogue does not publish the number.- * A peak-time multiplier applies in the model’s peak window; the price shown is the off-peak base price.
Older IDs of this family still work and are listed on Legacy models.
Quick start
Install the openai package on your server, keep the key in BEATAPI_API_KEY, and never put it in browser code. These are request examples, not recorded model outputs.
Read the answer from choices[0].message.content, then check finish_reason and usage. An HTTP 200 alone does not prove the answer satisfies your task: validate it in your application. Text requests return directly; do not poll /v1/tasks for them.
Free versions
These models have a free version. It costs nothing per token, is called on the same endpoint with the free model ID, and has its own per-minute limit: 1 successful request per minute per account before the first top-up and 10 per minute after. Its stability is not guaranteed: it can be rate-limited or withdrawn at any time. See Free models.
deepseek-v4.1-flash-free
deepseek-v4-flash-0731-free
Endpoint and authentication
POST https://direct.beatapi.io/v1/chat/completions
Authorization
string
Required
Bearer <BEATAPI_API_KEY>. The key works with or without the sk- prefix.
Request parameters
Standard OpenAI Chat Completions fields are accepted. Request-format compatibility does not mean every model-specific option is supported, so test the options you rely on.
model
string
Required
The exact model ID.
Allowed values: deepseek-v4.1-flash, deepseek-v4-pro-0813, deepseek-v4.1-flash-hc, deepseek-v4-pro-0813-hc
- Each ID is a separate model, not an alias of another.
- Call
GET /v1/modelswith your key to confirm which models are enabled for it. - The older ID
deepseek-v4-flash-0731still works and is listed on Legacy models.
messages
object[]
Required
The conversation, oldest message first. Each message has a role (system, user, assistant or tool) and content.
max_tokens
integer
Optional
Upper bound on the generated tokens, reasoning included.
- The gateway does not compare your value with the model’s max output from the table above. Keep it at or below that number.
max_tokensis also used to estimate how much balance a request needs. A very large value can be refused with402 insufficient_creditseven when the real output would be small. Set it to what you need.
A reasoning model writes its reasoning first. If max_tokens is too small, the reasoning can use all of it: content comes back empty and finish_reason is length. Leave room for both, and raise the value when you see length.
stream
boolean
OptionalDefault: false
Return the answer as server-sent events. See the Streaming section below.
Default: false
temperature
number
Optional
Sampling temperature. Change this or top_p, not both.
top_p
number
Optional
Nucleus sampling threshold.
stop
string | string[]
Optional
One or more sequences at which generation stops.
tools
object[]
Optional
Function definitions the model may call. The model answers with tool_calls; return each result in a following tool message that carries the matching tool_call_id.
tool_choice
string | object
Optional
Whether the model may, must or must not call a tool. Test the value you rely on with your model.
High-cache (HC) models
deepseek-v4-pro-0813-hc and deepseek-v4.1-flash-hc are the same two models served on a high-cache line. When requests share a prompt prefix, such as a long system prompt, a tool list or a conversation that keeps growing, the repeated prefix is billed at the cached-input rate. The regular line costs less per token but does not guarantee a cache hit.
Pick an HC model when most of each prompt is a prefix you send again and again. For prompts with little repetition the regular model is cheaper. Requests are identical to the regular models: only the model ID changes. Check the cached-input count in usage instead of assuming a hit.
Rates by time of day
The regular models, deepseek-v4.1-flash and deepseek-v4-pro-0813, bill one rate at every hour of every day.
The two HC models have a peak window. Every rate doubles on weekdays 09:00–12:00 and 14:00–18:00 Beijing time (GMT+8): input, cached input and output alike. Outside those hours, and all day on Saturday and Sunday, they bill the off-peak rate, which is the one in the model table above and on the price table.
Response
A non-streaming call returns one JSON object. This is an abbreviated example.
Response fields
Streaming
Set "stream": true. The answer arrives as chat.completion.chunk events and ends with data: [DONE].
- The response is
text/event-stream; without streaming it isapplication/json. - Text arrives in
choices[0].delta.content. A reasoning model sends its reasoning indelta.reasoning_contentfirst. - A failure before the model is called is returned as a normal JSON error with an HTTP status, not as a stream event.
- Set explicit timeouts and reconnect a streamed response safely.
Errors
HTTP errors at a glance
Authentication, routing, rate-limit and unknown-model failures are answered before the model is called, in the BeatAPI envelope: error.code, error.message, retryable, request_id. Every other failure keeps the OpenAI SDK shape {"error": {"message", "type", "code"}}: the code is in error.code and the request id ends message. See Errors.
Full code table and retry policy: Errors.
Notes
- DeepSeek models also answer on OpenAI Responses and Anthropic Messages.
- These models reason before they answer. Reasoning tokens are counted in the output tokens and billed as output, so budget
max_tokensfor the reasoning as well as the answer. - Input is text only: image input is not supported on these models.
- Keep API keys on trusted servers, log the response request ID, and retry only
429,500and503.
Authentication
Send your API key as Authorization: Bearer <BEATAPI_API_KEY>.
Request
The exact model ID.
Each ID is a separate model, not an alias of another.
Call GET /v1/models with your key to confirm which models are enabled for it.
The older ID deepseek-v4-flash-0731 still works and is listed on Legacy models.
deepseek-v4.1-flash, deepseek-v4-pro-0813, deepseek-v4.1-flash-hc, deepseek-v4-pro-0813-hc
The conversation, oldest message first. Each message has a role (system, user, assistant or tool) and content.
Upper bound on the generated tokens, reasoning included.
The gateway does not compare your value with the model’s max output from the table above. Keep it at or below that number.
max_tokens is also used to estimate how much balance a request needs. A very large value can be refused with 402 insufficient_credits even when the real output would be small. Set it to what you need.
A reasoning model writes its reasoning first. If max_tokens is too small, the reasoning can use all of it: content comes back empty and finish_reason is length. Leave room for both, and raise the value when you see length.
Return the answer as server-sent events. See the Streaming section below.
Sampling temperature. Change this or top_p, not both.
Function definitions the model may call. The model answers with tool_calls; return each result in a following tool message that carries the matching tool_call_id.
Response
A non-streaming call returns one JSON object. This is an abbreviated example.

