How It Works
Point
Set the OpenAI client’s
base_url to your Praxis Chat Completions endpoint.Authenticate
Pass your Praxis JWT via the
x-access-token header to identify the user session.Chat
Use your Digital Twin’s Public ID as the
model parameter — that’s it.Prerequisites
Before you begin, make sure you have:- A Praxis AI account with access to at least one Digital Twin
- The Digital Twin’s Public ID (a UUID like
e455529a-4f51-479e-94fc-bbebb41d19a1) — found in your instance’s administration panel - A valid Praxis JWT token (
x-access-token) — obtained when a user authenticates with Praxis (see Authentication) - Chat Completions enabled on the Digital Twin — this integration is off by default; an administrator must turn it on for the instance
The Chat Completions endpoint is part of the Pria platform itself — the base URL is your Pria server’s
/api/ai path (e.g. https://pria.praxislxp.com/api/ai). It is disabled per Digital Twin by default; if requests return 403 chat_completion_disabled, ask the instance administrator to enable the Chat Completions endpoint in the instance configuration.Quick Start
1
Install the OpenAI SDK
2
Configure the client
Point the SDK to your Praxis endpoint and pass your authentication token.
The
api_key field is required by the OpenAI SDK but is not used for authentication. Praxis authenticates via the x-access-token header. If your deployment also uses API keys, pass it as the api_key value instead (see Authentication below).3
Send a message (streaming)
Use your Digital Twin Public ID as the
model parameter, and set stream=True.The endpoint always streams — responses are delivered as OpenAI-format SSE chunks regardless of the
stream flag, so use your SDK’s streaming mode.Authentication
The API supports two authentication methods that can be used independently or together.Praxis JWT (primary)
Pass the user’s Praxis session token via thex-access-token header. This is the primary authentication method — it identifies the user and authorizes access to their Digital Twins.
Getting a JWT from a personal API key (server-to-server)
For scripts and server-to-server integrations, exchange a personal API key (prefixedpria_) for a JWT, then pass that JWT in the x-access-token header. The raw pria_… key is not accepted directly — exchange it first:
Context Headers
Optional headers let you pass conversation metadata to the Digital Twin. These enrich the interaction context without affecting authentication.Context headers are useful when your application manages multiple conversations or needs to target a specific assistant within a Digital Twin.
Message Roles
The API accepts standard OpenAI message roles with the following behavior:You can send only the current user message (Pria tracks the conversation via
x-praxis-conversation-id), or pass your own running message array — prior user/assistant turns you include are replayed as history for the active turn.Response Format
The endpoint always streams. Responses arrive as standard OpenAI SSE chunks:choices[0].delta.content.
Supported Parameters
Administrators can set Chat-Completions-specific overrides on the instance — a dedicated model, a max-completion-tokens cap, and a reasoning-effort level (commonly
none for voice agents) — without affecting the Twin’s normal in-app behaviour.Error Handling
Errors follow the standard OpenAI error format:Common Errors
Multi-Provider Routing
The Chat Completions API is a front door to the Pria platform, not a thin proxy to a single model provider. Behind the URL, Pria selects the underlying provider and model based on the Digital Twin’s configuration. As of today, Pria can route to:
The
model parameter you pass in the request is the Digital Twin Public ID — not a provider model ID. Pria resolves it to the configured underlying model. If the Twin’s admin changes the underlying model from Claude to GPT‑4o, your code does not change.
Per‑Provider Behavioural Differences
Because Pria forwards to many providers, some advanced behaviours are provider‑dependent and respect the Twin’s configuration rather than the request payload:- Reasoning effort — accepted for OpenAI o‑series and xAI
grok-3-mini. Grok 4.x reasons automatically and ignores the parameter. - Thinking tokens — Anthropic Claude 3.7+ and Gemini 2.5+ support extended thinking budgets, configured per Twin.
- Image generation — supported by OpenAI (
gpt-image-1), Bedrock (Stable Diffusion via Stability), Google (Imagen), and xAI (grok-2-image). Mistral delegates to OpenAI or Bedrock. - Prompt caching — automatic for Anthropic, OpenAI, and xAI; reported in the response
usageblock when present. - Tool calls — the Digital Twin’s server‑side tools (RAG, web search, charts, connectors, MCP) run automatically. Client‑supplied
tools/tool_choiceare not forwarded (see Supported Parameters).
Provider Authentication Errors
When the Twin is configured to use a provider that requires its own credentials (BYOT — Bring Your Own Tokens), errors from the underlying provider are surfaced back to you as standard OpenAI‑style errors:
See BYOT (Bring Your Own Tokens) for how Twin admins configure provider keys.
Cost & Credits
Chat completions consume Pria credits, billed by token usage and the underlying provider’s price tier. Each response’susage block reports prompt_tokens, completion_tokens, and total_tokens — the same fields the OpenAI SDK consumers already read.
- Cached prompt tokens (when the provider supports caching) are billed at a discounted rate.
- Streaming requests are billed identically to non‑streaming.
- Embedded RAG retrieval runs as part of the Digital Twin’s response and is included in the credit cost — you do not pay separately for vector search.
Chat Completions vs. the Pria Runtime API
Pria exposes two complementary APIs. They look similar but behave very differently — choose based on whether you want stateless OpenAI‑style requests or full Pria session semantics.
Rule of thumb: if your code already uses the OpenAI SDK and you want to point it at Pria with minimal changes, use the Chat Completions API. If you’re building a new client from scratch and want access to every Pria capability (per‑message tool events, citations, KAG augmentations, structured memory updates), use the Runtime API.
See the API Reference for both.
Related
- API Reference — Full REST API documentation with streaming details
- AI Models — Provider catalog, reasoning effort, thinking, and image generation behaviour per provider
- API Keys — Issue and rotate the API keys used to obtain Praxis JWTs
- BYOT (Bring Your Own Tokens) — How Twin admins configure per‑provider credentials
- Plans & Credits — How token usage maps to credits
- MCP Server — Connect Pria to custom LLM workflows
- Web SDK — Embed the full Digital Twin UI in your web app
- JavaScript SDK — Programmatic control of the Pria interface