身份验证
了解如何使用 API 密钥和令牌进行身份验证。
请求头示例
Authorization: Bearer YOUR_API_KEY
重要提示: 请妥善保管您的 API 密钥,不要在客户端代码中暴露。
速率限制
免费层
1,000
每天 1000 次请求
每分钟限制
60
每分钟 60 次请求
Token 限制
1M
每次请求最多 100 万 tokens
API 端点
POST
/v1/generate
Generate text using Gemini models
请求
curl -X POST \
https://api.gemini-guide.com/v1/generate \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "Your prompt here"}'
响应
{
"status": "success",
"data": {
"response": "Generated content...",
"model": "gemini-pro",
"usage": {
"tokens": 150
}
}
}
POST
/v1/chat
Start or continue a chat conversation
请求
curl -X POST \
https://api.gemini-guide.com/v1/chat \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"prompt": "Your prompt here"}'
响应
{
"status": "success",
"data": {
"response": "Generated content...",
"model": "gemini-pro",
"usage": {
"tokens": 150
}
}
}
GET
/v1/models
List available models
请求
curl -X GET \
https://api.gemini-guide.com/v1/models \
-H "Authorization: Bearer YOUR_API_KEY" \
响应
{
"status": "success",
"data": {
"response": "Generated content...",
"model": "gemini-pro",
"usage": {
"tokens": 150
}
}
}
GET
/v1/usage
Get API usage statistics
请求
curl -X GET \
https://api.gemini-guide.com/v1/usage \
-H "Authorization: Bearer YOUR_API_KEY" \
响应
{
"status": "success",
"data": {
"response": "Generated content...",
"model": "gemini-pro",
"usage": {
"tokens": 150
}
}
}
错误代码
400Bad Request
Invalid request parameters
401Unauthorized
Invalid or missing API key
429Too Many Requests
Rate limit exceeded
500Internal Server Error
Server error occurred