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 - The Chat Completions API base URL — provided by your Praxis administrator (e.g.
https://your-instance.example.com/api/v1)
The Chat Completions API is a separate middleware service. Ask your administrator for the endpoint URL and confirm it is deployed for your environment.
Quick Start
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).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.
API Key (optional)
For server-to-server integrations, your administrator may issue an API key (prefixedsk-). Pass it via the standard Authorization header. When used alongside x-access-token, the API key adds rate limiting and usage tracking.
Context Headers
Optional headers let you pass conversation metadata to the Digital Twin. These enrich the interaction context without affecting authentication.| Header | Type | Description | Default |
|---|---|---|---|
x-access-token | string | Required. Praxis JWT for user authentication | — |
x-praxis-conversation-id | string | Numeric conversation/course identifier | 0 |
x-praxis-conversation-name | string | Human-readable conversation or course name | "" |
x-praxis-assistant-id | string | Routes the request to a specific assistant persona | "" |
Context headers are useful when your application manages multiple conversations or needs to target a specific assistant within a Digital Twin.
Discover Available Models
List all Digital Twins available to the authenticated user.model.id returned is the Digital Twin Public ID — use it as the model parameter in chat completions.
Message Roles
The API accepts standard OpenAI message roles with the following behavior:| Role | Behavior |
|---|---|
user | Sent to the Digital Twin. Only the last user message is forwarded. |
system | Ignored — the Digital Twin manages its own system instructions. |
assistant | Ignored — Praxis maintains conversation history internally. |
tool | Treated as user input. If tool_call_id is present, it is prefixed for context. |
Since Praxis manages conversation history server-side, you only need to send the current user message. There is no need to maintain a local message array across turns.
Response Format
Responses follow the standard OpenAI Chat Completion format:Supported Parameters
| Parameter | Supported | Notes |
|---|---|---|
model | Yes | Digital Twin Public ID (required) |
messages | Yes | Message array (required) |
stream | Yes | true for SSE streaming |
response_format | Yes | text (default), json_object, or json_schema |
temperature | Accepted | Accepted for SDK compatibility but not forwarded |
max_tokens | Accepted | Accepted for SDK compatibility but not forwarded |
tools / tool_choice | Not supported | Function calling is not available |
Parameters marked Accepted are validated and will not cause errors, but Praxis manages these settings through the Digital Twin’s configuration.
Error Handling
Errors follow the standard OpenAI error format:Common Errors
| Status | Code | Cause | Fix |
|---|---|---|---|
| 401 | missing_praxis_token | No x-access-token header | Add the Praxis JWT header |
| 401 | unauthorized | Expired or invalid JWT | Refresh the user’s session token |
| 401 | invalid_api_key | API key inactive or expired | Check key status with your administrator |
| 404 | model_not_found | Invalid Digital Twin Public ID | Verify the ID via the models endpoint |
| 429 | rate_limit_exceeded | Too many requests | Reduce request frequency or request a higher limit |
| 504 | timeout | Digital Twin took too long to respond | Retry or enable streaming for long responses |
V2 Endpoint (HTTP SSE)
An alternative endpoint is available at/v2/chat/completions for environments where WebSocket connections are restricted. It uses direct HTTP Server-Sent Events instead of Socket.IO.
Related
- API Reference — Full REST API documentation with streaming details
- Web SDK — Embed the full Digital Twin UI in your web app
- MCP Server — Connect Pria to custom LLM workflows
- JavaScript SDK — Programmatic control of the Pria interface