Chat API
Send messages and receive AI-generated responses grounded in your content. The Chat API enables conversational interactions with automatic context retrieval and source citations.
Send message
Sends a user message and receives an AI-generated response with relevant resources from your content library.
The user's question or message.
Token from a previous response for conversation continuity.
Current page URL for context-aware responses.
AI-generated response grounded in your content.
Content items used to generate the response.
Token for maintaining conversation context.
Classified query type.
curl -X POST https://api.isomera.ai/api/v1/widget/chat \
-H "Content-Type: application/json" \
-H "X-API-Key: wk_your_api_key" \
-d '{
"message": "What are the side effects?",
"session_token": "sess_abc123def456"
}'{
"answer": "The most common side effects include nausea, diarrhea, and decreased appetite. These are usually mild and improve over time.",
"resources": [
{
"type": "webpage",
"title": "Common Side Effects",
"url": "https://example.com/side-effects",
"section_type": "side_effects"
},
{
"type": "youtube",
"title": "Managing Side Effects",
"video_id": "abc123",
"timestamp_seconds": 134,
"timestamp_display": "2:14"
}
],
"session_token": "sess_abc123def456",
"query_type": "side_effects"
}Create session
Creates a new chat session and returns widget configuration.
Page URL where session started.
curl -X POST https://api.isomera.ai/api/v1/widget/session \
-H "X-API-Key: wk_your_api_key"{
"session_token": "sess_abc123def456ghi789",
"client_name": "Acme Therapeutics",
"welcome_message": "Hi! How can I help you today?",
"placeholder_text": "Ask a question...",
"primary_color": "#0284c7"
}Get conversation history
Retrieves the full conversation history for a session.
The session token.
curl https://api.isomera.ai/api/v1/widget/history/sess_abc123 \
-H "X-API-Key: wk_your_api_key"{
"messages": [
{
"role": "user",
"content": "What are the side effects?",
"timestamp": "2024-12-18T10:30:00Z"
},
{
"role": "assistant",
"content": "The most common side effects include...",
"timestamp": "2024-12-18T10:30:02Z",
"resources": [...]
}
]
}Stream response
Stream chat responses using Server-Sent Events for real-time typing effect.
Individual tokens as generated.
Retrieved resources (sent before tokens).
Stream completion with metadata.
curl -X POST https://api.isomera.ai/api/v1/widget/chat/stream \
-H "Content-Type: application/json" \
-H "X-API-Key: wk_your_api_key" \
-H "Accept: text/event-stream" \
-d '{"message": "What is the dosing schedule?"}'event: resources
data: {"resources": [...]}
event: token
data: {"token": "The"}
event: token
data: {"token": " recommended"}
event: done
data: {"session_token": "sess_abc123"}