无需 KYC — 不用身份证、不用自拍、不用证件。用加密货币支付:BTC, USDT, USDC, ETH, SOL, LTC
语言: 简体中文
获取 API 密钥

文档 · API reference

Chat completions endpoint:POST /api/v1/chat/completions

一个 endpoint 即可调用所有模型。它接受与 OpenAI chat completions API 相同的 body,并返回相同的对象,因此现有集成只需新的 base URL、新的密钥和来自我们列表的 model id。

最后更新: · 3 分钟阅读

快速回答

LLMwithCrypto 的 chat completions endpoint 接受哪些字段?

它接受 OpenAI chat completions 的 body:model 和 messages 为必填;max_tokens、temperature、top_p、stop、stream、stream_options、tools、tool_choice 和 response_format 为可选。LLMwithCrypto 返回一个 chat.completion 对象,其中包含 usage 计数,按 token 从你的积分中计费,如 2026 年 10 月 23 日文档所述。Tool calling 和 JSON 输出取决于模型。

endpoint 概览

方法和 URLPOST https://llmwithcrypto.com/api/v1/chat/completions
身份验证像 OpenAI SDK 那样,把 API 密钥作为 Bearer token 放在 Authorization header 中传入
BodyJSON,Content-Type: application/json
响应chat.completion 对象,或使用 stream: true 的 server-sent events
计费按 token 从余额扣费:输入和输出 token 由模型自己的 tokenizer 计数,按该模型每 1M token 的价格计费。以错误结束的调用不收费
功能所有模型都支持流式输出;工具调用和 JSON 输出取决于各模型本身的支持情况

创建 chat completion

POST/api/v1/chat/completions

将一段对话发送给一个模型,并返回其回答及 token 计数。示例向 DeepSeek V4 Pro 提出一个简短问题,上限为 200 token;响应中的 id、时间和计数仅为示意。

认证:API 密钥放在 Authorization: Bearer API_KEY header 中。

请求体

字段类型必填描述
modelstring是model id,例如 deepseek-v4-pro 或 gpt-oss-120b。GET /api/v1/models 返回你的密钥可调用的所有 id。
messagesobject[]是对话,最早的在前。每一项包含一个 role(system、user、assistant 或 tool)和一个 content 字符串;tool 消息还带有一个 tool_call_id。
max_tokensinteger否回答可用的最大 token 数。不设置时,模型可能会一直写到其上下文窗口填满,而你需为它写出的每个 token 付费。
temperaturenumber否0 到 2。越低越可预测,越高越多样。默认值取决于模型。
top_pnumber否0 到 1,nucleus sampling。只改 temperature 或 top_p,不要同时改。
stopstring or string[]否最多 4 个序列,当模型写出它们时结束回答。它们不包含在回答中。
streamboolean否true 以 server-sent events 逐块发送回答。参见 streaming。
stream_optionsobject否{"include_usage": true} 添加一个最后事件,包含流式调用的 usage。
toolsobject[]否模型可能要求你调用的函数,采用 OpenAI 格式。适用于支持 tool calling 的模型。参见 tool calling。
tool_choicestring or object否auto(设置 tools 时的默认值)、none、required 或 {"type": "function", "function": {"name": "…"}}。
response_formatobject否{"type": "json_object"} 请求一个有效的 JSON 对象,适用于支持它的模型。在你的提示词中说明 JSON 应包含的内容。
示例: a short answer from DeepSeek V4 Pro
{
  "model": "deepseek-v4-pro",
  "messages": [
    {
      "role": "system",
      "content": "Answer in two sentences."
    },
    {
      "role": "user",
      "content": "What is a context window?"
    }
  ],
  "max_tokens": 200
}
示例: a JSON object from gpt-oss-120b, low temperature
{
  "model": "gpt-oss-120b",
  "messages": [
    {
      "role": "user",
      "content": "Return {\"city\": string, \"country\": string} for the Eiffel Tower."
    }
  ],
  "response_format": {
    "type": "json_object"
  },
  "temperature": 0.2,
  "max_tokens": 100
}

响应 200

{
  "id": "chatcmpl-8f2c41d0a7b94e1c",
  "object": "chat.completion",
  "created": 1792742400,
  "model": "deepseek-v4-pro",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "A context window is the maximum number of tokens a model can read and write in one request. Anything beyond it must be cut or summarized before the call."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 27,
    "completion_tokens": 34,
    "total_tokens": 61
  }
}

