AI 服务/大语言模型

Anthropic 对话

Changed on

接口说明:Anthropic Messages API(/v1/messages)的兼容端点,支持流式输出(SSE)。请求、响应与错误格式遵循 Anthropic 规范;鉴权使用 x-api-key 头(Anthropic SDK 默认携带),已有 Anthropic SDK 只需替换 baseURL 与 API Key 即可接入,按 AiToEarn 积分计费。

调用本接口前,请先请求「对话模型列表」接口(GET /api/ai/models/chat),获取当前可用的模型列表。

post/api/ai/v1/messages

Request

Request body

modelstring required

Anthropic 渠道模型 ID。先调用「对话模型列表」接口(GET /api/ai/models/chat),选择返回结果中 channel 为 anthropic 的 data[n].name。

max_tokensinteger

最大输出 Token 数。取值范围为 1 至 9007199254740991,默认值为 32000;示例使用 64 以控制测试消耗。

Example request

{
  "messages": [
    {
      "role": "user",
      "content": "请用一句话介绍 AiToEarn。"
    }
  ],
  "model": "claude-sonnet-5",
  "max_tokens": 64
}

Response

第三方协议原生响应或 SSE 数据。不使用 AiToEarn 通用响应包裹。

Changes

    • breaking

      the // request property type changed from no type to string

    • breaking

      removed the media type application/json for the response with the status