API Reference
Complete REST API documentation for AgenticAnts platform.
Base URL
https://api.agenticants.ai/v1Authentication
All API requests require authentication via API key:
curl https://api.agenticants.ai/v1/traces \
-H "Authorization: Bearer ants_sk_your_api_key_here"Rate Limits
| Plan | Rate Limit | Burst |
|---|---|---|
| Pro | 1,000 req/min | 100 |
| Enterprise | Custom | Custom |
Rate limit headers:
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 950
X-RateLimit-Reset: 1635724800Common Headers
Request Headers
Authorization: Bearer <api_key>
Content-Type: application/json
X-Request-ID: <unique_id>Response Headers
Content-Type: application/json
X-Request-ID: <unique_id>
X-RateLimit-Limit: 1000
X-RateLimit-Remaining: 950Endpoints
Traces
Create Trace
POST /v1/tracesRequest:
{
"name": "customer-support-query",
"input": "Help with my order",
"metadata": {
"userId": "user_123",
"sessionId": "session_abc"
},
"tags": {
"environment": "production",
"team": "support"
}
}Response:
{
"id": "trace_abc123",
"name": "customer-support-query",
"startTime": "2025-10-23T14:23:45Z",
"status": "in_progress",
"input": "Help with my order",
"metadata": {...},
"tags": {...}
}Get Trace
GET /v1/traces/{trace_id}Response:
{
"id": "trace_abc123",
"name": "customer-support-query",
"startTime": "2025-10-23T14:23:45Z",
"endTime": "2025-10-23T14:23:48Z",
"duration": 2500,
"status": "completed",
"input": "Help with my order",
"output": "I can help you track your order...",
"spans": [...],
"tokens": 350,
"cost": 0.0105,
"metadata": {...}
}List Traces
GET /v1/traces?limit=100&offset=0&status=completedQuery Parameters:
limit- Number of results (default: 100, max: 1000)offset- Pagination offsetstatus- Filter by status:in_progress,completed,erroragent- Filter by agent namestartDate- ISO 8601 dateendDate- ISO 8601 date
Response:
{
"data": [
{...},
{...}
],
"pagination": {
"total": 1234,
"limit": 100,
"offset": 0,
"hasMore": true
}
}Update Trace
PATCH /v1/traces/{trace_id}Request:
{
"output": "I can help you track your order...",
"status": "completed",
"metadata": {
"success": true
}
}Spans
Create Span
POST /v1/traces/{trace_id}/spansRequest:
{
"name": "llm-inference",
"parentId": null,
"startTime": "2025-10-23T14:23:46Z",
"attributes": {
"model": "gpt-4",
"temperature": 0.7
}
}End Span
PATCH /v1/spans/{span_id}Request:
{
"endTime": "2025-10-23T14:23:48Z",
"status": "ok",
"output": {...}
}Metrics
Query Metrics
POST /v1/metrics/queryRequest:
{
"metric": "latency_p95",
"agent": "customer-support",
"startDate": "2025-10-01T00:00:00Z",
"endDate": "2025-10-31T23:59:59Z",
"granularity": "1h"
}Response:
{
"metric": "latency_p95",
"data": [
{"timestamp": "2025-10-01T00:00:00Z", "value": 1850},
{"timestamp": "2025-10-01T01:00:00Z", "value": 1920},
...
]
}Available Metrics
| Metric | Description | Unit |
|---|---|---|
latency_p50 | 50th percentile latency | ms |
latency_p95 | 95th percentile latency | ms |
latency_p99 | 99th percentile latency | ms |
throughput | Requests per second | req/s |
error_rate | Error percentage | % |
token_count | Total tokens used | tokens |
cost | Total cost | USD |
Agents
List Agents
GET /v1/agentsResponse:
{
"data": [
{
"id": "agent_123",
"name": "customer-support",
"version": "1.2.3",
"framework": "langchain",
"model": "gpt-4",
"status": "active",
"createdAt": "2025-10-01T00:00:00Z"
}
]
}Get Agent Metrics
GET /v1/agents/{agent_id}/metricsResponse:
{
"agent": "customer-support",
"period": "last_24h",
"metrics": {
"totalRequests": 1234,
"avgLatency": 1850,
"errorRate": 0.5,
"totalCost": 45.67
}
}Webhooks
Create Webhook
POST /v1/webhooksRequest:
{
"url": "https://your-app.com/webhooks/agenticants",
"events": ["trace.completed", "alert.triggered"],
"secret": "whsec_your_webhook_secret"
}Webhook Events
| Event | Description |
|---|---|
trace.completed | Trace finished |
trace.error | Trace had error |
alert.triggered | Alert condition met |
budget.exceeded | Budget threshold exceeded |
pii.detected | PII found in data |
Webhook Payload:
{
"event": "trace.completed",
"timestamp": "2025-10-23T14:23:48Z",
"data": {
"traceId": "trace_abc123",
"agent": "customer-support",
"duration": 2500,
"status": "completed"
}
}Error Handling
Error Response Format
{
"error": {
"code": "invalid_request",
"message": "Missing required field: name",
"details": {
"field": "name",
"reason": "required"
}
}
}Error Codes
| Code | HTTP Status | Description |
|---|---|---|
invalid_request | 400 | Invalid request body |
authentication_failed | 401 | Invalid API key |
permission_denied | 403 | Insufficient permissions |
not_found | 404 | Resource not found |
rate_limit_exceeded | 429 | Too many requests |
internal_error | 500 | Server error |
SDKs
JavaScript/TypeScript
npm install @agenticants/sdkimport { AgenticAnts } from '@agenticants/sdk'
const ants = new AgenticAnts({
apiKey: process.env.AGENTICANTS_API_KEY
})Python
pip install agenticantsfrom agenticants import AgenticAnts
ants = AgenticAnts(api_key=os.getenv('AGENTICANTS_API_KEY'))Code Examples
Complete Trace Example
# 1. Create trace
curl -X POST https://api.agenticants.ai/v1/traces \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "customer-support",
"input": "Help with order"
}'
# Response: {"id": "trace_123", ...}
# 2. Create span
curl -X POST https://api.agenticants.ai/v1/traces/trace_123/spans \
-H "Authorization: Bearer $API_KEY" \
-d '{
"name": "llm-call",
"startTime": "2025-10-23T14:23:45Z"
}'
# Response: {"id": "span_456", ...}
# 3. End span
curl -X PATCH https://api.agenticants.ai/v1/spans/span_456 \
-H "Authorization: Bearer $API_KEY" \
-d '{
"endTime": "2025-10-23T14:23:47Z",
"status": "ok"
}'
# 4. Complete trace
curl -X PATCH https://api.agenticants.ai/v1/traces/trace_123 \
-H "Authorization: Bearer $API_KEY" \
-d '{
"output": "Your order is on the way!",
"status": "completed"
}'Versioning
API version is specified in the URL: /v1/
- Current version: v1
- Stable: Yes
- Deprecation notice: 6 months minimum
Support
- Documentation: https://agenticants.ai/docs (opens in a new tab)
- Status: https://status.agenticants.ai (opens in a new tab)
- Support: support@agenticants.ai
Next Steps
- Authentication - Detailed auth guide
- Traces API - Complete traces documentation
- Webhooks - Set up webhooks