Xena AI API

Private, OpenAI-compatible AI. Cheap, fast, and cache-heavy — repeated queries are served instantly and discounted from cache.

OpenAI-compatible Streaming RAG knowledge bases Web search Rerank & OCR Moderation Tool calling Semantic cache

Quickstart

Every first API key comes with $1.00 of free usage. Create a key, then send your first request in about a minute.

1. Create an API key

Sign in at ai.xytro.site and create a key. Keys look like xena_…. Your balance is shared across all of your keys.

2. Send a request (cURL)

curl https://ai.xytro.site/v1/chat/completions \
  -H "Authorization: Bearer xena_xxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "xael-turbo",
    "messages": [{"role": "user", "content": "Hello!"}]
  }'

3. Switch from OpenAI in one line

Use your existing OpenAI client and point it at Xena:

# Python (openai package)
client = OpenAI(api_key="xena_xxxxxxxx", base_url="https://ai.xytro.site/v1")

VS Code: TokenGuard Copilot by AdGuard

TokenGuard Copilot is an OpenAI-compatible assistant inside Visual Studio Code. Point it at Xena the same way you point the OpenAI Python client at Xena.

1. Sign in and create a key

Open the Xena dashboard (https://ai.xytro.site/dashboard.html), create an API key, then copy the full xena_… string.

2. Install TokenGuard Copilot

Install TokenGuard Copilot from the VS Code Marketplace or from Open VSX. In VS Code, search for TokenGuard Copilot in the Extensions view. Cursor, Windsurf and other Open VSX forks can install it from the Open VSX registry.

If you are loading the released .vsix directly, use Extensions: Install from VSIX… in the Command Palette and select the downloaded file.

3. Add a Xena provider

Open the Command Palette (Cmd/Ctrl+Shift+P) and run TokenGuard Copilot: Open Settings. Add a provider with:

  • Name: Xena API
  • Base URL: https://ai.xytro.site/v1
  • API key: your xena_… key

TokenGuard stores the API key in VS Code SecretStorage and verifies connectivity when you add or edit the provider.

4. Add a model

In settings, add a model from the Xena provider. TokenGuard fetches the available models from GET /v1/models, so you can select xena, xael3-turbo, xael3-think, or any other enabled model. Recognised models auto-populate context-window sizes, token costs, and capabilities; custom fields can be added for anything Xena supports that the extension does not expose directly.

For per-token pricing, TokenGuard records actual prompt/completion/cached/reasoning token usage from Xena's OpenAI-compatible usage response fields. Set the per-1M input/output rates (for example, $0.10 / $0.15 for xena) so the extension's local cost estimate matches the API dashboard.

5. Use it inside Copilot Chat

Open Copilot Chat and select the Xena model from TokenGuard in the model picker. TokenGuard then sends chat traffic to POST /v1/chat/completions. A valid key returns 200; an invalid one returns 401; a $0 balance returns 402. For richer context in editor requests, attach source files with TokenGuard's built-in context actions - Xena handles them like normal chat messages.

. A valid key returns 200; an invalid one returns 401; a $0 balance returns 402. For richer context in editor requests, attach source files with TokenGuard's built-in context actions - Xena handles them like normal chat messages.. A valid key returns 200; an invalid one returns 401; a $0 balance returns 402. For richer context in editor requests, attach source files with TokenGuard's built-in context actions — Xena handles them like normal chat messages.

Authentication

Authenticate with your API key in the Authorization: Bearer header:

Authorization: Bearer xena_xxxxxxxx

Missing or invalid keys return 401. A 0 balance returns 402 (insufficient balance).

Keys can be bound with a default system prompt and a default knowledge base so every request made with that key automatically uses them — configure via the dashboard or PATCH /v1/keys/:key.

Models & pricing

Per-token: a request costs prompt_tokens × input rate + completion_tokens × output rate, quoted in USD per 1M tokens. All prices are in USD. Live rates for every model: GET /v1/models and GET /v1/pricing.

API IDModelContextUSD / 1M tokens (in / out)Notes
xenaXena ★ FLAGSHIP64K$0.15 / $0.30Vision · reasoning · the tuned flagship
xena-proXena Pro128K$0.25 / $0.50Vision · reasoning · premium
xena2-proXena2 Pro1M$0.50 / $0.75Vision · reasoning · 1M context
xael3-turboXael Turbo256K$0.17 / $0.50General purpose, no reasoning step
xael3-thinkXael Think1M$0.20 / $0.75Vision · reasoning · mid
xael3-thinkXLXael Think XL1M$0.30 / $0.80Vision · reasoning · highest
yoshi2-coderYoshi Coder256K$0.20 / $0.75Vision · coding, fast
yoshi2-coder-plusYoshi Coder Plus1M$0.50 / $1.00Vision · coding, stronger
yoshi2-coder-maxYoshi Coder Pro1M$0.75 / $1.75Vision · coding, highest capability
xael3-embedXael Embeddings8K$0.02 / $0.00Embeddings · 768-dim · not a chat model
wallyWALLY · auto-route1M25% offPicks the model for the request and bills 25% below it — never dearer than choosing directly
zora-turboZora Imagen Turbo—$0.0300 per imageImage generation · fastest · drafts
zoraZora Imagen—$0.0400 per imageImage generation · balanced
zora-vectorsZora Vectors—$0.0500 per imageVector artwork · logos and glyphs
zora-plusZora Imagen Plus—$0.0800 per imageImage generation · enhanced prompt
zora-conceptsZora Concepts—$0.1000 per imageConcept art · highest quality
yoshi2-voiceYoshi Voice—$0.0300 per minuteText-to-speech · billed per minute

Per-token pricing. There is no per-request band, size tier or surcharge. A request costs exactly what the arithmetic says, and GET /v1/price?model=xena&prompt_tokens=1200&completion_tokens=300 returns the same number the charger uses. GET /pricing.txt prints the full sheet.

Two different caches, two different prices. A request answered from your account's own semantic response cache is billed at 5% of the normal price — a 95% discount. An identical request (same model, same full message list, same output limit) always hits; a re-worded version of the same question hits when our small local decider model confirms it is the same question, and that decision never leaves the machine. Every model uses this pool, coding models included — but an answer that contains code is never stored, and an entry that contains code is deleted rather than served, so the pool can never hand you a stale snippet. Answers are per account and are never served to another account, the pools for the web chat and the API are separate, and requests using tools, a knowledge base, attachments or a custom system prompt are never cached. Separately, when the provider reports that part of the prompt came from its own prefix cache: every cached token bills at 10% of the normal input price, proportionally across the whole prompt: normal × (fresh + cached×0.10 + completion) / (prompt + completion). The discount is per TOKEN, not per request — every cached token gets the 10% rate and every fresh one pays full price, so there is no threshold to fall short of and no cliff at the boundary. In an agentic run, continuations after a tool call bill at 10%, because that context was already charged once — and the two discounts never multiply: where the provider also reports cached tokens the higher of the two applies, so a continuation is never billed below the price its own provider cache implies.

All models listed below are publicly available. Live availability, limits and pricing are returned by GET/v1/models and GET/v1/pricing.

List live models and pricing via GET/v1/models and GET/v1/pricing.

Chat completions

POST/v1/chat/completions — generate a chat completion. Rate limit: 90 req/min per key (and 500 req/min per account). Every response carries x-ratelimit-limit, x-ratelimit-remaining and x-ratelimit-window.

Request body

FieldTypeDescription
modelstringOne of the model IDs above (default xael-turbo).
messagesarrayRequired. Chat messages (system/user/assistant).
streamboolStream tokens as SSE (see below).
temperaturenumberSampling temperature. Defaults per model.
promptstring/objectCustom system prompt — a saved preset name, inline text, or {"content":"…"}. Overrides any system message.
response_formatobjectForce JSON: {"type":"json_object"}.
tools / tool_choicearray / stringFunction/tool calling (OpenAI-compatible).
ragobjectAttach a knowledge base: {"kb":"kb_…"}. Sources returned as rag.sources.

Response

Response shape is OpenAI-compatible. Xena adds helpful fields:

  • cached: true — served from your account's response cache (billed at 5%, a 95% discount).
  • semantic: true + similarity — served from a re-worded version of the same question, after our local decider model confirmed both ask the same thing. Billed at the same 5%.
  • reasoning_content — the model's reasoning/thinking text (Think models).
  • rag.sources — cited knowledge-base excerpts.
  • fallback — served by a fallback model.

Streaming

Set "stream": true to receive tokens as an SSE stream of data: chunks, ending with data: [DONE]. Each chunk is an OpenAI-format completion chunk with choices[0].delta.content (and delta.reasoning_content for Think models).

curl https://ai.xytro.site/v1/chat/completions \
  -H "Authorization: Bearer xena_xxxxxxxx" \
  -d '{"model":"xael-turbo","stream":true,"messages":[{"role":"user","content":"hi"}]}'

JSON mode

Force structured output with response_format:

# Python
resp = client.chat.completions.create(
  model="xael-turbo",
  response_format={"type": "json_object"},
  messages=[{"role":"user","content":"Return JSON: {\"name\": , \"age\": }"}],
)

Tool calling

Pass tools (OpenAI function schemas) and optionally tool_choice. The model emits tool_calls in the assistant message. Turbo is the reliable tool-calling model; Think/Think XL tool requests are auto-routed to Turbo.

Caching

A request answered from cache bills at 5% of the normal request price (a 95% discount) and comes back in single-digit milliseconds. Exact repeats always hit. A re-worded version of the same question hits only when our small local decider model says the two requests need the same answer — a similarity score never decides on its own, and the decider runs on our own hardware, so the question is never sent anywhere to be compared.

Every model may use the pool; no code comes out of it. The coding models are included, because most of what is asked of them is still a question with a prose answer. But an answer that contains code — fenced, indented or bare — is never stored, and any stored entry whose answer looks like code is deleted the moment it is read instead of being served.

Two hits in every ten are regenerated (and the stored answer replaced) so a repeated question keeps getting a current answer instead of a frozen one; those requests bill normally.

  • Clearing the cache wipes your cached history. Only your cache is affected.
  • Use POST/v1/cache/clear to clear it (dashboard: Clear Cache).
  • GET/v1/cache/stats shows the live counters and, per surface, how many answers you have stored.

RAG knowledge bases

Upload documents, then chat over them with citations. RAG pipelines you over your own data — hosted on Xytro hardware.

1. Create a KB

curl -X POST https://ai.xytro.site/v1/rag/kbs \
  -H "Authorization: Bearer xena_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"name":"Product docs"}'

2. Add documents

curl -X POST https://ai.xytro.site/v1/rag/kbs/kb_xxx/documents \
  -H "Authorization: Bearer xena_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"text":"Xena AI is built by Xytro Labs and runs on our own hardware."}'

Plain text is auto-chunked and embedded. You can pass documents (array of {text, id}) to tag sources.

3. Query (with citations)

curl -X POST https://ai.xytro.site/v1/rag/query \
  -H "Authorization: Bearer xena_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"kb":"kb_xxx","query":"Who builds Xena AI?"}'

Returns an answer plus sources with excerpts and relevance scores. You can also attach the KB directly to a chat via rag: {"kb": …}.

Search, rerank & OCR

Four endpoints that turn the API into a retrieval stack rather than just a model behind a URL. Each is unit priced — the price on the sheet is what the bill charges. Everything below is also listed machine-readably at GET /v1/capabilities.

POST/v1/web/search

Our own hosted search chain — self-hosted first, with a fallback chain behind it. Returns ranked sources and the page text they came from, so you do not pay a second round trip per result. $0.0015 per search.

curl -X POST https://ai.xytro.site/v1/web/search \
  -H "Authorization: Bearer xena_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"query": "who won the 2024 super bowl", "max_results": 3}'

→ {sources:[{title,url}], text, usage:{searches,usd}}. Set include_text:false when you only want the ranked URLs.

POST/v1/rerank

The half of retrieval a vector store cannot do: a cross-encoder puts the right candidate first. $0.0005 per 10 documents (rounded up).

curl -X POST https://ai.xytro.site/v1/rerank \
  -H "Authorization: Bearer xena_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"query":"What is the capital of France?","documents":[
        "Paris is the capital of France.","Berlin is in Germany.","Bananas are yellow."],
      "top_n":2}'

