Skip to content

API 说明

FoxAPI 完全兼容 OpenAI API 格式,支持任何 OpenAI 兼容客户端。

API 地址

https://foxapi.chat

认证

bash
Authorization: Bearer sk-你的Key

Chat Completions

POST https://foxapi.chat/v1/chat/completions

请求参数

参数类型必填说明
modelstring模型名称
messagesarray消息列表
streamboolean流式输出,默认 false
temperaturenumber温度 0-2,默认 1
max_tokensinteger最大输出 token

请求示例

bash
curl https://foxapi.chat/v1/chat/completions \
  -H "Authorization: Bearer sk-你的Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.4-mini",
    "messages": [
      {"role": "user", "content": "你好"}
    ]
  }'

Python 示例

python
from openai import OpenAI

client = OpenAI(
    api_key="sk-你的Key",
    base_url="https://foxapi.chat/v1"
)

response = client.chat.completions.create(
    model="gpt-5.4-mini",
    messages=[{"role": "user", "content": "你好"}]
)

print(response.choices[0].message.content)

Models

GET https://foxapi.chat/v1/models

返回可用模型列表。

Images

文生图

POST https://foxapi.chat/v1/images/generations
参数类型必填说明
modelstring默认 gpt-image-2
promptstring图片描述
ninteger数量,默认 1
sizestring尺寸,默认 1024x1024
bash
curl https://foxapi.chat/v1/images/generations \
  -H "Authorization: Bearer sk-你的Key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "一只橘猫在阳光下打盹",
    "size": "1024x1024"
  }'

图片编辑(上传参考图)

POST https://foxapi.chat/v1/images/edits

使用参考图 + 文字描述来编辑图片,支持蒙版局部编辑。

参数类型必填说明
modelstring默认 gpt-image-2
imagefile参考图片文件
promptstring编辑描述
maskfile蒙版(白色=编辑区域)
ninteger数量,默认 1
sizestring尺寸,默认 1024x1024
bash
curl https://foxapi.chat/v1/images/edits \
  -H "Authorization: Bearer sk-你的Key" \
  -F "model=gpt-image-2" \
  -F "image=@reference.png" \
  -F "prompt=把背景改成海边日落"

⚠️ 此接口使用 multipart/form-data 格式,不是 JSON。 详细文档:图片编辑教程

异步接口

异步接口先提交任务再查询结果,返回真实图片链接(非 base64),不会超时。

POST https://foxapi.chat/async/images/generations
POST https://foxapi.chat/async/images/edits
GET  https://foxapi.chat/task/{task_id}
bash
# 提交任务
curl https://foxapi.chat/async/images/generations \
  -H "Authorization: Bearer sk-你的Key" \
  -F "model=gpt-image-2" \
  -F "prompt=一只橘猫"

# 查询结果
curl https://foxapi.chat/task/{task_id}

⚠️ 使用 multipart/form-data 格式。 详细文档:异步图片生成

Billing(余额查询)

GET https://foxapi.chat/v1/dashboard/billing/subscription
GET https://foxapi.chat/v1/dashboard/billing/usage
接口说明
/subscription查询账户状态和限额信息
/usage?start_date=&end_date=查询指定时间段的已用额度
bash
# 查询账户信息
curl https://foxapi.chat/v1/dashboard/billing/subscription \
  -H "Authorization: Bearer sk-你的Key"

# 查询已用额度
curl "https://foxapi.chat/v1/dashboard/billing/usage?start_date=2026-06-01&end_date=2026-06-07" \
  -H "Authorization: Bearer sk-你的Key"

详细文档:查询余额与用量

错误码

状态码说明解决方案
200成功
401Key 无效检查 Key 是否正确
403余额不足充值后再试
429频率限制稍后重试
500服务器错误联系客服

© 2026 FoxAPI. All rights reserved.