Realtime AI Endpoints
This endpoint group provides methods for interacting with Realtime AI agents, allowing clients to start and end sessions, send text and audio messages, manage audio input, and retrieve or clear chat history.
Endpoints
POST /api/rpc (Method: RealtimeAiRpc.startSession)
Description: Starts a Realtime AI session with a specified agent.
Request Body:
{ "method": "RealtimeAiRpc.startSession", "params": { "agentName": "myAgent" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to start the session with Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.startSession", "params": { "agentName": "myAgent" } }'
POST /api/rpc (Method: RealtimeAiRpc.endSession)
Description: Ends a Realtime AI session with a specified agent.
Request Body:
{ "method": "RealtimeAiRpc.endSession", "params": { "agentName": "myAgent" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to end the session with Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.endSession", "params": { "agentName": "myAgent" } }'
POST /api/rpc (Method: RealtimeAiRpc.sendMessage)
Description: Sends a text message to a Realtime AI agent.
Request Body:
{ "method": "RealtimeAiRpc.sendMessage", "params": { "agentName": "myAgent", "message": "Hello, how are you?" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to send the message to messageStringYes The text content of the message to send Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.sendMessage", "params": { "agentName": "myAgent", "message": "Hello, how are you?" } }'
POST /api/rpc (Method: RealtimeAiRpc.sendAudioChunk)
Description: Sends an audio chunk to a Realtime AI agent. The audio chunk should be Base64 encoded.
Request Body:
{ "method": "RealtimeAiRpc.sendAudioChunk", "params": { "agentName": "myAgent", "audioChunk": "BASE64_ENCODED_AUDIO_DATA" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to send the audio to audioChunkStringYes Base64 encoded audio chunk Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.sendAudioChunk", "params": { "agentName": "myAgent", "audioChunk": "..." } }'
POST /api/rpc (Method: RealtimeAiRpc.startAudio)
Description: Starts audio input for a Realtime AI agent. This typically signals the agent to begin processing incoming audio chunks.
Request Body:
{ "method": "RealtimeAiRpc.startAudio", "params": { "agentName": "myAgent" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to start audio input for Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.startAudio", "params": { "agentName": "myAgent" } }'
POST /api/rpc (Method: RealtimeAiRpc.stopAudio)
Description: Stops audio input for a Realtime AI agent. This typically signals the agent to stop processing incoming audio chunks.
Request Body:
{ "method": "RealtimeAiRpc.stopAudio", "params": { "agentName": "myAgent" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to stop audio input for Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.stopAudio", "params": { "agentName": "myAgent" } }'
POST /api/rpc (Method: RealtimeAiRpc.getChatHistory)
Description: Retrieves the chat history for a specified AI agent.
Request Body:
{ "method": "RealtimeAiRpc.getChatHistory", "params": { "agentName": "myAgent" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to get chat history from Response:
{ "success": true, "data": [ { "role": "user", "content": "Hello!" }, { "role": "assistant", "content": "Hi there, how can I help you?" } ] }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.getChatHistory", "params": { "agentName": "myAgent" } }'
POST /api/rpc (Method: RealtimeAiRpc.clearChatHistory)
Description: Clears the chat history for a specified AI agent.
Request Body:
{ "method": "RealtimeAiRpc.clearChatHistory", "params": { "agentName": "myAgent" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to clear chat history for Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.clearChatHistory", "params": { "agentName": "myAgent" } }'
POST /api/rpc (Method: RealtimeAiRpc.cancelResponse)
Description: Cancels an in-progress Realtime AI response for a specified agent.
Request Body:
{ "method": "RealtimeAiRpc.cancelResponse", "params": { "agentName": "myAgent" } }Parameters:
Name Type Required Description agentNameStringYes Name of the agent to cancel the response for Response:
{ "success": true, "data": { "success": true } }Example (cURL):
curl -X POST https://api.example.com/api/rpc \ -H "Content-Type: application/json" \ -H "X-API-Key: YOUR_API_KEY" \ -d '{ "method": "RealtimeAiRpc.cancelResponse", "params": { "agentName": "myAgent" } }'