Quickstart
Get a first request through AI Setu in a few minutes.
1. Get an API key
Sign up at app.aisetu.ai (email OTP, or Google/
Microsoft SSO). Creating your first workspace mints a workspace API key —
tt_live_… in production, tt_test_… in test mode. You can create
additional keys later from the workspace's Settings → Keys tab.
New workspaces start at $0 balance. Visit the top-up link from the
dashboard before your first call, or it returns wesence.insufficient_credits.
Export it:
export AI_SETU_API_KEY=tt_live_…2. Make your first call
Every request goes to https://gateway.aisetu.ai/v1. Pick whichever of
these matches your stack — they all hit the same endpoint.
curl
curl https://gateway.aisetu.ai/v1/chat/completions \
-H "Authorization: Bearer $AI_SETU_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"messages": [{"role": "user", "content": "Hello!"}]
}'TypeScript — @ai-setu/client
The official SDK — the openai package, subclassed, with no baseURL to
set and workspace balance surfaced on every call.
npm i @ai-setu/clientimport { AiSetu } from '@ai-setu/client';
const client = new AiSetu(); // reads AI_SETU_API_KEY from env
const res = await client.chat.completions.create({
model: 'openai/gpt-4o-mini',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(res.choices[0].message.content);
console.log(client.lastBalance); // { micros, isLow, topUpUrl }TypeScript — stock openai SDK
Already using the openai package? Point its baseURL at the gateway and
change nothing else:
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.AI_SETU_API_KEY,
baseURL: 'https://gateway.aisetu.ai/v1',
});
const res = await client.chat.completions.create({
model: 'openai/gpt-4o-mini',
messages: [{ role: 'user', content: 'Hello!' }],
});
console.log(res.choices[0].message.content);Python — openai SDK
There's no dedicated AI Setu Python package yet; the stock openai Python
SDK works the same way, pointed at the gateway:
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AI_SETU_API_KEY"],
base_url="https://gateway.aisetu.ai/v1",
)
res = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "Hello!"}],
)
print(res.choices[0].message.content)3. Pick a model
openai/gpt-4o-mini above is a hard override — that exact provider serves.
You can also send a bare model id (e.g. claude-sonnet-4-5) and let AI Setu
pick the provider, or route through your own key with @<slug>/<model>. See
Models, Routing, and
BYOK.
4. Handle errors
Non-2xx responses use the OpenAI error envelope shape plus an AI Setu-specific
code. @ai-setu/client exports type guards so you don't have to parse the
envelope yourself:
import { isInsufficientCreditsError, getInsufficientCreditsDetails } from '@ai-setu/client';
try {
await client.chat.completions.create({ model: 'openai/gpt-4o-mini', messages: [...] });
} catch (err) {
if (isInsufficientCreditsError(err)) {
const { topUpUrl } = getInsufficientCreditsDetails(err);
console.error(`Out of credits. Top up at ${topUpUrl}.`);
}
}See the full list in Errors.
Next
- Routing — how AI Setu picks a provider, and what happens when one fails.
- BYOK — route through your own provider keys.
- Caching — skip the provider entirely on repeat requests.
- Agent Quickstart — wiring up an autonomous agent instead of a human-driven app.