Documentation menu
Xpersona developer documentation
Everything you need to integrate GPT, Claude, Gemini, and Xpersona models through one OpenAI-compatible API: authentication, chat completions, streaming, tools, vision, structured outputs, billing, usage, and reference tables.
Quick start#
Call your first model in under three minutes.
- Create a Xpersona account and generate an API key in the Connect AI dashboard.
- Pick any model ID from the model catalog.
- Point your OpenAI-compatible client at
https://www.xpersona.co/v1and send a request.
Chat completion
curl https://www.xpersona.co/v1/chat/completions \
-H "Authorization: Bearer $XPERSONA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5",
"messages": [
{"role": "user", "content": "What is the meaning of life?"}
]
}'OpenAI-compatible
Xpersona speaks the standard OpenAI Chat Completions protocol. Any official OpenAI SDK, LangChain, LlamaIndex, Vercel AI SDK, or hand-rolled HTTP client works — change the base URL and API key, nothing else.Native OpenCode setup#
Xpersona is a first-party OpenCode provider. Choose xpersona from the provider picker, then run the generated setup script with your key. The default OpenCode model is xpersona/claude-fable-5 (Claude Fable 5, 1M context).
export XPERSONA_API_KEY='xp_your_key'
opencode models xpersona --refresh --verbose
opencode run -m xpersona/claude-fable-5 "Reply with exactly: XPERSONA_OK"
opencodeFull guide: /opencode. Verify discovery with curl https://www.xpersona.co/v1/models.
Authentication#
All authenticated endpoints use a bearer key created in the dashboard. Keys are shown once — store them in a secret manager or environment variable.
- Sign in and open Dashboard → Connect AI.
- Create a key (prefix
xp_) and copy it immediately. - Export it as
XPERSONA_API_KEYand send it on every request.
Keep keys server-side
Never ship your key in browser code, mobile bundles, or public repositories. Route production traffic through your backend and rotate keys from the dashboard if one leaks.Base URL & protocol#
One gateway serves the whole catalog. The production base URL is https://www.xpersona.co/v1, and the four core routes mirror the OpenAI surface you already know:
| Method | Endpoint | Auth | Purpose |
|---|---|---|---|
| POST | /v1/chat/completions | Bearer key | Generate a model response; supports stream, tools, vision, JSON schema output. |
| GET | /v1/models | Public | List every public model ID available to your account tier. |
| GET | /v1/pricing | Public | Retail price card per model (input, cached input, output per 1M tokens). |
| GET | /v1/usage | Bearer key | Billing state, included allowance, spend, and recent requests. |
Model catalog#
Popular models and their retail rates. Prices are USD per one million tokens; cached input applies when a provider cache hit occurs on supported routes.
| Model ID | Context | Max out | Input / 1M | Cached / 1M | Output / 1M |
|---|---|---|---|---|---|
| claude-fable-5 | 1M | 128k | $3 | $0.3 | $18.5 |
| gpt-5.6 | 372k | 128k | $1.5 | $0.15 | $12 |
| gpt-5.6-sol | 372k | 128k | $1.5 | $0.15 | $12 |
| gpt-5.6-terra | 372k | 128k | $1.5 | $0.15 | $2 |
| gpt-5.4-mini | 272k | 128k | $0.375 | $0.037 | $4 |
| claude-opus-4-8 | 200k | 128k | $1.5 | $0.15 | $9.25 |
| claude-sonnet-4-6 | 200k | 128k | $0.9 | $0.09 | $5.55 |
| gemini-3.5-flash | 1M | 128k | $1.55 | $0.155 | $12.2 |
Full catalog with filters and live pricing: /models. Machine-readable: GET https://www.xpersona.co/v1/models and GET https://www.xpersona.co/v1/pricing.
Streaming#
Set "stream": true to receive server-sent events. Each chunk carries a partial delta; the stream ends with a [DONE] sentinel, exactly like the OpenAI wire format.
curl https://www.xpersona.co/v1/chat/completions \
-H "Authorization: Bearer $XPERSONA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5",
"stream": true,
"messages": [{"role": "user", "content": "Count to five"}]
}'Function calling#
Pass a tools array to let the model request structured tool calls. Execute the tool server-side, then append the result as a tool message and continue the conversation.
from openai import OpenAI
client = OpenAI(base_url="https://www.xpersona.co/v1", api_key="$XPERSONA_API_KEY")
tools = [
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string"},
"unit": {"type": "string", "enum": ["celsius", "fahrenheit"]},
},
"required": ["city"],
},
},
}
]
response = client.chat.completions.create(
model="claude-fable-5",
messages=[{"role": "user", "content": "Weather in Tokyo?"}],
tools=tools,
)
print(response.choices[0].message.tool_calls[0].function.arguments)Vision input#
Vision-capable models accept image parts alongside text. Supply a public HTTPS URL or a base64 data URL in the content array. Check the catalog capabilities before sending images.
curl https://www.xpersona.co/v1/chat/completions \
-H "Authorization: Bearer $XPERSONA_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-fable-5",
"messages": [
{
"role": "user",
"content": [
{"type": "text", "text": "What is in this image?"},
{"type": "image_url", "image_url": {"url": "https://example.com/photo.jpg"}}
]
}
]
}'Structured outputs#
Constrain responses to a JSON Schema with response_format. With strict: true the model must return valid JSON that matches your schema — ideal for extraction pipelines and agent planners.
from openai import OpenAI
client = OpenAI(base_url="https://www.xpersona.co/v1", api_key="$XPERSONA_API_KEY")
response = client.chat.completions.create(
model="claude-fable-5",
messages=[{"role": "user", "content": "Invoice from Acme, $120 due June 1"}],
response_format={
"type": "json_schema",
"json_schema": {
"name": "invoice",
"strict": True,
"schema": {
"type": "object",
"properties": {
"vendor": {"type": "string"},
"amount_usd": {"type": "number"},
"due_date": {"type": "string"},
},
"required": ["vendor", "amount_usd", "due_date"],
"additionalProperties": False,
},
},
},
)
print(response.choices[0].message.content)Prompt caching#
Repeated prefixes (system prompts, retrieved documents, long tool definitions) are automatically cached on managed routes. Cache hits are billed at roughly 10% of the uncached input rate, so stable prompt prefixes materially cut cost and latency. Cached prices appear in the catalog and in GET https://www.xpersona.co/v1/pricing.
Error handling#
Errors return standard HTTP status codes with an OpenAI-style body:
{
"error": {
"message": "Incorrect API key provided.",
"type": "invalid_request_error",
"code": "invalid_api_key"
}
}| Status | Type | Meaning |
|---|---|---|
| 400 | invalid_request_error | Malformed JSON body or an unsupported parameter for the selected model. |
| 401 | invalid_request_error | Missing or invalid API key. Check the Authorization: Bearer header. |
| 402 | insufficient_balance | Prepaid balance is exhausted or the monthly package allowance is paused. Top up or wait for the reset. |
| 404 | not_found | Unknown model ID or route. List valid IDs with GET /v1/models. |
| 429 | rate_limit_exceeded | Too many requests in a short window. Back off and retry with jitter. |
| 500 / 502 | api_error | Upstream inference failure. Retry once, then fall back to another catalog model. |
Retry 500/502 once with backoff, honor 429, and treat 402 as a billing signal rather than an error to retry blindly.
Billing & packages#
Access the full catalog with a fixed monthly package, or pay as you go with prepaid credits from $2. Package requests pause at the monthly compute allowance instead of creating overage charges; prepaid usage pauses at a zero balance. Stripe handles checkout.
| Plan | Price | Included capacity |
|---|---|---|
| Builder | $20/month | Fixed supplier-weighted monthly capacity on the base-cost route. |
| Pro | $100/month | 5x Builder monthly capacity; premium usage is supplier-weighted. |
| Studio | $200/month | 20x Builder monthly capacity; premium usage is supplier-weighted. |
| Scale | $350/month | 50x Builder monthly capacity; premium usage is supplier-weighted. |
Compare plans on /pricing; manage payment methods and invoices in Dashboard → Billing.
Usage & dashboard#
Pull your own telemetry programmatically, or read it visually in the dashboard:
curl https://www.xpersona.co/v1/usage \
-H "Authorization: Bearer $XPERSONA_API_KEY"- Prepaid credit state, API key prefix, and plan status
- Monthly spend, weekly usage, and token totals per model
- Latency and a log of recent requests
- Retail price card for reconciliation against
/v1/pricing
Council multi-model runs#
Run one task across several frontier models, blind-judge the evidence, and continue with the winner. Council sessions are created by signed-in users via POST /v1/council, and each session can produce a shareable proof receipt (GET /v1/council/:id/receipt, private by default).
Full guide: /docs/council. Product surface: /council.
Agent discovery flow#
The recommended flow for autonomous clients evaluating third-party agents:
- Discover — start from feed views: latest, benchmarked, security-reviewed, openapi-ready.
- Inspect evidence — read snapshot, contract, trust, card, and facts before acting.
- Act — recommend, crawl, or route work; use /v1 inference once your user has an active plan.
Retired search endpoints intentionally return 410 — crawlers should move to the feed-first flow above.
Endpoint reference#
Inference and usage
| GET | /v1/models | Public | List public Xpersona model IDs. |
| POST | /v1/chat/completions | Bearer API key | Run any catalog model; Claude Fable 5 is the default. |
| GET | /v1/pricing | Public | Retail model price cards. |
| GET | /v1/usage | Bearer API key | Billing state, limits, spend, and recent calls. |
| POST | /v1/chat/completions (model: xpersona-auto) | Bearer API key | Auto-route each request to the best enabled model with explainable routing metadata. |
Council
| POST | /v1/council | Signed-in user | Create and run a multi-model Council comparison. |
| GET | /v1/council/:id/receipt | Signed-in user | Preview, publish, or unpublish a proof receipt (private by default). |
Agent discovery
| GET | /api/v1/feeds/agents/{view} | Public | latest, benchmarked, security-reviewed, openapi-ready, recent-updates. |
| GET | /api/v1/agents/{slug}/snapshot | Public or crawl token | Stable summary for extraction. |
| GET | /api/v1/agents/{slug}/contract | Public or crawl token | Capability and integration contract. |
| GET | /api/v1/agents/{slug}/trust | Public or crawl token | Verification and reliability signals. |
Crawler and tool integrations
| GET | /api/v1/crawl-license | Public | Credit options, token transport, and gated surfaces. |
| POST | /api/v1/crawl-license | xpcrawl key | Exchange an API key for a crawl token. |
| GET | /api/v1/tools/langchain | Public | LangChain tool descriptors. |
Machine-readable surfaces#
Built for autonomous clients, crawlers, and LLM framework adapters:
