cURL
cURL 是从命令行测试 HiAPI 端点最快的方式。
所有请求都需要 Authorization 请求头:
-H "Authorization: Bearer YOUR_API_KEY"curl -X POST https://api.hiapi.ai/v1/images/generations \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "qwen-image-2.0", "prompt": "一张春季促销海报,包含中文标题", "size": "2048x2048" }'聊天补全(对话式生图)
Section titled “聊天补全(对话式生图)”curl -X POST https://api.hiapi.ai/v1/chat/completions \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "Nano-Banana", "stream": false, "messages": [{"role": "user", "content": "draw a cute cat"}], "extra_body": { "google": { "image_config": { "aspect_ratio": "1:1", "image_size": "1K" } } } }'curl -X POST https://api.hiapi.ai/v1/videos \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "wan2.7-t2v", "prompt": "sunset timelapse over mountains", "size": "1920*1080", "seconds": "5" }'curl https://api.hiapi.ai/v1/dashboard/billing/usage \ -H "Authorization: Bearer YOUR_API_KEY"- 使用
jq格式化输出响应:curl ... | jq . - 将 API 密钥保存为环境变量:
export HIAPI_KEY=sk-...,然后使用-H "Authorization: Bearer $HIAPI_KEY"