Tài liệu APIAPI documentation
Cổng LLM tương thích OpenAI, chạy trên Cloudflare Workers ở mức hoàn toàn miễn phí. Không cần đăng ký, không cần API key — gửi request là dùng được. Trỏ SDK OpenAI sẵn có vào đây là chạy. An OpenAI-compatible LLM gateway running on Cloudflare Workers at zero cost. No signup, no API key — just send a request. Point any existing OpenAI SDK at it and it works.
Free tier & API keyFree tier & API keys
Base URL: https://api.iamzero.app/v1.
Gọi mà không gửi header Authorization thì bạn đang ở free tier. Gửi key đúng thì lên tier có key với giới hạn rộng hơn.
Base URL: https://api.iamzero.app/v1.
Call it without an Authorization header and you are on the free tier. Send a valid key to get the wider key tier.
| Free tier (không key)Free tier (no key) | Có API keyWith API key | |
|---|---|---|
| Tốc độRate | 3 request/phút mỗi IPrequests/min per IP | không giới hạn riêngno separate limit |
| Hạn mức ngàyDaily budget | 200 lượt/ngày, dùng chung cho tất cả người dùng freecalls/day, shared across all free users | chỉ giới hạn bởi trần từng modelbounded only by each model's ceiling |
max_tokens | 512 | 4096 |
| Kích thước requestRequest size | 8 KB | 32 KB |
| Model | auto, gemini-flash, llama-3.3-70b, llama-4-scout |
tất cả, kể cảall, including ling-3.0-tiny |
Gửi key sai sẽ nhận 401 chứ không tự động tụt xuống free tier — để lỗi cấu hình lộ ra thay vì bị che.
Cần key riêng (giới hạn rộng hơn) thì liên hệ chủ dịch vụ; key cấp bằng wrangler secret put LLM_API_KEYS, mỗi
consumer một key để thu hồi riêng được.
Sending a wrong key returns 401 rather than silently dropping to the free tier — a misconfiguration should
surface, not hide. For your own key with wider limits, ask the service owner; keys are issued via
wrangler secret put LLM_API_KEYS, one per consumer so they can be revoked individually.
Danh sách modelList models
GET /v1/models
Trả kèm quota còn lại hôm nay — hạn mức ở đây rất nhỏ và lệch nhau giữa các model, nên hãy đọc
x_remaining để lùi bước thay vì đâm vào 429.
Includes remaining quota for today — the ceilings here are small and uneven, so read
x_remaining and back off instead of walking into a 429.
# free tier — không cần key
curl https://api.iamzero.app/v1/models
{
"object": "list",
"data": [
{
"id": "llama-3.3-70b",
"object": "model",
"owned_by": "meta via groq",
"x_provider": "groq",
"x_upstream_model": "llama-3.3-70b-versatile",
"x_daily_ceiling": 1000,
"x_calls_today": 5,
"x_remaining": 995,
"x_note": "Nhanh nhất; trần ~1.000 req/ngày."
}
]
}
Nếu D1 không đọc được, x_calls_today trả chuỗi "unmeasured" — hệ thống này
không bao giờ điền một con số "hợp lý" thay cho số đo thật.
If D1 is unreachable, x_calls_today is the string "unmeasured" — this system
never substitutes a plausible-looking number for a measured one.
Chat completions
POST /v1/chat/completions
Tham sốParameters
| Tham sốField | KiểuType | Mô tảDescription |
|---|---|---|
model | string required | Một trong các ID ở bảng bên dưới.One of the IDs in the table below. |
messages | array required | Mỗi phần tử {role, content}, role là system | user | assistant. Phần tử cuối phải là user.
Each item is {role, content} where role is system | user | assistant. The last item must be user. |
max_tokens | integer | 1–4096, mặc định 1024.1–4096, defaults to 1024. |
stream | boolean | Chưa hỗ trợ. Đặt true sẽ nhận 400 chứ không bị treo.
Not supported. Setting true returns a 400 rather than hanging. |
Các tham số khác của OpenAI (temperature, top_p, tools…) hiện bị bỏ qua,
vì tầng provider miễn phí bên dưới không nhận chúng đồng nhất.
Other OpenAI parameters (temperature, top_p, tools…) are currently ignored,
because the free provider layer underneath does not accept them consistently.
curl
curl -X POST https://api.iamzero.app/v1/chat/completions \
-H "content-type: application/json" \
-d '{
"model": "llama-3.3-70b",
"messages": [
{"role": "system", "content": "Trả lời ngắn gọn."},
{"role": "user", "content": "Thủ đô Việt Nam?"}
],
"max_tokens": 128
}'
Python openai SDK
from openai import OpenAI
client = OpenAI(
base_url="https://api.iamzero.app/v1",
api_key="free", # free tier bỏ qua giá trị này; SDK bắt buộc phải có gì đó
)
r = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Thủ đô Việt Nam?"}],
)
print(r.choices[0].message.content)
JavaScript fetch
const r = await fetch("https://api.iamzero.app/v1/chat/completions", {
method: "POST",
headers: { "content-type": "application/json" }, // free tier: không cần key
body: JSON.stringify({
model: "auto",
messages: [{ role: "user", content: "Thủ đô Việt Nam?" }],
}),
});
const data = await r.json();
console.log(data.choices[0].message.content);
Kết quảResponse
{
"id": "chatcmpl-2f1c…",
"object": "chat.completion",
"created": 1786500000,
"model": "llama-3.3-70b",
"choices": [
{ "index": 0,
"message": { "role": "assistant", "content": "Thủ đô của Việt Nam là Hà Nội." },
"finish_reason": "stop" }
],
"x_provider": "groq",
"x_upstream_model": "llama-3.3-70b-versatile",
"x_tier": "anon"
}
usage vì tầng dưới không trả số token —
thà thiếu còn hơn trả số bịa. Và finish_reason luôn là "stop": provider miễn phí không cho biết lý do
dừng, nên đây là giá trị cố định theo schema chứ không phải thứ đo được. Đừng dựa vào nó để phát hiện câu trả lời bị cắt.
Two deliberate deviations from OpenAI: there is no usage field because the layer underneath
reports no token counts — an absent field beats an invented number. And finish_reason is always "stop":
the free providers do not report why they stopped, so it is a schema-required constant, not a measurement. Do not use it to
detect truncated answers.
Model & hạn mứcModels & limits
| ID | Chạy bằngBacked by | Đo đượcMeasured | Trần/ngàyDaily ceiling | Free tierFree tier |
|---|---|---|---|---|
auto |
thử lần lượt cả 4 lanetries all four lanes in order | 2.28s | phần còn dư của các lanewhatever the lanes have left | ✓ |
gemini-flash | gemini-flash-latest | 2.74s | 1.500 | ✓ |
llama-3.3-70b | llama-3.3-70b-versatile (Groq) | 0.48s | ~1.000 | ✓ |
ling-3.0-tiny | inclusionai/ling-3.0-tiny:free | — | 50 | cần keykey only |
llama-4-scout | @cf/meta/llama-4-scout-17b-16e-instruct | 1.03s | tính bằng Neurons (10K/ngày)metered in Neurons (10K/day) | ✓ |
Thời gian đo bằng curl từ Việt Nam ngày 2026-08-12, một lần mỗi model — là mốc tham khảo, không phải cam kết. Timings measured once per model with curl from Vietnam on 2026-08-12 — a reference point, not a guarantee.
auto: nó đi hết chuỗi
cho tới lane đầu tiên thành công.
Naming a model means no fallback. If it fails you get a 502 rather than a silent answer from a different
model — you need to know exactly who answered. For fallback use auto, which walks the chain until a lane succeeds.
Mã lỗiError codes
Lỗi trả theo shape OpenAI để SDK đọc được:Errors use the OpenAI shape so SDKs can read them:
{"error":{"message","type","code"}}
| HTTP | code | NghĩaMeaning |
|---|---|---|
| 400 | bad_json | Body không phải JSON hợp lệ.Body is not valid JSON. |
| 400 | model_not_found | ID model không có; thông báo kèm danh sách hợp lệ.Unknown model ID; the message lists the valid ones. |
| 400 | invalid_messages | Mảng rỗng, content rỗng, hoặc phần tử cuối không phải user.Empty array, empty content, or the last item is not user. |
| 400 | invalid_role | Role ngoài system/user/assistant.Role outside system/user/assistant. |
| 400 | invalid_max_tokens | Không phải số nguyên 1–4096.Not an integer in 1–4096. |
| 400 | stream_unsupported | Đã gửi stream: true.You sent stream: true. |
| 400 | model_not_available_anonymously | Model có thật nhưng chỉ mở cho tier có key (trần quá nhỏ để chia cho free tier).The model exists but is key-only (its ceiling is too small to share with the free tier). |
| 429 | anon_rate_limited | Free tier: quá 3 request/phút từ IP của bạn. Chờ một phút.Free tier: more than 3 requests/min from your IP. Wait a minute. |
| 429 | anon_budget_reached | Free tier đã dùng hết 200 lượt chung của ngày hôm nay.The free tier's shared 200 calls for today are used up. |
| 503 | anon_disabled | Chủ dịch vụ đã tạm tắt free tier; cần key.The owner has temporarily turned the free tier off; a key is required. |
| 405 | method_not_allowed | Sai phương thức — /v1/models chỉ nhận GET, /v1/chat/completions chỉ nhận POST.Wrong method — /v1/models is GET-only, /v1/chat/completions is POST-only. |
| 401 | invalid_api_key | Thiếu hoặc sai key.Missing or wrong key. |
| 413 | context_too_large | Tổng nội dung vượt 32.768 bytes.Total content exceeds 32,768 bytes. |
| 429 | daily_ceiling_reached | Model đã hết suất hôm nay. Đổi model hoặc chờ sang ngày (theo giờ UTC).That model is out of quota today. Switch models or wait for the UTC day to roll over. |
| 502 | http_5xx, timeout, bad_response | Nhà cung cấp phía sau lỗi. timeout = quá 8 giây.The upstream provider failed. timeout means it took over 8 seconds. |
| 503 | d1_unreachable | Không ghi được sổ đếm hạn mức nên request bị từ chối — không bao giờ gọi LLM mà không đếm.The quota ledger is unwritable, so the request is refused — an LLM call is never made without metering it. |
Giới hạn cần biết trướcConstraints worth knowing up front
- Timeout 8 giây mỗi lane. Prompt dài hoặc model chậm sẽ trả 502
timeout. 8-second timeout per lane. Long prompts or slow models come back as a 502timeout. - 32 KB nội dung và 4096 token đầu ra khi có key; free tier là 8 KB và 512 token. 32 KB of content and 4096 output tokens with a key; the free tier gets 8 KB and 512 tokens.
- Role
systemđược gấp vào tin nhắn user đầu tiên trước khi gửi đi, vì bốn nhà cung cấp miễn phí không có cách khai báo system giống nhau. Nội dung vẫn được tôn trọng, chỉ khác vị trí. Thesystemrole is folded into the first user message before dispatch, because the four free providers have no consistent system-prompt API. The content is still honoured, just repositioned. - Không lưu hội thoại. API không giữ trạng thái; mỗi request phải gửi lại toàn bộ lịch sử cần thiết. No conversation storage. The API is stateless; resend whatever history you need on every request.
- Không gửi dữ liệu nhạy cảm. Các lane miễn phí có thể dùng nội dung để huấn luyện — đừng đưa PII của khách hàng qua đây. Do not send sensitive data. Free tiers may train on your content — keep customer PII out of it.
- Mọi lượt gọi đều bị đếm trước khi gửi, kể cả lượt sau đó thất bại. Con số hạn mức vì thế là cận trên, không phải số lần thành công. Every call is metered before dispatch, including ones that then fail. Quota figures are therefore an upper bound, not a success count.
Endpoint khácOther endpoints
| Đường dẫnPath | Auth | Công dụngPurpose |
|---|---|---|
GET /health | — | Còn sống hay không.Liveness. |
GET /ready | — | Sẵn sàng chưa (có ping cơ sở dữ liệu).Readiness, including a database ping. |
POST /chat | Turnstile hoặcor Bearer | Khung chat công khai ở /ai. Khác API này: có chống lạm dụng, giới hạn chặt hơn. Backs the public chat at /ai. Unlike this API it carries abuse protection and tighter limits. |
POST /summarize | Bearer | Tóm tắt văn bản ≤3 câu, tự động chuyển lane khi lỗi. Summarise text into ≤3 sentences, with automatic lane fallback. |
GET /metrics | Bearer (chủ dịch vụ)(owner) | Mức tiêu thụ hôm nay so với trần.Today's usage against the ceilings. |