AIGate 模型价格 接入文档 登录注册

基本说明

OpenAI 兼容(所有厂商的对话模型)

支持 /v1/chat/completions、/v1/completions、/v1/responses、/v1/embeddings、/v1/images/generations、/v1/models

from openai import OpenAI
client = OpenAI(base_url="http://localhost:8080/v1", api_key="sk-...")
r = client.chat.completions.create(model="deepseek-chat", messages=[{"role": "user", "content": "你好"}], stream=True)
for c in r:
    print(c.choices[0].delta.content or "", end="") if c.choices else None

Anthropic Messages

import anthropic
client = anthropic.Anthropic(base_url="http://localhost:8080", api_key="sk-...")
msg = client.messages.create(model="claude-sonnet-4-5", max_tokens=1024, messages=[{"role": "user", "content": "你好"}])

Google Gemini

curl "http://localhost:8080/v1beta/models/gemini-2.5-flash:generateContent" \
  -H "x-goog-api-key: sk-..." -H "Content-Type: application/json" \
  -d '{"contents":[{"parts":[{"text":"你好"}]}]}'

图像生成(DALL·E / FLUX)

curl http://localhost:8080/v1/images/generations -H "Authorization: Bearer sk-..." -H "Content-Type: application/json" \
  -d '{"model":"flux-pro-1.1","prompt":"a cat in space","size":"1024x1024","n":1}'

错误码

状态码含义
401Key 无效 / 已禁用 / 已过期
402余额不足或 Key 额度用尽
403无权使用该模型、IP 不在白名单或账户被禁用
404模型不存在或未开放
429请求过于频繁
502/503上游暂时不可用(已自动尝试其它渠道,预扣已退回)