API Reference
Complete reference for the Agero API — chat, retrieval, and source management endpoints with interactive code examples.
API Reference
Complete reference for the Agero API — chat, retrieval, and source management endpoints with interactive code examples.
Authentication
API requests authenticate with either header format:
Authorization: Bearer spk_...
or:
x-api-key: spk_...
API keys support three permission types:
| Permission | Used for |
|---|---|
chat | Chat and chat streaming |
retrieve | Retrieval-only requests |
ingest | Source management and ingestion |
Origin allowlists
If a key has allowed origins configured, the request must include an Origin header that exactly matches
one of the configured values. Keys with no allowlist accept requests from any origin.
Error Responses
All errors follow a consistent envelope:
{
"error": {
"code": "UNAUTHORIZED",
"message": "Invalid credentials"
}
}
| Code | Status | Meaning |
|---|---|---|
UNAUTHORIZED | 401 | Missing or invalid API key |
FORBIDDEN | 403 | Origin not allowed for this key |
VALIDATION_ERROR | 400 | Request body did not match the schema |
NOT_FOUND | 404 | Resource does not exist or is not accessible |
RATE_LIMITED | 429 | Per-key rate limit exceeded |
LIMIT_EXCEEDED | 429 | Plan entitlement limit reached |
GONE | 410 | Route has moved or is no longer served here |
UNSUPPORTED_ATTACHMENT_TYPE | 400 | File type not supported by the selected model |
ATTACHMENT_TOO_LARGE | 400 | Total attachment size exceeds model limit |
UNSUPPORTED_TYPE | 400 | File type not allowed for upload |
FILE_TOO_LARGE | 400 | File exceeds the per-type upload size limit |
INTERNAL_ERROR | 500 | Unexpected server failure |
Endpoints
Chat & Retrieval
Send messages, stream responses, and search the knowledge base.
/api/v1/chatDeprecated — returns 410 GONE. Use POST /api/v1/chat/stream instead for both streaming and non-streaming use cases.
curl -X POST https://your-domain.com/api/v1/chat \
-H "Authorization: Bearer spk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"message": "What are your opening hours?"}'Request body
{
"message": "What are your opening hours?",
"conversationId": "optional",
"endUserId": "optional"
}Response
{
"reply": "We are open 9am–6pm Monday to Friday.",
"conversationId": "conv_abc123",
"citations": [
{
"title": "FAQ",
"url": null,
"similarity": 0.92
}
],
"media": []
}/api/v1/chat/streamStream a response using Server-Sent Events. Compatible with the Vercel AI SDK client. Send as JSON for text-only, or as multipart/form-data to include file attachments (images, PDFs) for multimodal models.
# Text-only (JSON)
curl -X POST https://your-domain.com/api/v1/chat/stream \
-H "Authorization: Bearer spk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"message": "Tell me about your products"}' \
--no-buffer
# With file attachments (multipart)
curl -X POST https://your-domain.com/api/v1/chat/stream \
-H "Authorization: Bearer spk_your_api_key" \
-F "message=Describe this image" \
-F "files=@photo.png" \
--no-buffer
# Multiple files
curl -X POST https://your-domain.com/api/v1/chat/stream \
-H "Authorization: Bearer spk_your_api_key" \
-F "message=Compare these documents" \
-F "files=@report.pdf" \
-F "files=@chart.png" \
--no-bufferRequest body
// JSON (text-only)
{
"message": "Tell me about your products",
"conversationId": "optional",
"endUserId": "optional"
}
// multipart/form-data (with files)
// Fields: message, files[] (up to 10), conversationId?, endUserId?Response
// SSE stream — text deltas, citations, and a final done event/api/v1/retrieveSearch the knowledge base without AI generation. Useful for custom search UIs.
curl -X POST https://your-domain.com/api/v1/retrieve \
-H "Authorization: Bearer spk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"query": "pricing plans", "topK": 5}'Request body
{
"query": "pricing plans",
"topK": 5,
"threshold": 0.7
}Response
{
"results": [
{
"content": "Our plans start at $29/mo...",
"title": "Pricing",
"url": "https://example.com/pricing",
"similarity": 0.94
}
]
}Sources
Manage knowledge sources programmatically. Requires an API key with the ingest permission.
/v1/sourcesList sources with cursor-based pagination. Filter by status or type.
curl https://api.agero.tech/v1/sources?limit=20&status=READY \
-H "Authorization: Bearer spk_your_api_key"Request body
// Query params: ?limit=20&status=READY&type=URL&cursor=clx...Response
{
"data": {
"sources": [
{
"id": "clx...",
"type": "URL",
"name": "Help center",
"status": "READY",
"config": {
"url": "https://help.example.com"
},
"latestJob": {
"id": "clx...",
"status": "SUCCEEDED",
"progress": 100
}
}
],
"nextCursor": "clx..."
}
}/v1/sourcesCreate a new knowledge source. Supports URL, SITEMAP, FILE, and IMAGE types. Ingestion starts automatically unless autoSync is false.
curl -X POST https://api.agero.tech/v1/sources \
-H "Authorization: Bearer spk_your_api_key" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: my-unique-key" \
-d '{"type":"URL","name":"Help center","config":{"url":"https://help.example.com","maxDepth":3}}'Request body
{
"type": "URL",
"name": "Help center",
"config": {
"url": "https://help.example.com",
"maxDepth": 3
},
"autoSync": true
}Response
{
"data": {
"source": {
"id": "clx...",
"type": "URL",
"name": "Help center",
"status": "PENDING"
},
"ingestionJob": {
"id": "clx...",
"status": "QUEUED"
}
}
}/v1/sources/:idDelete a source and all its associated documents and chunks.
curl -X DELETE https://api.agero.tech/v1/sources/SOURCE_ID \
-H "Authorization: Bearer spk_your_api_key"Request body
// No request bodyResponse
{
"data": {
"id": "clx...",
"deleted": true
}
}/v1/sources/:id/syncTrigger an ingestion or full re-index for a source. Use force: true for a complete re-index.
curl -X POST https://api.agero.tech/v1/sources/SOURCE_ID/sync \
-H "Authorization: Bearer spk_your_api_key" \
-H "Content-Type: application/json" \
-d '{"force": false}'Request body
{
"force": false
}Response
{
"data": {
"jobId": "clx...",
"status": "QUEUED",
"sourceId": "clx..."
}
}File Attachments
Send images and documents alongside your chat message in a single request. Just send POST /api/v1/chat/stream as multipart/form-data instead of JSON:
curl -X POST https://your-domain.com/api/v1/chat/stream \
-H "Authorization: Bearer spk_..." \
-F "message=What is in this image?" \
-F "files=@photo.png"
No separate upload step — include the files directly. We detect the type, validate it against the model, and handle the rest.
Supported types: JPEG, PNG, WebP, GIF, PDF. Up to 10 files per message.
Size limits: Images 10 MB, documents 25 MB per file. Total per-message limits vary by model (e.g. 20 MB for OpenAI, 25 MB for Anthropic).
Model compatibility
Not all models support file inputs. If the selected model does not support the attachment type, the API returns a
400 error with code UNSUPPORTED_ATTACHMENT_TYPE. Vision models accept images; some also
accept PDFs. Text-only models reject all attachments.
Source Types
When creating sources via POST /v1/sources, use one of the following types:
| Type | Required config fields | Notes |
|---|---|---|
URL | config.url | Optional: maxDepth, includePatterns, excludePatterns |
SITEMAP | config.sitemapUrl or config.url | Optional: includePatterns, excludePatterns |
FILE | config.fileUrl | Optional: fileName |
IMAGE | config.fileUrl | Optional: fileName |
BULK_UPLOAD | Varies | Typically created via the dashboard |
Idempotency
Pass an Idempotency-Key header on POST /v1/sources to safely retry requests. Matching keys
within 24 hours return the original response without creating duplicates.
Related Docs
API Keys
Create and manage keys for chat, retrieve, and ingest use cases.
Tools
Enable built-in tools and create custom HTTP tools for your agent.
Sources
Add and monitor the content your agent retrieves from.