cURL 示例

使用 cURL 调用模型列表、Chat Completions 与 Anthropic Messages 接口。

cURL 适合验证 Key、排查网络问题和复现请求。下面的示例可直接改成你的模型与消息内容。

获取模型列表

curl https://api.sublyx.org/v1/models \
  -H "Authorization: Bearer sk-sublyx-example"

创建对话

curl https://api.sublyx.org/v1/chat/completions \
  -H "Authorization: Bearer sk-sublyx-example" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-terra",
    "messages": [
      {"role": "system", "content": "回答保持简洁。"},
      {"role": "user", "content": "什么是 SSE?"}
    ]
  }'

启用流式输出

curl -N https://api.sublyx.org/v1/chat/completions \
  -H "Authorization: Bearer sk-sublyx-example" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-terra",
    "stream": true,
    "messages": [
      {"role": "user", "content": "逐步解释二分查找。"}
    ]
  }'

-N 会关闭 cURL 的输出缓冲,便于实时查看 SSE 数据。

查看响应头

curl -i https://api.sublyx.org/v1/models \
  -H "Authorization: Bearer sk-sublyx-example"

排查问题时记录 HTTP 状态码、响应体中的错误类型,以及服务返回的请求标识;不要公开包含完整 Key 的命令历史或日志。

本页目录