跳转到主要内容

Request Body

model
string
必填
ID of the model to use. See Models for available options.
messages
array
必填
组成对话的消息列表。每个消息对象包含:
  • role (string): system, user, or assistant
  • content (string | array): The message content
When content is an array, LemonData supports structured multimodal blocks for compatible models:
  • text: { "type": "text", "text": "..." }
  • image: { "type": "image_url", "image_url": { "url": "https://..." } }
  • video: { "type": "video_url", "video_url": { "url": "https://..." } }
  • audio: { "type": "audio_url", "audio_url": { "url": "https://..." } }
For multimodal production traffic, prefer public https URLs. LemonData will translate these media blocks into the provider-specific request shape required by the routed physical model.
temperature
number
默认值:"1"
采样温度,范围在 0 到 2 之间。较高的值会使输出更随机。
max_tokens
integer
要生成的最大 token 数。
stream
boolean
默认值:"false"
如果为 true,则部分消息增量将作为 SSE events 发送。
stream_options
object
流式传输选项。设置 include_usage: true 以在流分片中接收 token 使用情况。
top_p
number
默认值:"1"
Nucleus 采样参数。建议更改此参数或 temperature,而不是同时更改两者。
frequency_penalty
number
默认值:"0"
值在 -2.0 到 2.0 之间。正值会惩罚重复出现的 token。
presence_penalty
number
默认值:"0"
值在 -2.0 到 2.0 之间。正值会惩罚已出现在文本中的 token。
stop
string | array
最多 4 个序列,API 在遇到这些序列时会停止生成 token。
tools
array
模型可能调用的工具列表(函数调用)。
tool_choice
string | object
控制模型如何使用工具。选项:auto, none, required, 或特定工具对象。
parallel_tool_calls
boolean
默认值:"true"
是否启用并行函数调用。设置为 false 则按顺序调用函数。
max_completion_tokens
integer
补全的最大 token 数。作为 max_tokens 的替代,对于启用推理的新模型系列更有用。
reasoning_effort
string
启用推理的模型的推理强度。选项:low, medium, high
seed
integer
用于确定性采样的随机种子。
n
integer
默认值:"1"
要生成的补全数量(1-128)。
logprobs
boolean
是否返回对数概率(log probabilities)。
top_logprobs
integer
要返回的顶级对数概率数量(0-20)。需要 logprobs: true
top_k
integer
Top-K 采样参数(用于 Anthropic/Gemini 模型)。
response_format
object
响应格式规范。使用 {"type": "json_object"} 进入 JSON 模式。将 {"type": "json_schema", "json_schema": {...}} 视为一条基于所选模型和路由行为的尽力支持路径。
logit_bias
object
修改指定 token 出现的可能性。将 token ID(以字符串形式)映射到 -100 到 100 的偏差值。
user
string
表示您最终用户的唯一标识符,用于滥用监控。
cache_control
object
LemonData 缓存控制选项。
  • type (string): 缓存策略 - default, no_cache, no_store, response_only, semantic_only
  • max_age (integer): 缓存 TTL(秒),最大 86400

Response

id
string
补全的唯一标识符。
object
string
始终为 chat.completion
created
integer
补全创建时的 Unix 时间戳。
model
string
用于补全的模型。
choices
array
补全选项列表。每个选项包含:
  • index (integer): 选项的索引
  • message (object): 生成的消息
  • finish_reason (string): 模型停止的原因(stop, length, tool_calls
usage
object
token 使用统计。
  • prompt_tokens (integer): 提示中的 token 数
  • completion_tokens (integer): 补全中的 token 数
  • total_tokens (integer): 使用的总 token 数
curl -X POST "https://api.lemondata.cc/v1/chat/completions" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user", "content": "Hello!"}
    ],
    "temperature": 0.7,
    "max_tokens": 1000
  }'

Multimodal Example

{
  "model": "gemini-2.5-pro",
  "messages": [
    {
      "role": "user",
      "content": [
        { "type": "text", "text": "Describe this video briefly." },
        { "type": "video_url", "video_url": { "url": "https://example.com/demo.mp4" } }
      ]
    }
  ],
  "max_tokens": 64
}
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1706000000,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 9,
    "total_tokens": 29
  }
}