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.

  1. Create a Xpersona account and generate an API key in the Connect AI dashboard.
  2. Pick any model ID from the model catalog.
  3. Point your OpenAI-compatible client at https://www.xpersona.co/v1 and send a request.

Chat completion

Terminal
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"
opencode

Full 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.

  1. Sign in and open Dashboard → Connect AI.
  2. Create a key (prefix xp_) and copy it immediately.
  3. Export it as XPERSONA_API_KEY and 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:

MethodEndpointAuthPurpose
POST/v1/chat/completionsBearer keyGenerate a model response; supports stream, tools, vision, JSON schema output.
GET/v1/modelsPublicList every public model ID available to your account tier.
GET/v1/pricingPublicRetail price card per model (input, cached input, output per 1M tokens).
GET/v1/usageBearer keyBilling 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 IDContextMax outInput / 1MCached / 1MOutput / 1M
claude-fable-51M128k$3$0.3$18.5
gpt-5.6372k128k$1.5$0.15$12
gpt-5.6-sol372k128k$1.5$0.15$12
gpt-5.6-terra372k128k$1.5$0.15$2
gpt-5.4-mini272k128k$0.375$0.037$4
claude-opus-4-8200k128k$1.5$0.15$9.25
claude-sonnet-4-6200k128k$0.9$0.09$5.55
gemini-3.5-flash1M128k$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.

Terminal
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.

tools.py
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.

Terminal
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.

structured.py
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"
  }
}
StatusTypeMeaning
400invalid_request_errorMalformed JSON body or an unsupported parameter for the selected model.
401invalid_request_errorMissing or invalid API key. Check the Authorization: Bearer header.
402insufficient_balancePrepaid balance is exhausted or the monthly package allowance is paused. Top up or wait for the reset.
404not_foundUnknown model ID or route. List valid IDs with GET /v1/models.
429rate_limit_exceededToo many requests in a short window. Back off and retry with jitter.
500 / 502api_errorUpstream 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.

PlanPriceIncluded capacity
Builder$20/monthFixed supplier-weighted monthly capacity on the base-cost route.
Pro$100/month5x Builder monthly capacity; premium usage is supplier-weighted.
Studio$200/month20x Builder monthly capacity; premium usage is supplier-weighted.
Scale$350/month50x 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:

1) /api/v1/feeds/agents/latest → 2) /snapshot → 3) /contract + /trust → then decide
  • 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/modelsPublicList public Xpersona model IDs.
POST/v1/chat/completionsBearer API keyRun any catalog model; Claude Fable 5 is the default.
GET/v1/pricingPublicRetail model price cards.
GET/v1/usageBearer API keyBilling state, limits, spend, and recent calls.
POST/v1/chat/completions (model: xpersona-auto)Bearer API keyAuto-route each request to the best enabled model with explainable routing metadata.

Council

POST/v1/councilSigned-in userCreate and run a multi-model Council comparison.
GET/v1/council/:id/receiptSigned-in userPreview, publish, or unpublish a proof receipt (private by default).

Agent discovery

GET/api/v1/feeds/agents/{view}Publiclatest, benchmarked, security-reviewed, openapi-ready, recent-updates.
GET/api/v1/agents/{slug}/snapshotPublic or crawl tokenStable summary for extraction.
GET/api/v1/agents/{slug}/contractPublic or crawl tokenCapability and integration contract.
GET/api/v1/agents/{slug}/trustPublic or crawl tokenVerification and reliability signals.

Crawler and tool integrations

GET/api/v1/crawl-licensePublicCredit options, token transport, and gated surfaces.
POST/api/v1/crawl-licensexpcrawl keyExchange an API key for a crawl token.
GET/api/v1/tools/langchainPublicLangChain tool descriptors.

Machine-readable surfaces#

Built for autonomous clients, crawlers, and LLM framework adapters:

Next steps

Xpersona API Docs - OpenAI-Compatible Inference, Guides, and Reference