Overview
The Agentic Chat API, powering Zarna AI (the intelligent chatbot), provides a natural language interface to query and interact with your CRM data using a multi-agent AI system with persistent agent pools for optimal performance. Base Path:/agentic-chat
Key Features
- Natural Language Queries: Ask questions in plain English
- Multi-Agent System: Specialized agents for different tasks
- Agent Pool: Pre-warmed agents eliminate 5-11s cold start
- Real-time Streaming: Server-Sent Events for live responses
- Context Awareness: Maintains conversation history
Endpoints
Query (Streaming)
Execute a natural language query against your CRM data.| Field | Type | Required | Description |
|---|---|---|---|
company_id | UUID | No | Context company (optional) |
query | string | Yes | Natural language query |
chat_id | UUID | Yes | Conversation ID for context |
pool_options | object | No | Pool configuration |
System Health
Check agent pool system health.Pool Status
Get status for a specific firm’s agent pool.healthy: Operating normallydegraded: Some agents unavailablefailed: Pool not operationalinitializing: Starting up
Restart Pool
Manually restart a firm’s agent pool.Performance Metrics
Get aggregated performance metrics.Event Types
Streaming Events
| Event | Description | Data Fields |
|---|---|---|
start | Query processing started | query_id, timestamp |
agent_start | Agent begins task | agent, task |
chunk | Content chunk | content |
data | Structured data | varies by query |
agent_complete | Agent finishes | agent, duration |
complete | Query complete | query_id, total_time |
error | Error occurred | message, error_code |
Frontend Integration
React Hook for Streaming
Python
Example Queries
Data Retrieval
Analytics
Operations
Complex Queries
Performance
With Agent Pool
- First query (cold firm): ~7-8 seconds
- Subsequent queries (warm pool): ~3-4 seconds
- Peak throughput: ~10 queries/second
- Concurrent users: Supports 100+ simultaneous users
Without Agent Pool (Legacy)
- Every query: ~12-15 seconds (5-11s cold start + 7s execution)
Agent Pool Architecture
Learn about performance optimization
Error Handling
| Code | Error | Description |
|---|---|---|
| 400 | invalid_query | Query cannot be understood |
| 401 | unauthorized | Authentication required |
| 404 | chat_not_found | Chat ID doesn’t exist |
| 422 | query_failed | Query execution error |
| 429 | rate_limit_exceeded | Too many requests |
| 503 | pool_unavailable | Agent pool not ready |