代码示例

curl
curl -s "https://llmwithcrypto.com/api/v1/chat/completions" \
  -H "Authorization: Bearer $LLMWITHCRYPTO_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "deepseek-v4-pro",
    "messages": [
      {"role": "system", "content": "Answer in two sentences."},
      {"role": "user", "content": "What is a context window?"}
    ],
    "max_tokens": 200
  }'
Python
import os

from openai import OpenAI

client = OpenAI(
    base_url="https://llmwithcrypto.com/api/v1",
    api_key=os.environ["LLMWITHCRYPTO_API_KEY"],
)

resp = client.chat.completions.create(
    model="deepseek-v4-pro",
    messages=[
        {"role": "system", "content": "Answer in two sentences."},
        {"role": "user", "content": "What is a context window?"},
    ],
    max_tokens=200,
)
print(resp.choices[0].message.content)
print(resp.usage.prompt_tokens, "in,", resp.usage.completion_tokens, "out")
Node.js
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://llmwithcrypto.com/api/v1',
  apiKey: process.env.LLMWITHCRYPTO_API_KEY,
});

const resp = await client.chat.completions.create({
  model: 'deepseek-v4-pro',
  messages: [
    { role: 'system', content: 'Answer in two sentences.' },
    { role: 'user', content: 'What is a context window?' },
  ],
  max_tokens: 200,
});
console.log(resp.choices[0].message.content);
console.log(resp.usage.prompt_tokens, 'in,', resp.usage.completion_tokens, 'out');

如何编写 messages?

每次都要发送完整对话,最早的消息在前:API 在调用之间不保留记忆,你的提示词也不会被存储。我们不保存你的提示词或模型的回答:响应一旦发出,其文本即消失。每次调用只留一行日志,记录时间、账户、模型和 token 数量,30 天后删除。

  • system:为每个回答定调的指令,例如语气、语言或输出格式。放在最前面。
  • user:用户或你的程序提出的问题。
  • assistant:模型之前的回答,让它能接着对话往下说。
  • tool:模型要求你运行的函数的结果,以及它给你的 tool_call_id。

每条消息都计入输入 token,所以历史越长,每一轮的花费越高。对话变长时,裁剪或总结较早的轮次。

一次请求可以有多长?

输入和输出加起来必须能放进模型的上下文窗口。截至 2026 年 10 月 23 日,DeepSeek V4 Pro 最多读取 1M tokens,gpt-oss-120b 最多 128K,Qwen3 235B 最多 256K;models 页面列出了全部模型。

放不下的请求会返回 400,代码为 context_length_exceeded,且不产生费用。设置 max_tokens,让提示词加上你接受的最长回答始终落在窗口之内。

finish_reason 能告诉我什么?

finish_reason含义该怎么做
stop模型结束了回答,或写出了你的某个 stop 序列无需处理:回答已完成
length回答达到了 max_tokens 或上下文窗口上限调高 max_tokens,或要求更短的回答
tool_calls模型想让你运行一个或多个函数运行它们并把结果发回去,见工具调用

哪些 OpenAI 参数不受支持?

上表中的字段就是全部约定。OpenAI API 的其他字段,例如 n(每次调用返回多个回答)、logprobs、audio 或图像输入,都不受支持:只发送此处列出的字段。这些模型都是文本模型;没有任何一个能通过这个 endpoint 接收图像。

model 字段只接受我们列表中的 id。我们不出售 GPT、Claude、Gemini 或 Grok 的访问权限:其开发商禁止未经其批准转售 API 访问,而我们并未获得该批准。

Chat completions:常见问题

还有旧版 completions endpoint 吗?

没有。只有 chat 格式;单个提示词就是一个 messages 数组,里面放一条 user 消息。

一次调用要花多少钱?

按 token 从余额扣费:输入和输出 token 由模型自己的 tokenizer 计数,按该模型每 1M token 的价格计费。以错误结束的调用不收费。各模型的价格在定价页面上。

我能查看过去的请求吗?

不能,这是设计如此。我们不保存你的提示词或模型的回答:响应一旦发出,其文本即消失。每次调用只留一行日志,记录时间、账户、模型和 token 数量,30 天后删除。

为什么我的回答中途停了?

此时 finish_reason 是 length:回答触到了 max_tokens。在模型的上下文窗口内调高它。

DeepSeek V4 Pro 低至 $1.254 每 1M 输入 token · 无需 KYC

获取 API 密钥