Skip to main content
POST
/
chat
curl --request POST \
  --url https://huajune.duliday.com/api/v1/chat \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "anthropic/claude-3-7-sonnet-20250219",
  "messages": [
    {
      "role": "user",
      "content": "你好"
    }
  ]
}
'
{
  "success": true,
  "data": {
    "messages": [
      {
        "role": "user",
        "content": "<string>"
      }
    ],
    "usage": {
      "inputTokens": 123,
      "outputTokens": 123,
      "totalTokens": 123,
      "reasoningTokens": 123,
      "cachedInputTokens": 123
    },
    "tools": {
      "used": [
        "<string>"
      ],
      "skipped": [
        "<string>"
      ]
    }
  }
}

Authorizations

Authorization
string
header
required

使用 Bearer Token 进行认证,格式:Bearer YOUR_API_KEY

Body

application/json
model
string
required

模型 ID,格式:provider/model

Example:

"anthropic/claude-3-7-sonnet-20250219"

messages
object[]
required

对话消息数组。支持两种格式:

  1. AI SDK 标准格式(UIMessage):包含 role、content、parts 等完整字段,支持工具调用历史
  2. 简化格式:仅包含 {role, content},服务端会自动归一化为 UIMessage 格式
stream
boolean
default:true

是否启用流式输出。流式输出返回 text/event-stream 格式,非流式返回完整 JSON 响应。

prune
boolean
default:false

是否启用消息剪裁。启用后会根据 pruneOptions 配置自动删除历史消息以控制 token 数量。

pruneOptions
object

消息剪裁选项。当 prune=true 时生效。未指定的字段使用默认值。

systemPrompt
string

直接指定系统提示词,优先级高于 promptType。如果同时指定了 promptType,此字段优先使用。

promptType
enum<string>

系统提示词类型。从 context.systemPrompts 中查找对应的提示词。如果找不到会使用默认提示词。

Available options:
bossZhipinSystemPrompt,
bossZhipinLocalSystemPrompt,
generalComputerSystemPrompt
allowedTools
string[]

允许使用的工具名称列表。如果不指定,会根据 promptType 自动启用对应的工具集。

contextStrategy
enum<string>
default:error

上下文缺失处理策略:

  • error:缺少必需上下文时抛出错误(默认)
  • skip:缺少必需上下文时跳过该工具,继续执行
  • report:返回验证报告,不实际执行对话
Available options:
error,
skip,
report
sandboxId
string | null

E2B 沙盒 ID。使用需要沙盒的工具(如 bash、computer)时必需。可以设为 null 表示不使用沙盒。

context
object

全局上下文配置。包含各种工具可能需要的配置数据。具体字段的类型定义可通过 /config-schema 端点获取。

toolContext
object

工具特定上下文映射。键为工具名,值为该工具的特定配置。可以覆盖 context 中的同名字段。

validateOnly
boolean
default:false

仅验证模式。设为 true 时,只验证参数和上下文是否正确,不实际执行对话。返回 ValidationReport 而非对话响应。

Response

对话成功

非流式响应(stream=false)

success
boolean
Example:

true

data
object