API reference
SeleAI API
All APIs · SDKs · Continue with SeleID (OIDC) · SeleStorage · SeleBase · Webhooks, queue, SeleMail, routing and push · SeleAI · SeleDomains search
Coming soon Version 1.0.0. One API for hosted models with a hard spend cap: a worst-case hold is reserved before every call and a request that would pass the cap is refused with 402. No Free-plan access.
Base URL
https://api.seleid.dev SeleAI base URL
Authentication and scopes
Bearer SeleAI key. Not available on the Free plan.
Rate limits and quotas
A hard spend cap: a worst-case amount is held before each call and a call that would pass the cap returns 402 spend_cap_reached.
Endpoints
GET /v1/ai/modelsModels available to your planGET /v1/ai/usageSpend, cap and meteringPOST /v1/ai/chatChat completion
GET /v1/ai/models
Models available to your plan
Authentication: required.
curl
curl -X GET "https://api.seleid.dev/v1/ai/models" \
-H "Authorization: Bearer $SELEAI_KEY"TypeScript
const res = await fetch('https://api.seleid.dev/v1/ai/models', {
method: 'GET',
headers: { Authorization: `Bearer ${process.env.SELEAI_KEY}` },
});
const data = await res.json();Python
import os, requests
res = requests.get(
"https://api.seleid.dev/v1/ai/models",
headers={"Authorization": f"Bearer {os.environ['SELEAI_KEY']}"}
)
print(res.status_code, res.text)
Example response
{
"models": [
{
"id": "MODEL_ID",
"context_tokens": 8192,
"max_output_tokens": 1024,
"price_per_million_tokens_micro_usd": {
"input": 564000,
"output": 1654000
}
}
]
}
| Status | Meaning |
|---|---|
200 | Models. |
401 | Missing, invalid or revoked API key. |
403 | Key lacks the required scope, or the account is suspended. |
GET /v1/ai/usage
Spend, cap and metering. Amounts are integer micro-USD (1 USD = 1,000,000).
Authentication: required.
curl
curl -X GET "https://api.seleid.dev/v1/ai/usage" \
-H "Authorization: Bearer $SELEAI_KEY"TypeScript
const res = await fetch('https://api.seleid.dev/v1/ai/usage', {
method: 'GET',
headers: { Authorization: `Bearer ${process.env.SELEAI_KEY}` },
});
const data = await res.json();Python
import os, requests
res = requests.get(
"https://api.seleid.dev/v1/ai/usage",
headers={"Authorization": f"Bearer {os.environ['SELEAI_KEY']}"}
)
print(res.status_code, res.text)
| Status | Meaning |
|---|---|
200 | Usage. |
401 | Missing, invalid or revoked API key. |
403 | Key lacks the required scope, or the account is suspended. |
POST /v1/ai/chat
Chat completion. Body max 64 KB, 1 to 50 messages of at most 32,000 characters. max_tokens defaults to 256. At most 2 provider attempts; each is metered.
Authentication: required.
curl
curl -X POST "https://api.seleid.dev/v1/ai/chat" \
-H "Authorization: Bearer $SELEAI_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"MODEL_ID","messages":[{"role":"user","content":"Say hello"}],"max_tokens":64}'TypeScript
const res = await fetch('https://api.seleid.dev/v1/ai/chat', {
method: 'POST',
headers: { Authorization: `Bearer ${process.env.SELEAI_KEY}`, 'Content-Type': 'application/json' },
body: JSON.stringify({
"model": "MODEL_ID",
"messages": [
{
"role": "user",
"content": "Say hello"
}
],
"max_tokens": 64
}),
});
const data = await res.json();Python
import os, requests
res = requests.post(
"https://api.seleid.dev/v1/ai/chat",
headers={"Authorization": f"Bearer {os.environ['SELEAI_KEY']}"},
json={
"model": "MODEL_ID",
"messages": [
{
"role": "user",
"content": "Say hello",
},
],
"max_tokens": 64,
}
)
print(res.status_code, res.text)
Example response
{
"id": "req_1",
"model": "MODEL_ID",
"message": {
"role": "assistant",
"content": "Hello!"
},
"usage": {
"input_tokens": 9,
"output_tokens": 3,
"attempts": 1,
"charge_micro_usd": 11
}
}
| Status | Meaning |
|---|---|
200 | Completion. |
400 | Invalid request. |
401 | Missing, invalid or revoked API key. |
402 | spend_cap_reached. |
403 | Key lacks the required scope, or the account is suspended. |
405 | Use POST. |
413 | Payload too large. |
502 | upstream_error; failed attempts are metered. |
Errors
| HTTP | Meaning |
|---|---|
400 | Invalid request. |
401 | Missing, invalid or revoked API key. |
403 | Key lacks the required scope, or the account is suspended. |
404 | Not found. |
413 | Payload too large. |
429 | Plan quota or rate limit reached. Hard stop, never an overage charge. |
The machine-readable OpenAPI 3.1 description for this API lives in the SeleID repository under docs/openapi/.