> ## Documentation Index
> Fetch the complete documentation index at: https://docs.heihuzi.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# cURL

> 已运行并检查返回内容的 cURL 示例。

先在运行环境中设置 `HEIHUZI_API_KEY`，按目标能力选择文本、Messages 或图片 Key。下列代码均经过真实请求验证，结果保存到当前目录。

## 查询模型

```bash theme={null}
curl --fail-with-body --silent --show-error --max-time 600 \
  --request GET \
  --url https://code.heihuzi.ai/v1/models \
  --header "Authorization: Bearer $HEIHUZI_API_KEY" \
  --output models.json
```

## Responses 文本

Responses 示例已于 **2026-09-13** 在当前生产接口复核，`input` 使用消息数组。

```bash theme={null}
curl --fail-with-body --silent --show-error --max-time 600 \
  --request POST \
  --url https://code.heihuzi.ai/v1/responses \
  --header "Authorization: Bearer $HEIHUZI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-5.5",
  "input": [{"role": "user", "content": "Reply with exactly API_OK."}]
}' \
  --output responses.json
```

## Messages 文本

```bash theme={null}
curl --fail-with-body --silent --show-error --max-time 600 \
  --request POST \
  --url https://code.heihuzi.ai/v1/messages \
  --header "Authorization: Bearer $HEIHUZI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "claude-sonnet-5",
  "max_tokens": 256,
  "messages": [
    {
      "role": "user",
      "content": "Reply with exactly API_OK."
    }
  ]
}' \
  --output messages.json
```

## 生成图片

```bash theme={null}
curl --fail-with-body --silent --show-error --max-time 600 \
  --request POST \
  --url https://code.heihuzi.ai/v1/images/generations \
  --header "Authorization: Bearer $HEIHUZI_API_KEY" \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "gpt-image-2.5-flare",
  "prompt": "A simple blue ceramic cup on a white background.",
  "n": 1,
  "size": "1024x1024",
  "quality": "low",
  "output_format": "png"
}' \
  --output generation.json
```

`generation.json` 中的 `data[].b64_json` 为图片 base64。[SDK 示例](/cn/integrations/openai-sdk)演示解码保存；[图像编辑](/cn/api-reference/images/gpt-image-2.5/edits)提供实测文件上传；[流式返回](/cn/api-reference/images/gpt-image-2.5/streaming)提供 cURL SSE 示例。
