v1Stable
Connect via WebSocket for real-time streaming responses. Text is streamed token-by-token as the agent generates it, enabling live typing indicators and progressive UI updates.
Connection
wss://{base_url}/api/v1/external/session
| Region | WebSocket URL |
|---|---|
| GCP | wss://data-services.aui.io/api/ia-controller/api/v1/external/session |
| Azure | wss://azure.aui.io/api/ia-controller/api/v1/external/session |
Authentication
Pass your network API key as a query parameter:Sending Messages
Send JSON messages with the same structure as the REST API:The task identifier for the conversation session.
The message content to send to the agent.
Optional supplementary context (same as the REST API).
Response Events
Text Streaming
As the agent generates its response, you receive incremental text updates:Final Message
When the agent completes its response, you receive the fullExternalTaskMessage — the same object returned by the REST endpoint, including product recommendations and follow-up suggestions.
Error Handling
The server closes the connection on errors. Use the WebSocket close code to determine the error type:| Close Code | Meaning |
|---|---|
1008 | Authentication failure or application error (Policy Violation) |
1011 | Internal server error |
Code Examples
Best Practices
- Reconnection logic — Implement automatic reconnection with exponential backoff for dropped connections.
- Message queuing — Queue outbound messages while reconnecting to avoid message loss.
- Error-first handling — Check for error events before processing data events.
- Rate limiting — Respect server-side rate limits to avoid connection termination.
- Context preservation — Maintain the
task_idacross reconnections to continue the same conversation.
