Skip to content

API Endpoints

All endpoints are served by the Astromesh daemon (astromeshd) and are prefixed with /v1. The default base URL is http://localhost:8000.

Health check endpoint. Returns 200 if the daemon is running.

Response:

{
"status": "healthy",
"version": "0.10.0",
"uptime_seconds": 8072
}

List all loaded agents.

Response:

{
"agents": [
{
"name": "assistant",
"description": "General-purpose assistant",
"model": "openai/gpt-4o",
"orchestration": "react",
"status": "ready"
},
{
"name": "researcher",
"description": "Research and analysis agent",
"model": "anthropic/claude-sonnet-4-20250514",
"orchestration": "plan_and_execute",
"status": "ready"
}
]
}

Get details for a specific agent.

Path parameters:

ParameterTypeDescription
namestringAgent name as defined in YAML

Response:

{
"name": "assistant",
"description": "General-purpose assistant",
"model": {
"primary": { "provider": "openai", "model": "gpt-4o" },
"fallback": { "provider": "anthropic", "model": "claude-sonnet-4-20250514" },
"routing": "cost_optimized"
},
"orchestration": { "pattern": "react", "max_iterations": 10, "timeout": 120 },
"tools": ["web_search", "knowledge_base"],
"memory": { "conversational": "redis", "semantic": "chroma" },
"status": "ready"
}

Errors:

StatusDescription
404Agent not found

Execute an agent with a user query.

Path parameters:

ParameterTypeDescription
namestringAgent name

Request body:

{
"query": "What are the latest trends in AI?",
"session_id": "sess_abc123"
}
FieldTypeRequiredDescription
querystringYesUser input text
session_idstringNoSession ID for memory continuity. Auto-generated if omitted

Response:

{
"response": "Based on my research, the latest trends in AI include...",
"session_id": "sess_abc123",
"tool_calls": [
{
"tool": "web_search",
"input": { "query": "latest AI trends 2026" },
"output": "..."
}
],
"usage": {
"input_tokens": 1250,
"output_tokens": 430,
"total_tokens": 1680
},
"timing": {
"total_ms": 3200,
"model_ms": 2800,
"tool_ms": 400
},
"model": "openai/gpt-4o",
"provider": "openai"
}

Errors:

StatusDescription
404Agent not found
503All providers unavailable
408Orchestration timeout exceeded

Retrieve conversational history for an agent session.

Path parameters:

ParameterTypeDescription
agentstringAgent name
sessionstringSession ID

Response:

{
"agent": "assistant",
"session_id": "sess_abc123",
"messages": [
{ "role": "user", "content": "Hello" },
{ "role": "assistant", "content": "Hi! How can I help?" },
{ "role": "user", "content": "What is Astromesh?" },
{ "role": "assistant", "content": "Astromesh is..." }
]
}

DELETE /v1/memory/{agent}/history/{session}

Section titled “DELETE /v1/memory/{agent}/history/{session}”

Clear conversational history for an agent session.

Path parameters:

ParameterTypeDescription
agentstringAgent name
sessionstringSession ID

Response:

{
"status": "cleared",
"agent": "assistant",
"session_id": "sess_abc123"
}

Query semantic memory for an agent.

Path parameters:

ParameterTypeDescription
agentstringAgent name

Query parameters:

ParameterTypeDefaultDescription
querystring(required)Text to search for semantically similar entries
top_kinteger5Number of results to return

Response:

{
"results": [
{
"text": "Previous conversation about deployment...",
"score": 0.92,
"metadata": { "session_id": "sess_xyz", "timestamp": "2026-03-08T14:30:00Z" }
}
]
}

List all registered tools across all agents.

Response:

{
"tools": [
{
"name": "web_search",
"type": "internal",
"description": "Search the web for current information",
"agents": ["assistant", "researcher"]
},
{
"name": "mcp_filesystem",
"type": "mcp",
"description": "File system operations",
"agents": ["assistant"]
}
]
}

Execute a tool directly (outside of an agent context).

Request body:

{
"tool": "web_search",
"input": {
"query": "Astromesh documentation",
"max_results": 3
}
}

Response:

{
"tool": "web_search",
"output": {
"results": [
{ "title": "Astromesh Docs", "url": "https://..." }
]
},
"timing_ms": 320
}

Ingest documents into a RAG collection.

Request body:

{
"collection": "product_docs",
"documents": [
{
"text": "Astromesh supports multiple LLM providers...",
"metadata": { "source": "docs", "page": 1 }
}
],
"chunk_size": 512,
"chunk_overlap": 50
}
FieldTypeRequiredDefaultDescription
collectionstringYesTarget collection name
documentsarrayYesDocuments to ingest (text + metadata)
chunk_sizeintegerNo512Characters per chunk for splitting
chunk_overlapintegerNo50Overlap between chunks

Response:

{
"collection": "product_docs",
"documents_ingested": 1,
"chunks_created": 4
}

Query a RAG collection.

Request body:

{
"collection": "product_docs",
"query": "How does the model router work?",
"top_k": 5,
"score_threshold": 0.7
}
FieldTypeRequiredDefaultDescription
collectionstringYesCollection to search
querystringYesNatural language query
top_kintegerNo5Maximum results
score_thresholdfloatNo0.0Minimum similarity score

Response:

{
"results": [
{
"text": "The Model Router selects which LLM provider...",
"score": 0.89,
"metadata": { "source": "docs", "page": 3 }
}
]
}

