AI gateway
One OpenAI-compatible endpoint for many models, paid per token from your ZoCloud wallet (VND, with a VAT invoice). It works with any SDK or tool that supports OpenAI (Python, JS, LangChain, n8n…): just change the base_url and use a ZoCloud key.
| Setting | Value |
|---|---|
| Base URL | https://api.zocloud.io/v1/ai |
| Key | of the form zcai_…, created in the organisation's AI section |
| Endpoints | POST /chat/completions (with streaming), POST /embeddings, GET /models |
ZoCloud decides which models are open. If the AI section says "No models are open yet.", the gateway has no model to call.
Creating a key
- AI section → Create key.
- Enter a Name (the application that will use the key) and, if you want, a Monthly limit (VND). Leave it empty for no limit; once the limit is exceeded, requests are refused.
- Click Create. Copy the key now: ZoCloud does not show it again.
Use one key per application so you can track its cost and revoke it on its own. Put the key in the service's environment variables (for example OPENAI_API_KEY), never in the code.
Revoke a key: any application still using it stops being able to call immediately.
Examples
Python
from openai import OpenAI
client = OpenAI(base_url="https://api.zocloud.io/v1/ai", api_key="zcai_...")
r = client.chat.completions.create(
model="MODEL_NAME",
messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.zocloud.io/v1/ai",
apiKey: process.env.OPENAI_API_KEY, // zcai_...
});
const stream = await client.chat.completions.create({
model: "MODEL_NAME",
messages: [{ role: "user", content: "Hello" }],
stream: true,
});
for await (const chunk of stream) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
Embeddings
e = client.embeddings.create(model="EMBEDDING_MODEL_NAME", input=["text to embed"])
curl
curl https://api.zocloud.io/v1/ai/chat/completions \
-H "Authorization: Bearer zcai_..." \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_NAME","messages":[{"role":"user","content":"Hello"}]}'
Replace MODEL_NAME with a name from the Prices table on the portal, or take one from GET https://api.zocloud.io/v1/ai/models.
Models and prices
AI section → Prices (VAT incl.): each model has an Input price (tokens you send) and an Output price (tokens you receive), per 1 million tokens, in VND, VAT included. Prices can change with the provider's prices; always check the price table on the portal.
Billing and limits
- Every request is recorded; ZoCloud aggregates them and charges the wallet about once a minute.
- If the wallet falls below the minimum balance, requests are refused with HTTP 402. Top up to keep calling.
- If a key exceeds its Monthly limit, requests are refused with HTTP 429.
- Calling a model that does not exist returns the error
ai.model_not_found. - The month's AI costs are combined into a single "AI gateway usage, …" line on the statement and the invoice (Billing).
Tracking usage
- The Keys list: last use and the cost "This month …".
- Last 30 days: by day and model, with the number of requests, input/output tokens and cost.
From an AI agent
Through zo MCP: ai_models (models and prices), create_ai_key (creates a key, optionally with a limit), ai_usage. See zo CLI and MCP server.