→ {results:[{index,relevance_score}], usage:{documents,usd}}, best first.

POST/v1/ocr

PDFs and images to per-page markdown, ready to ingest into a knowledge base. $0.006 per page.

curl -X POST https://ai.xytro.site/v1/ocr \
  -H "Authorization: Bearer xena_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"url":"https://example.com/report.pdf"}'

Also accepts file_id and base64, or the full document object. → {pages:[{index,markdown}], usage:{pages,usd}}.

POST/v1/moderations

The same content gate the web chat uses, in front of your own pipeline: child safety, sexual content, non-consensual imagery, illegal activity, hate, self-harm and graphic violence. $0.0001 per request.

curl -X POST https://ai.xytro.site/v1/moderations \
  -H "Authorization: Bearer xena_xxxxxxxx" -H "Content-Type: application/json" \
  -d '{"input":["How do I bake bread?","I will kill you"]}'

→ {results:[{flagged,categories,category_scores,label,reason}]}, one per input, in order.

Embeddings

POST/v1/embeddings — generate xael-embed vectors (768-dim). Accepts a string or array of strings.

resp = client.embeddings.create(model="xael-embed", input="Xena rocks")
vector = resp.data[0].embedding

Account & usage

EndpointDescription
GET/v1/keysList your API keys
POST/v1/keysCreate an API key (grants $1 on your first key)
PATCH/v1/keys/:keySet key name / default prompt / default KB
DELETE/v1/keys/:keyRevoke a key
GET/v1/usageRequests, tokens, cost, per-model & daily
GET/v1/balanceYour current balance and key count
GET/v1/prompts · POST/v1/prompts · DELETE/v1/prompts/:nameManage named system-prompt presets
GET/v1/logsRecent request log (last 20)
GET/v1/capabilitiesEverything this deployment offers, with prices, read from the billing table

Errors & limits

CodeMeaning
400Bad request (e.g., missing messages)
401Missing or invalid API key
402Insufficient balance
429Rate limited (90 req/min key, 500 req/min account) — honour Retry-After
503AI engine unavailable

Top up your balance anytime at ai.xytro.site. Balances are stored and spent in dollars.

OpenAPI spec & interactive explorer

Try the API live — no setup — with the interactive explorer (Swagger UI):

https://ai.xytro.site/api-explorer.html
https://ai.xytro.site/api-explorer.html

A machine-readable OpenAPI 3.0 spec is available at:

https://ai.xytro.site/openapi.json
https://ai.xytro.site/openapi.json

In the explorer, click Authorize, paste your xena_… key, and hit Try it out on any endpoint.