Skip to content

cURL 调用示例

基础对话

bash
curl https://api.echoly.cn/v1/chat/completions \
  -H "Authorization: Bearer sk-你的Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "kimi-k2.6",
    "messages": [
      { "role": "user", "content": "用一句话解释什么是递归" }
    ]
  }'

流式输出

bash
curl https://api.echoly.cn/v1/chat/completions \
  -H "Authorization: Bearer sk-你的Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-terra",
    "messages": [
      { "role": "system", "content": "你是一个 Python 编程专家" },
      { "role": "user", "content": "写一个冒泡排序" }
    ],
    "stream": true
  }'

多轮对话

bash
curl https://api.echoly.cn/v1/chat/completions \
  -H "Authorization: Bearer sk-你的Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-terra",
    "messages": [
      { "role": "user", "content": "1+1等于几?" },
      { "role": "assistant", "content": "1+1等于2。" },
      { "role": "user", "content": "那再加上3呢?" }
    ]
  }'

图片生成

bash
curl https://api.echoly.cn/v1/images/generations \
  -H "Authorization: Bearer sk-你的Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "一只穿着太空服的柴犬,数字绘画风格",
    "n": 1,
    "size": "1024x1024"
  }'

使用 Claude 协议

bash
curl https://api.echoly.cn/v1/messages \
  -H "x-api-key: sk-你的Key" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.6-terra",
    "max_tokens": 1024,
    "messages": [
      { "role": "user", "content": "你好" }
    ]
  }'

使用 Gemini 协议

bash
curl "https://api.echoly.cn/v1beta/models/gpt-5.6-terra:generateContent?key=sk-你的Key" \
  -H "Content-Type: application/json" \
  -d '{
    "contents": [
      { "parts": [{ "text": "你好" }] }
    ]
  }'

常用参数

参数说明示例
model模型名"kimi-k2.6"
messages对话消息数组[{"role":"user","content":"hi"}]
stream流式输出true / false
temperature随机性 0~20.7
max_tokens最大输出长度4096
top_p核采样1.0

基于 New API 构建