Skip to main content
POST
创建消息
Use the Anthropic Messages format to generate text with Claude from text or image inputs. Send requests to https://geekai.co/api/v1/messages (mainland China) or https://geekai.dev/api/v1/messages (international). Set the bearer token to your GeekAI API key. Request and response parameters follow the Claude Messages API.

Authorizations

Authorization
string
header
required

API认证token

Headers

anthropic-version
string

请求使用的 Anthropic API 版本。

Example:

"2026-10-21"

anthropic-beta
string[]

以逗号分隔的 Beta 功能标识。示例值并非封闭枚举。

anthropic-user-profile-id
string

将请求归属到此用户配置。

anthropic-workspace-id
string

凭据可访问多个工作区时用于选择工作区。若凭据绑定特定工作区,传入值必须与之匹配。

Body

application/json
max_tokens
integer
required

最多生成的 token 数。设为 0 可预热提示缓存而不生成文本;上限取决于模型。

Required range: x >= 0
messages
object[]
required

按顺序传入对话轮次。无状态请求需要包含历史消息;连续的 user 或 assistant 同角色消息会被合并。能否预填 assistant 回复取决于模型。

Maximum array length: 100000
model
string
required

生成回复所用的模型 ID。

Example:

"claude-opus-5-5"

billing_policy
object | null

将费用计入本组织(self)或 anthropic-user-profile-id 指定的已授权客户(user_profile)。

cache_control
object | null

在请求中最后一个可缓存的内容块上设置缓存断点。

compaction
object | null

将对话压缩为可在后续轮次使用的 compaction 块。不可与 context_management 同时使用。

container

复用容器 ID,或指定需要加载的技能。

context_management
object | null

配置上下文编辑策略,例如清除早期工具结果。

diagnostics
object | null

配置本次请求的诊断信息。

fallback_credit_token

上次拒绝响应返回的抵扣令牌,须在五分钟内由同一组织和工作区使用。对象形式需要 fallback-credit-2026-07-01,不可与 fallbacks 同用。

fallbacks

因策略拒绝时依次尝试的备用模型;传入 default 使用服务端策略。支持情况取决于模型。

inference_geo
string | null

请求使用的推理地域。

mcp_servers
object[]

本次请求可用的远程 MCP 服务器。

Maximum array length: 20
metadata
object

与请求关联的元数据。

output_config
object

配置输出努力程度、结构化输出格式或任务预算。

service_tier
enum<string>

自动使用可用的优先容量(auto),或仅使用标准容量。

Available options:
auto,
standard_only
speed
enum<string> | null

在模型支持时选择标准或快速推理。

Available options:
standard,
fast
stop_sequences
string[]

遇到指定序列时停止生成,匹配结果在 stop_sequence 中返回。

stream
boolean

设为 true 时返回 SSE 事件流,而不是单条 JSON 消息。

system

以字符串或文本块数组传入的系统指令。

thinking
object

选择模型支持的思考模式。adaptive 由 Claude 决定;enabled 需要至少 1,024 个预算 token,思考消耗计入 max_tokens。

thread
object

创建服务端对话状态,或使用上一条回复 ID 继续线程,此时仅需提交新轮次。

tool_choice
object

允许自动选择、要求调用工具、指定一个工具或禁用工具。

tools
object[]

声明客户端或服务端工具。收到客户端 tool_use 后,使用其 input 调用指定工具,再返回引用该调用 ID 的 tool_result。

output_format
object | null
deprecated

已弃用。请通过 output_config.format 指定 JSON 输出 schema。

temperature
number

响应中注入的随机性温度

默认值为 1.0。范围从 0.0 到 1.0。使用 temperature 更接近 0.0 进行分析 / 多项选择,而更接近 1.0 进行创造性和生成性 任务。

注意,即使 temperature 为 0.0,结果也不会完全确定。 旧版采样选项,所附 Beta 文档未列出;支持情况取决于模型和 API 版本。

Required range: 0 <= x <= 1
Example:

1

top_k
integer

仅从每个后续标记的前 K 个选项中进行采样。

用于删除“长尾”低概率响应。 了解更多技术细节 这里.

仅推荐用于高级用例。通常,您只需要使用 temperature。 旧版采样选项,所附 Beta 文档未列出;支持情况取决于模型和 API 版本。

Required range: x >= 0
Example:

5

top_p
number

使用核采样。 在核采样中,我们按照概率递减的顺序计算每个后续 token 的所有选项的累积分布,并在达到 top_p 指定的特定概率时将其截断。您应该只更改 temperature 或 top_p 中的一个,而不是同时更改两者。 仅推荐用于高级用例。通常,您只需要使用 temperature。 旧版采样选项,所附 Beta 文档未列出;支持情况取决于模型和 API 版本。

Required range: 0 <= x <= 1
Example:

0.7

Response

非流式调用返回完整 JSON 消息;stream 为 true 时返回 SSE 帧序列。开始推流后的失败通过 error 事件传递,不会更改 HTTP 状态。

type
any
default:message
required

固定为 message。

id
string
required

消息唯一标识。

container
object | null
required

本次请求使用的容器信息(如有)。

content
object[]
required

有序的输出内容块,如文本、工具调用或思考内容。

context_management
object | null
required

处理请求时已执行的上下文编辑。

diagnostics
object | null
required

与本次请求关联的诊断结果(如有)。

model
string
required

实际生成回复的模型。

Example:

"claude-opus-5-5"

role
any
default:assistant
required

生成的消息角色为 assistant。

stop_details
object | null
required

有关停止原因的补充信息(如有)。

stop_reason
enum<string> | null
required

生成停止的原因;结束前可能为 null。

Available options:
end_turn,
max_tokens,
stop_sequence,
tool_use,
pause_turn,
compaction,
refusal,
model_context_window_exceeded
stop_sequence
string | null
required

触发停止的自定义序列;未触发时为 null。

usage
object
required

用量及计费数据。输入 token 总量包括 input_tokens、cache_creation_input_tokens 和 cache_read_input_tokens。

input_transformations
object[] | null

服务端对输入块执行的变换。