FoxAPI 提供兼容 OpenAI 标准的统一 API 网关。您可以通过一个 API Key 和 Base URL 集成任何 AI 模型。
Base URL: https://api.foxapi.cc
第一步:获取 API Key
- 登录 FoxAPI 控制台
- 找到 API Keys 管理页面
- 点击「创建新 Key」
- 复制生成的 Key(以
sk- 开头)
请妥善保管您的 API Key,切勿在客户端代码或公开仓库中暴露。
第二步:发送第一个请求
curl --request POST \
--url https://api.foxapi.cc/v1/images/generations \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "gemini-3.1-flash-image-preview",
"prompt": "一只猫在草地上玩耍"
}'
import requests
response = requests.post(
"https://api.foxapi.cc/v1/images/generations",
headers={
"Authorization": "Bearer YOUR_API_KEY",
"Content-Type": "application/json"
},
json={
"model": "gemini-3.1-flash-image-preview",
"prompt": "一只猫在草地上玩耍"
}
)
result = response.json()
task_id = result["id"]
print(f"任务已创建: {task_id}")
const response = await fetch('https://api.foxapi.cc/v1/images/generations', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gemini-3.1-flash-image-preview',
prompt: '一只猫在草地上玩耍'
})
});
const result = await response.json();
console.log('任务已创建:', result.id);
第三步:查询任务结果
大多数生成类 API 使用异步处理模式。使用返回的任务 ID 查询结果:
curl --request GET \
--url https://api.foxapi.cc/v1/tasks/YOUR_TASK_ID \
--header 'Authorization: Bearer YOUR_API_KEY'
当 status 变为 completed 时,output 字段将包含生成的内容。
第四步:使用文本模型
FoxAPI 完全兼容 OpenAI 的 Chat Completions API:
curl --request POST \
--url https://api.foxapi.cc/v1/chat/completions \
--header 'Authorization: Bearer YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"model": "claude-sonnet-4-6",
"messages": [
{"role": "user", "content": "你好,你是谁?"}
]
}'
认证方式
所有接口均需要使用 Bearer Token 进行认证。在每个请求中添加以下请求头:
Authorization: Bearer YOUR_API_KEY
下一步
集成指南
连接 Claude Code CLI 和其他工具