API 文档

使用 InferGate API

使用 OpenAI 兼容 Base URL,并始终把完整 API Key 保存在服务端。首先查询当前账号可以使用哪些模型。

Base URL

https://api.useinfergate.com/v1

API Key 仅保存在服务端。

不要把完整 InferGate API Key 写入浏览器代码、移动端安装包、截图、支持工单或源码仓库。

1. 获取账号模型列表

先调用该接口,只选择返回结果中的模型。

cURL
curl https://api.useinfergate.com/v1/models \
  -H "Authorization: Bearer $INFERGATE_API_KEY"

2. Responses API

cURL
curl https://api.useinfergate.com/v1/responses \
  -H "Authorization: Bearer $INFERGATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.4-mini","input":"只回复:ready"}'
JavaScript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.INFERGATE_API_KEY,
  baseURL: "https://api.useinfergate.com/v1",
});

const response = await client.responses.create({
  model: "gpt-5.4-mini",
  input: "只回复:ready",
});

console.log(response.output_text);
Python
import os
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["INFERGATE_API_KEY"],
    base_url="https://api.useinfergate.com/v1",
)

response = client.responses.create(
    model="gpt-5.4-mini",
    input="只回复:ready",
)

print(response.output_text)

3. Chat Completions

cURL
curl https://api.useinfergate.com/v1/chat/completions \
  -H "Authorization: Bearer $INFERGATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.4-mini","messages":[{"role":"user","content":"只回复:ready"}]}'

设置 "stream": true 可接收 Server-Sent Events 流。

4. 图像生成

gpt-image-2 需要付费模型权益。

cURL
curl https://api.useinfergate.com/v1/images/generations \
  -H "Authorization: Bearer $INFERGATE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-image-2","prompt":"白纸上的黑色墨线网络网关结构图"}'

权限与可用性错误

HTTP错误码含义
403access_denied该账号尚未为此模型完成符合条件的真实充值。
503model_unavailable所请求模型明确不可用,不应静默替换成其他模型。

充值余额用完后,已获得的付费模型权益仍保留;当不存在其他有效实付订单时,全额退款或拒付可能撤销权益。InferGate 与 OpenAI 及其他模型提供商相互独立。