Welcome to the Praxis AI API reference documentation. This section provides detailed information about the Praxis AI API endpoints, request formats, and response structures to help you integrate Praxis AI’s capabilities directly into your applications.
This page provides a quick, actionable path to authenticate, call REST endpoints, and capture streaming events from the middleware.
All API requests require an authorization token issued after successful authentication. See the Authentication API for how to sign in and use the token in requests.
You can connect to Praxis AI middleware to receive streaming events while REST requests are in-flight. The server emits stream chunks to your socket; you must include the current socket ID in Q&A requests to link streams to your session.
These are typical events payload received from the stream
Copy
Ask AI
{ "prompt": " I'm doing great, thank you for asking! 😊 I'm here, energized, and ready to help you with whatever you need today.Since we last spoke just a minute ago when you checked if I was here, I'm curious—what's on your mind? Are you: - Looking to learn something new? - Working on a project or assignment? - Curious about a specific topic? - Just wanting to chat? I'm all ears and ready to assist! What would you like to explore", "delta": " What would you like to explore", "type": "STREAM"}
prompt: Contains the full response from the begining ot the interaction.delta Contains only the last text segment reportedtype: “STREAM” for messages streamed by the LLM
Note that the final response may differ from the prompt returned while streaming.
When the QANDA request response includes "streamingFailed": true, it indicates that the middleware has lost the backend Socket ID mapping (user email to client socket ID), preventing it from communicating response chunks back to the client. This typically occurs when multiple browser windows or tabs are open for the same user email, causing them to compete for the same backend session and overwriting each other’s socket registrations. To resolve this issue, you can re-establish the socket connection to re-register the most current client handle and restore proper communication between the middleware and the active client session.
Copy
Ask AI
if (response?.streamingFailed){ // reconnecting if (state.socket.connected){ await state.socket.disconnect() } await state.socket.connect()}
To abort a request while executing, emit a cancel_request event:
Copy
Ask AI
state.socket.emit('cancel_request', user);
The cancel_request message signals the controller API to interrupt the ongoing communication and attempt a graceful termination of the conversation. While the controller works to terminate resources cleanly, there may be a slight delay before the process completes. You will only be charged for any partial response generated up to the point of cancellation.
The endpoint returns text/event-stream content type with SSE-formatted chunks:
Event Type
Description
connected
Initial acknowledgment that stream is established
stream
Text chunks as they are generated by the AI
tool
Notification when a tool (RAG, web search, etc.) is being invoked
complete
Final response with usage statistics
error
Error information if something went wrong
done
Stream termination signal
Example SSE Response:
Copy
Ask AI
data: {"type":"connected","message":"Stream connected"}data: {"type":"stream","prompt":"Hello! "}data: {"type":"stream","prompt":"I'm here to help you today."}data: {"type":"tool","name":"call_rag","status":"calling"}data: {"type":"stream","prompt":" Based on the documentation..."}data: {"type":"complete","success":true,"usage":1234,"outputs":["..."]}data: {"type":"done"}
To cancel an in-flight HTTP stream request, you can abort the fetch request:
Copy
Ask AI
const controller = new AbortController();// Start the request with abort signalconst response = await fetch('/api/ai/personal-stream/qanda-stream', { method: 'POST', headers: { ... }, body: JSON.stringify({ ... }), signal: controller.signal // Pass the abort signal});// Later, to cancel:controller.abort();
The HTTP SSE endpoint is stateless - each request is independent. This makes it ideal for serverless functions, CLI tools, and microservices where maintaining WebSocket connections is impractical.
While the API provides direct access to all capabilities, the TypeScript/JavaScript SDK simplifies most tasks.
API Benefits
• Direct access to all Praxis features
• Language-agnostic integration
• Fine-grained request/response control
• Ideal for custom platforms or gateways, mobile applications
SDK Benefits
• Higher-level abstractions
• Seamless SSO authentication
• UI Ready to use
• Supports LMS Such as Canvas, Moodle, D2L, LTI
For most use cases, we recommend using our SDKs, while the API remains available for mobile applications, low-level or platform-neutral integrations.