使用 API Key 调用我们的封面生成服务
Authorization: Bearer YOUR_API_KEY或者直接使用 API Key(不推荐):
Authorization: YOUR_API_KEY提示: 您可以在 Dashboard → API Keys 页面创建和管理您的 API Keys
POST /api/generatecurl -X POST https://your-domain.com/api/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"description": "今天天气真好"
}'const response = await fetch('https://your-domain.com/api/generate', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json',
},
body: JSON.stringify({
description: '今天天气真好'
})
});
const data = await response.json();
console.log(data.data.coverUrl);import requests
url = 'https://your-domain.com/api/generate'
headers = {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
}
data = {
'description': '今天天气真好'
}
response = requests.post(url, headers=headers, json=data)
result = response.json()
print(result['data']['coverUrl'])| 参数 | 类型 | 必需 | 说明 |
|---|---|---|---|
| description | string | 是 | 要生成封面的文字描述,最大长度 500 字符 |
{
"success": true,
"data": {
"coverUrl": "https://your-domain.com/temp/1234567890-abc123.png",
"description": "今天天气真好",
"timestamp": "2024-01-01T12:00:00.000Z"
},
"meta": {
"apiVersion": "v1",
"requestId": "1234567890-abc123"
}
}| 字段 | 类型 | 说明 |
|---|---|---|
| success | boolean | 请求是否成功 |
| data.coverUrl | string | 生成的封面图片完整 URL |
| data.description | string | 描述文本(截取前50字符) |
| data.timestamp | string | 生成时间(ISO 8601 格式) |
| meta.apiVersion | string | API 版本号 |
| meta.requestId | string | 请求唯一标识符 |
| Header | 说明 |
|---|---|
| X-RateLimit-Limit | 每小时请求限制数 |
| X-RateLimit-Remaining | 当前剩余请求数 |
| X-RateLimit-Reset | 重置时间(Unix 时间戳) |
{
"error": "错误类型",
"message": "详细的错误信息"
}| 状态码 | 说明 |
|---|---|
| 400 | 请求参数错误 |
| 401 | 未授权,API Key 无效或缺失 |
| 429 | 请求频率超限 |
| 500 | 服务器内部错误 |
401 - 未授权
{
"error": "缺少认证信息",
"message": "请在请求头中添加 Authorization: Bearer <your_api_key>"
}429 - 请求频率超限
{
"error": "请求频率超限",
"message": "已达到每小时 100 次请求的限制",
"resetAt": "2024-01-01T13:00:00.000Z"
}响应头会包含 Retry-After 字段,表示需要等待的秒数
每个响应都包含速率限制相关的响应头:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 95
X-RateLimit-Reset: 1704110400提示: 如果您的应用需要更高的速率限制,请联系我们或升级您的订阅计划。