List all available built-in tools with metadata.

Response:

{
"tools": [
{
"name": "datetime_now",
"description": "Get the current date and time with optional timezone",
"parameters": {
"type": "object",
"properties": {
"timezone": {
"type": "string",
"description": "Timezone name (e.g. 'UTC', 'US/Eastern')"
}
}
}
}
],
"count": 17
}

List collected traces with optional filtering.

Query parameters:

ParameterTypeDefaultDescription
agentstringFilter by agent name
limitinteger20Max traces to return (1-100)

Response:

{
"traces": [
{
"trace_id": "abc123",
"agent": "assistant",
"session_id": "sess_xyz",
"spans": [
{
"name": "agent.run",
"span_id": "s1",
"duration_ms": 2340,
"attributes": {"agent": "assistant"},
"status": "OK"
}
]
}
]
}

Get a specific trace by ID.

Path parameters:

ParameterTypeDescription
trace_idstringTrace identifier

Errors:

StatusDescription
404Trace not found

Get in-memory counters and histograms.

Response:

{
"counters": {
"agent.runs": 150,
"tool.executions": 420
},
"histograms": {
"agent.latency_ms": {
"count": 150,
"sum": 345000,
"avg": 2300,
"min": 450,
"max": 8900
}
}
}

Clear all in-memory metrics.

Response:

{
"status": "reset"
}

System status including version, uptime, and resource usage.

Response:

{
"version": "0.10.0",
"status": "running",
"mode": "standalone",
"pid": 48291,
"uptime_seconds": 8072,
"agents_loaded": 3,
"providers": {
"healthy": 2,
"degraded": 0,
"unavailable": 0
}
}

Run health checks on all subsystems.

Response:

{
"checks": [
{ "name": "runtime", "status": "healthy", "message": null },
{ "name": "openai", "status": "healthy", "message": "avg latency: 420ms" },
{ "name": "redis", "status": "healthy", "message": null },
{ "name": "chromadb", "status": "failing", "message": "connection refused on localhost:8000" }
],
"summary": {
"healthy": 3,
"degraded": 0,
"failing": 1
}
}

These endpoints are only available when mesh mode is enabled (ASTROMESH_MESH_ENABLED=true).

Get the full mesh state as seen by this node.

Response:

{
"this_node": "node-beta",
"leader": "node-alpha",
"nodes": [
{
"node_id": "node-alpha",
"address": "10.0.1.10:8000",
"state": "alive",
"heartbeat": 4521,
"agents": ["assistant", "support"],
"active_requests": 12
},
{
"node_id": "node-beta",
"address": "10.0.1.11:8000",
"state": "alive",
"heartbeat": 4519,
"agents": ["researcher"],
"active_requests": 5
}
]
}

Request to join the cluster. Called by new nodes during startup.

Request body:

{
"node_id": "node-gamma",
"address": "10.0.1.12:8000",
"agents": ["assistant"],
"meta": { "version": "0.10.0" }
}

Response:

{
"status": "joined",
"leader": "node-alpha",
"cluster_size": 3
}

Gracefully leave the cluster. Notifies peers and drains requests.

Request body:

{
"node_id": "node-gamma"
}

Response:

{
"status": "left",
"drained_requests": 2
}

Receive a heartbeat from a peer node.

Request body:

{
"node_id": "node-alpha",
"heartbeat": 4522,
"active_requests": 14
}

Response:

{
"ack": true
}

Exchange gossip state with a peer. Push-pull: receives the sender’s state and returns this node’s state.

Request body:

{
"sender": "node-alpha",
"state": [
{ "node_id": "node-alpha", "heartbeat": 4522, "state": "alive", "agents": ["assistant"] },
{ "node_id": "node-beta", "heartbeat": 4519, "state": "alive", "agents": ["researcher"] }
]
}

Response:

{
"sender": "node-beta",
"state": [
{ "node_id": "node-alpha", "heartbeat": 4520, "state": "alive", "agents": ["assistant"] },
{ "node_id": "node-beta", "heartbeat": 4520, "state": "alive", "agents": ["researcher"] },
{ "node_id": "node-gamma", "heartbeat": 4510, "state": "suspect", "agents": ["assistant"] }
]
}

Trigger or participate in a leader election.

Request body:

{
"type": "election",
"sender": "node-beta"
}
type ValueDescription
electionInitiate election. Higher-ID nodes respond with ok
okResponse from a higher-ID node (it will take over the election)
coordinatorAnnouncement from the new leader

Response:

{
"type": "ok",
"sender": "node-gamma"
}

Stream agent responses in real-time over WebSocket.

Path parameters:

ParameterTypeDescription
namestringAgent name

Client sends:

{
"query": "Explain quantum computing",
"session_id": "sess_abc123"
}

Server sends (multiple messages):

Token chunks:

{
"type": "token",
"content": "Quantum"
}

Tool call notification:

{
"type": "tool_call",
"tool": "web_search",
"input": { "query": "quantum computing basics" }
}

Tool result:

{
"type": "tool_result",
"tool": "web_search",
"output": "..."
}

Completion:

{
"type": "done",
"usage": {
"input_tokens": 800,
"output_tokens": 350,
"total_tokens": 1150
},
"timing": {
"total_ms": 2400
}
}

Error:

{
"type": "error",
"message": "Provider unavailable"
}