DeepSeek API
  1. API 文档
DeepSeek API
  • 快速开始
    • 首次调用 API
    • 模型 & 价格
    • Temperature 设置
    • Token 用量计算
    • 限速
    • 错误码
  • API 文档
    • 基本信息
    • 对话补全
      POST
    • FIM 补全(Beta)
      POST
    • 列出模型
      GET
    • 查询余额
      GET
  • API 指南
    • 推理模型 (deepseek-reasoner)
    • 多轮对话
    • 对话前缀续写(Beta)
    • FIM 补全(Beta)
    • JSON Output
    • Function Calling
    • 上下文硬盘缓存
  • 提示库
    • 代码改写
    • 代码解释
    • 代码生成
    • 内容分类
    • 结构化输出
    • 角色扮演(自定义人设)
    • 角色扮演(情景续写)
    • 散文写作
    • 诗歌创作
    • 文案大纲生成
    • 宣传标语生成
    • 模型提示词生成
    • 中英翻译专家
  • 常见问题
    • 常见问题
  1. API 文档

FIM 补全(Beta)

POST
https://api.deepseek.com/beta/completions
FIM(Fill-In-the-Middle)补全 API。
用户需要设置 base_url="https://api.deepseek.com/beta" 来使用此功能。
请求示例请求示例
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.deepseek.com/beta/completions' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{
  "model": "deepseek-chat",
  "prompt": "Once upon a time, ",
  "echo": false,
  "frequency_penalty": 0,
  "logprobs": 0,
  "max_tokens": 1024,
  "presence_penalty": 0,
  "stop": null,
  "stream": false,
  "stream_options": null,
  "suffix": null,
  "temperature": 1,
  "top_p": 1
}'
响应示例响应示例
{
  "id": "string",
  "choices": [
    {
      "finish_reason": "stop",
      "index": 0,
      "logprobs": {
        "text_offset": [
          0
        ],
        "token_logprobs": [
          0
        ],
        "tokens": [
          "string"
        ],
        "top_logprobs": [
          {}
        ]
      },
      "text": "string"
    }
  ],
  "created": 0,
  "model": "string",
  "system_fingerprint": "string",
  "object": "text_completion",
  "usage": {
    "completion_tokens": 0,
    "prompt_tokens": 0,
    "prompt_cache_hit_tokens": 0,
    "prompt_cache_miss_tokens": 0,
    "total_tokens": 0,
    "completion_tokens_details": {
      "reasoning_tokens": 0
    }
  }
}

请求参数

Authorization
在 Header 添加参数
Authorization
,其值为在 Bearer 之后拼接 Token
示例:
Authorization: Bearer ********************
Header 参数
Content-Type
string 
必需
示例值:
application/json
Authorization
string 
必需
示例值:
Bearer {{API_KEY}}
Body 参数application/json
model
string 
必需
prompt
string 
必需
echo
boolean  | null 
可选
frequency_penalty
number  | null 
可选
logprobs
integer  | null 
可选
max_tokens
integer  | null 
可选
presence_penalty
number  | null 
可选
stop
null 
可选
stream
boolean  | null 
可选
stream_options
null 
可选
suffix
null 
可选
temperature
integer 
可选
top_p
integer 
可选
示例

返回响应

🟢200成功
application/json
Body
id
string 
必需
choices
array [object {4}] 
必需
finish_reason
string 
可选
index
integer 
可选
logprobs
object  | null 
可选
text
string 
可选
created
integer 
必需
model
string 
必需
system_fingerprint
string 
可选
object
string 
必需
usage
object 
可选
completion_tokens
integer 
必需
prompt_tokens
integer 
必需
prompt_cache_hit_tokens
integer 
必需
prompt_cache_miss_tokens
integer 
必需
total_tokens
integer 
必需
completion_tokens_details
object 
可选
上一页
对话补全
下一页
列出模型
Built with