Sub2API

Codex Setup

S3 · OpenAI protocol compatible · only base URL and API key change

Integration changes exactly two things: the Base URL and the API key. Request bodies, SDKs and response shapes stay as they are.

1. Register and sign in

New accounts receive an initial credit so you can call immediately. Top up from Balance in the console once it runs out.

2. Create an API key

Create one under API Keys in the console. The plaintext is shown exactly once, in the dialog right after creation - close it and it is gone. The list only ever shows the first 8 characters after sk-. Lost it? Revoke and create a new one.

3. Point the Base URL here

Pick any of the four forms below; it takes effect immediately.

Base URL
from openai import OpenAI

client = OpenAI(
    base_url="https://aiapigpt.com/v1",
    api_key="sk-your-sub2api-key",
)

resp = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)
print(resp.choices[0].message.content)
export OPENAI_BASE_URL=https://aiapigpt.com/v1
export OPENAI_API_KEY=sk-your-sub2api-key

codex "refactor this file"
# Any client that lets you set a custom OpenAI-compatible Base URL works (Cherry Studio, NextChat, IDE plugins, and so on).
#
#   接口类型:OpenAI / OpenAI 兼容
#   Base URL:https://aiapigpt.com/v1
#   API Key :sk-your-sub2api-key
#   模型名  :填「实时价格」页里列出的名字
curl https://aiapigpt.com/v1/chat/completions \
  -H "Authorization: Bearer sk-your-sub2api-key" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-4o", "messages": [{"role": "user", "content": "Hello"}]}'

The Python and Node SDKs are identical in shape - swap base_url and api_key.

Four things that trip people up

  1. The model name must be one this site has registered - the Live pricing page is the authoritative list. Unregistered models are not forwarded; you get "no available upstream account".
  2. Do not drop the trailing /v1 and do not add another level. The gateway only serves POST /v1/chat/completions; everything else is a 404.
  3. The plaintext API key appears exactly once. The sk-xxxx prefix in the list is only there so you can tell keys apart - calling with it returns an invalid-key error.
  4. Only the OpenAI chat completions protocol is implemented. Claude Code speaks the Anthropic protocol, so pointing it here returns 404 - use a client that accepts a custom OpenAI Base URL.

Next: the API docs →