Skip to content
Main Site News Console

Three Steps to Get Started

4All API is fully compatible with the OpenAI interface protocol. Existing OpenAI SDK / HTTP clients only need to replace the Base URL and API Key to work; in most cases, no code changes are needed.

Open api.4allapi.com to register an account and log in to the console. New users can view their balance and available models in the console after registration.

  1. Go to Tokens(API Keys) in the left menu of the console;
  2. Click New Token to set the name, quota limit, expiration time, and available model groups;
  3. After creation, copy the generated key starting with sk- and keep it safe.
Terminal window
curl https://api.4allapi.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $AIPROXY_KEY" \
-d '{
"model": "gpt-5.6",
"messages": [{"role": "user", "content": "你好,介绍一下你自己"}]
}'
from openai import OpenAI
client = OpenAI(
base_url="https://api.4allapi.com/v1",
api_key="sk-你的密钥",
)
resp = client.chat.completions.create(
model="gpt-5.6",
messages=[{"role": "user", "content": "你好,介绍一下你自己"}],
)
print(resp.choices[0].message.content)
import OpenAI from 'openai'
const client = new OpenAI({
baseURL: 'https://api.4allapi.com/v1',
apiKey: process.env.AIPROXY_KEY,
})
const resp = await client.chat.completions.create({
model: 'gpt-5.6',
messages: [{ role: 'user', content: '你好,介绍一下你自己' }],
})
console.log(resp.choices[0].message.content)