Welcome to the Polmy.ai API documentation. Our APIs provide programmatic access to knowledge stores, AI agents, and more. This documentation will help you integrate Polmy.ai into your applications.
All API requests must include an API key for authentication. You can create API keys in your dashboard after signing up.
Authorization: Bearer YOUR_API_KEY
The Knowledge Store API allows you to query your knowledge stores and retrieve relevant information based on natural language queries.
/api/v1/ks/{knowledge_store_id}/query/
{
"query": "What is the pricing structure?",
"max_results": 5
}
{
"results": [
{
"content": "Our pricing structure has three tiers: Basic, Pro, and Enterprise...",
"metadata": {
"source": "pricing.pdf",
"page": 2
},
"relevance_score": 0.92
},
...
],
"query_id": "6f9d7a3e-5b8c-4a7f-b71d-c390a8957849"
}
The Agent API allows you to create and manage AI agent conversations through threads, messages, and interventions.
All messages in the agent API include a role field with one of the following values:
human: Messages from the userassistant: Responses from the AI agentsystem: System-level instructions or informationtool: Messages from tools used by the agenthuman-intervention: Messages from human operators during an interventionClient applications should use these roles to determine how to display different message types in the UI.
/api/v1/agents/
{
"agents": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Customer Support Agent",
"description": "Helps with customer inquiries",
"type": "react",
"created_at": "2023-01-01T12:00:00Z"
},
{
"id": "8fb95f64-5717-4562-b3fc-2c963f66ccc7",
"name": "Sales Assistant",
"description": "Assists with product information",
"type": "reflexion",
"created_at": "2023-01-02T10:30:00Z"
}
]
}
Threads represent conversations with AI agents. You create a thread first, then add messages to it.
/api/v1/threads/create/
{
"agent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"title": "New Thread",
"external_user_id": "user_123"
}
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"title": "New Thread",
"created_at": "2023-01-01T12:00:00Z",
"agent": {
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"name": "Agent Name",
"type": "react"
}
}
/api/v1/threads/{thread_id}/delete/
external_user_id - Required: The external identifier of the thread owner
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"title": "Thread Title",
"agent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"status": "deleted"
}
/api/v1/threads/create/
{
"agent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"metadata": {
"user_id": "user_123",
"session_id": "session_456"
}
}
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2023-01-01T12:00:00Z",
"updated_at": "2023-01-01T12:00:00Z",
"agent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"status": "active",
"metadata": {
"user_id": "user_123",
"session_id": "session_456"
}
}
/api/v1/threads/
{
"results": [
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2023-01-01T12:00:00Z",
"updated_at": "2023-01-01T12:00:00Z",
"agent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"status": "active",
"metadata": {
"user_id": "user_123"
}
},
...
],
"count": 10,
"next": null,
"previous": null
}
/api/v1/threads/{thread_id}/
{
"id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2023-01-01T12:00:00Z",
"updated_at": "2023-01-01T12:00:00Z",
"agent_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"status": "active",
"metadata": {
"user_id": "user_123"
},
"messages": [
{
"id": "msg_123",
"role": "human",
"content": "Hello, can you help me?",
"created_at": "2023-01-01T12:01:00Z"
},
{
"id": "msg_124",
"role": "assistant",
"content": "Yes, I'd be happy to help. What do you need?",
"created_at": "2023-01-01T12:01:10Z"
}
]
}
Messages are sent to a thread to communicate with an AI agent.
/api/v1/threads/{thread_id}/messages/
{
"content": "I need help with setting up a knowledge store.",
"role": "user"
}
{
"id": "msg_125",
"thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2023-01-01T12:05:00Z",
"role": "human",
"content": "I need help with setting up a knowledge store.",
"status": "delivered"
}
Interventions allow human operators to take over or assist AI agents during conversations.
/api/v1/threads/{thread_id}/interventions/
{
"interventions": [
{
"id": "int_123",
"thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"type": "approval_required",
"status": "pending",
"created_at": "2023-01-01T12:10:00Z",
"content": {
"question": "Should I provide pricing information?",
"context": "The user is asking about enterprise pricing."
}
}
]
}
/api/v1/threads/{thread_id}/interventions/{intervention_id}/respond/
{
"response": {
"approved": true,
"message": "Yes, provide the standard enterprise pricing information."
}
}
{
"id": "int_123",
"thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"type": "approval_required",
"status": "completed",
"created_at": "2023-01-01T12:10:00Z",
"response_at": "2023-01-01T12:12:00Z"
}
For real-time updates on threads, messages, and interventions, you can establish WebSocket connections.
wss://api.polmy.ai/ws/thread/{thread_id}/
Connect with your API key in the query parameters:
wss://api.polmy.ai/ws/thread/3fa85f64-5717-4562-b3fc-2c963f66afa6/?token=YOUR_API_KEY
message: New message in the threadintervention: New intervention requeststatus: Thread status changes{
"type": "message",
"data": {
"id": "msg_126",
"thread_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6",
"created_at": "2023-01-01T12:15:00Z",
"role": "assistant",
"content": "Here's the information about setting up a knowledge store...",
"status": "delivered"
}
}
API requests are subject to rate limiting based on your subscription plan.
| Plan | Knowledge Store Queries | Agent Messages | Concurrent Threads |
|---|---|---|---|
| Free | 100 / day | 50 / day | 5 |
| Standard | 1,000 / day | 500 / day | 20 |
| Business | 10,000 / day | 5,000 / day | 100 |
| Enterprise | Custom | Custom | Custom |
Try out our APIs interactively in our API Playground.
Test queries against your knowledge stores and see results in real-time.
Try Knowledge Store API