OpenAI 协议兼容 · 国内直连 · 无需海外信用卡。把 base URL 一换,存量代码零迁移。
图片生成现已可用,更多接口持续接入中
文字生图,支持多种分辨率,秒级出图,b64 直返
统一对话接口,跨厂商一次接入,按场景智能路由
多语言向量化,构建语义搜索 / RAG 数据底座
面向 IDE 插件 / Agent 的低延迟代码补全接口
已经在用 OpenAI SDK?把 base URL 和 key 换掉,代码不动
# 文字生图(gpt-image-1) curl https://agg-api.code2ai.codes/v1/images/generations \ -H "Authorization: Bearer sk-agg-xxxxxxxx" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-1", "prompt": "一只橘猫坐在木桌上,写实风格", "n": 1, "size": "1024x1024", "response_format": "b64_json" }'
# pip install openai from openai import OpenAI import base64 client = OpenAI( base_url="https://agg-api.code2ai.codes/v1", api_key="sk-agg-xxxxxxxx", ) resp = client.images.generate( model="gpt-image-1", prompt="一只橘猫坐在木桌上,写实风格", n=1, size="1024x1024", response_format="b64_json", ) img_bytes = base64.b64decode(resp.data[0].b64_json) with open("cat.png", "wb") as f: f.write(img_bytes)
// npm install openai import OpenAI from "openai"; import fs from "node:fs"; const client = new OpenAI({ baseURL: "https://agg-api.code2ai.codes/v1", apiKey: "sk-agg-xxxxxxxx", }); const resp = await client.images.generate({ model: "gpt-image-1", prompt: "一只橘猫坐在木桌上,写实风格", n: 1, size: "1024x1024", response_format: "b64_json", }); fs.writeFileSync("cat.png", Buffer.from(resp.data[0].b64_json, "base64"));
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 固定 gpt-image-1 |
prompt | string | 是 | 图片描述,中英文皆可 |
n | integer | 否 | 生成张数,目前仅支持 1,默认 1 |
size | string | 否 | 1024x1024 / 1024x1536 / 1536x1024,默认 1024x1024 |
response_format | string | 否 | 目前仅支持 b64_json |
| 字段 | 类型 | 说明 |
|---|---|---|
created | integer | Unix 时间戳 |
data[].b64_json | string | 图片 base64 编码(PNG) |
当前为内测期,留下邮箱我们会在开放后第一时间私信你接入凭证。当前候补用户首月免费。
还有其它疑问?回到首页底部联系我们
base_url 改成 https://agg-api.code2ai.codes/v1、API Key 换成 sk-agg-*,业务代码完全不动。响应字段、错误码、SSE 流式协议保持一致。