Skip to content

API Reference

Complete REST API reference for the ByteBrew Engine. All endpoints return JSON (except SSE streams) and accept JSON request bodies.

All API requests must include a valid Ed25519-signed JWT or an API token in the Authorization header. The engine verifies every token with its Ed25519 public key — the password-based /auth/login endpoint has been removed.

Getting a JWT (self-hosted, local auth mode)

Section titled “Getting a JWT (self-hosted, local auth mode)”

With BYTEBREW_AUTH_MODE=local (the default) the engine auto-generates an Ed25519 keypair on first boot and mints tokens on demand:

Terminal window
curl -X POST http://localhost:8443/api/v1/auth/local-session
{"access_token": "eyJhbG...", "expires_at": "2026-03-23T07:00:00Z"}

The returned JWT can be used in the Authorization: Bearer <token> header for all subsequent requests.

In Cloud or any deployment with BYTEBREW_AUTH_MODE=external, the engine does not issue tokens itself. Obtain the JWT from your auth provider (ByteBrew Cloud API or your own IdP that signs with the engine’s configured Ed25519 public key) and pass it in the Authorization header.

For long-lived integrations, create API tokens through the Admin Dashboard:

  • Navigate to Admin Dashboard -> API Keys
  • Click “Create API Key” and select the scopes you need
  • Copy the token immediately — it is shown only once and cannot be recovered
  • Tokens are prefixed with bb_ for easy identification in logs and config
Terminal window
# curl
curl http://localhost:8443/api/v1/agents \
-H "Authorization: Bearer bb_your_api_token"
// JavaScript (fetch)
const response = await fetch('http://localhost:8443/api/v1/agents', {
headers: { 'Authorization': 'Bearer bb_your_api_token' },
});
# Python (requests)
import requests
response = requests.get(
'http://localhost:8443/api/v1/agents',
headers={'Authorization': 'Bearer bb_your_api_token'},
)
ScopeDescription
chatSend messages to schemas (POST /api/v1/schemas/{name}/chat) and respond to user input
tasksCreate, list, cancel tasks and provide input
agents:readList and inspect agent configurations
agents:writeCreate, update, and delete agents
models:readList and inspect model configurations
models:writeCreate, update, delete, and verify models
mcp:readList MCP server configurations
mcp:writeCreate, update, and delete MCP servers
configReload, export, and import configuration
adminFull access to all endpoints including API key management, settings, tokens, sessions, and audit
// 401 Unauthorized — missing or invalid token
{"error": "unauthorized", "message": "Invalid or expired API token"}
// 403 Forbidden — token lacks required scope
{"error": "forbidden", "message": "Token does not have 'config' scope"}

Base URL: http://localhost:8443/api/v1

Content-Type: application/json

Send a message to a schema and receive a stream of Server-Sent Events. This is the primary endpoint for building conversational interfaces. The schema must have Chat Enabled toggled on in Admin Dashboard → Schemas.

POST /api/v1/schemas/{name}/chat

The {name} is the schema name (a DNS-label like support-handbook), visible in Admin Dashboard → Schemas or returned by GET /api/v1/schemas. Schema names are declared in your configuration and are immutable post-create.

ParameterDefaultDescription
message *The user message to send to the agent.
session_idauto-generatedSession ID for continuing a conversation. Omit to start a new session.
Terminal window
# Start a new conversation
curl -N http://localhost:8443/api/v1/schemas/support-handbook/chat \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{"message": "What laptops do you have under $1000?"}'
EventDescription
thinkingInternal reasoning text (if the model supports it).
message_deltaText chunk from the agent. Concatenate all deltas for the full response.
messageComplete message (sent after all deltas).
tool_callAgent is executing a tool. For spawn_* calls, the sub-agent runs synchronously and the result returns via tool_result.
tool_resultTool execution result. Contains the output returned by the tool.
structured_outputStructured data block emitted by show_structured_output (table, info, or form). Client renders the block; form answers arrive as the next chat message.
confirmationInteractive pause — a confirm_before approval gate. Contains call_id for the respond endpoint.
errorAn error occurred during processing.
doneStream is complete. Contains session_id.
event: message_delta
data: {"content":"I found several laptops under $1000. "}
event: tool_call
data: {"tool":"search_products","input":{"query":"laptops under 1000","limit":"5"}}
event: tool_result
data: {"tool":"search_products","output":"[{\"name\":\"ProBook 450\",\"price\":849}...]"}
event: message_delta
data: {"content":"Here are the top options:\n\n1. **ProBook 450** — $849..."}
event: message
data: {"content":"I found several laptops under $1000. Here are the top options:\n\n1. **ProBook 450** — $849..."}
event: done
data: {"session_id":"a1b2c3d4-e5f6-7890-abcd-ef1234567890"}
Terminal window
curl -N http://localhost:8443/api/v1/schemas/support-handbook/chat \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{"message": "Tell me more about the ProBook 450", "session_id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890"}'

List and inspect configured agents. Requires agents:read or admin scope.

Terminal window
# List all agents
curl http://localhost:8443/api/v1/agents \
-H "Authorization: Bearer bb_your_token"
[
{
"name": "sales-agent",
"model": "glm-5",
"lifecycle": "persistent",
"tools_count": 5,
"has_knowledge": true
}
]
Terminal window
# Get agent details
curl http://localhost:8443/api/v1/agents/sales-agent \
-H "Authorization: Bearer bb_your_token"
{
"name": "sales-agent",
"model": "glm-5",
"lifecycle": "persistent",
"tools": ["knowledge_search", "search_products", "create_order"],
"mcp_servers": ["crm-api"],
"can_spawn": ["researcher"],
"max_steps": 50,
"max_context_size": 16000
}
Terminal window
curl -X POST http://localhost:8443/api/v1/agents \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{
"name": "my-agent",
"system": "You are a helpful assistant.",
"model": "glm-5",
"tools": ["knowledge_search"],
"can_spawn": ["researcher"],
"lifecycle": "persistent",
"max_steps": 50
}'
Terminal window
curl -X PUT http://localhost:8443/api/v1/agents/my-agent \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{"system": "Updated prompt.", "max_steps": 100}'
Terminal window
curl -X DELETE http://localhost:8443/api/v1/agents/my-agent \
-H "Authorization: Bearer bb_your_token"
# Returns 204 No Content

CRUD for LLM model providers. Requires admin scope.

Terminal window
curl http://localhost:8443/api/v1/models \
-H "Authorization: Bearer bb_your_token"
[
{
"id": 1,
"name": "qwen3",
"type": "ollama",
"base_url": "http://localhost:11434",
"model_name": "qwen3:30b-a3b",
"has_api_key": false,
"created_at": "2026-03-20T12:00:00Z"
}
]
Terminal window
curl -X POST http://localhost:8443/api/v1/models \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{
"name": "my-model",
"type": "ollama",
"model_name": "llama3.2",
"base_url": "http://localhost:11434",
"api_key": "ollama"
}'

Supported types: ollama, openai_compatible, anthropic, azure_openai, google, openrouter, deepseek, mistral, xai, zai.

Terminal window
curl -X PUT http://localhost:8443/api/v1/models/my-model \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{"api_key": "new-key", "model_name": "qwen3:70b"}'

API key is only updated if a non-empty value is provided.

Terminal window
curl -X DELETE http://localhost:8443/api/v1/models/my-model \
-H "Authorization: Bearer bb_your_token"
# Returns 204 No Content

Test that a model is accessible and supports tool calling before using it.

Terminal window
curl -X POST http://localhost:8443/api/v1/models/my-model/verify \
-H "Authorization: Bearer bb_your_token"
{
"connectivity": "ok",
"tool_calling": "supported",
"response_time_ms": 1240,
"model_name": "llama3.2",
"provider": "ollama",
"error": null
}
FieldValuesDescription
connectivityok, errorWhether the API endpoint is accessible
tool_callingsupported, not_detected, skippedWhether the model generates tool calls
response_time_msnumberLatency of the ping request
errorstring or nullError details if connectivity failed

When an agent reaches a confirm_before gate, the client receives a confirmation SSE event. Use this endpoint to send the user’s approval or rejection back to the agent.

Terminal window
curl -X POST http://localhost:8443/api/v1/sessions/{session_id}/respond \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{
"call_id": "conf_abc123",
"answers": ["approve"]
}'

The call_id comes from the SSE event’s metadata. The agent receives the answer and continues execution.

Manage conversation sessions. Sessions store the full message history between a user and an agent. Requires chat or admin scope.

Terminal window
# List sessions (with optional filters)
curl "http://localhost:8443/api/v1/sessions?agent=sales-agent&limit=10" \
-H "Authorization: Bearer bb_your_token"
{
"sessions": [
{
"id": "a1b2c3d4",
"agent": "sales-agent",
"created_at": "2025-03-19T10:00:00Z",
"message_count": 12
}
]
}
Terminal window
# Get session with messages
curl http://localhost:8443/api/v1/sessions/a1b2c3d4 \
-H "Authorization: Bearer bb_your_token"
# Delete session
curl -X DELETE http://localhost:8443/api/v1/sessions/a1b2c3d4 \
-H "Authorization: Bearer bb_your_token"

Create and manage agent tasks. Tasks are units of work that agents process asynchronously — they can be created by users, triggers, or other agents. Requires tasks or admin scope.

Terminal window
# Create a task
curl -X POST http://localhost:8443/api/v1/tasks \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-d '{
"agent": "researcher",
"title": "Market analysis Q1",
"description": "Analyze Q1 2025 market trends for the SaaS sector"
}'
{
"id": "task_abc123",
"agent": "researcher",
"title": "Market analysis Q1",
"status": "pending",
"created_at": "2025-03-19T14:30:00Z"
}
Terminal window
# List tasks with filters
curl "http://localhost:8443/api/v1/tasks?status=pending&agent=researcher" \
-H "Authorization: Bearer bb_your_token"
# Get task details
curl http://localhost:8443/api/v1/tasks/task_abc123 \
-H "Authorization: Bearer bb_your_token"
# Cancel a task (pending or in_progress only)
curl -X DELETE http://localhost:8443/api/v1/tasks/task_abc123 \
-H "Authorization: Bearer bb_your_token"
StatusDescription
pendingTask created, waiting to be picked up by the agent.
in_progressAgent is actively working on the task.
needs_inputAgent paused and waiting for user input (e.g., confirmation).
completedTask finished successfully.
failedTask failed due to an error.
cancelledTask was cancelled by a user or API call.

Manage engine configuration at runtime. Hot-reload applies changes without restarting the engine. Export/import enable GitOps workflows. Requires config or admin scope.

Terminal window
# Hot-reload configuration from the database
curl -X POST http://localhost:8443/api/v1/config/reload \
-H "Authorization: Bearer bb_your_token"
# Response
# {"status":"ok","agents_loaded":4,"models_loaded":3}
# Export current config as YAML (secrets are excluded)
curl http://localhost:8443/api/v1/config/export \
-H "Authorization: Bearer bb_your_token" \
-o config-backup.yaml
# Import YAML config (merges with existing)
curl -X POST http://localhost:8443/api/v1/config/import \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/x-yaml" \
--data-binary @new-config.yaml
# Response
# {"status":"ok","agents_imported":2,"models_imported":1,"tools_imported":3}

Check engine status. No authentication required — useful for load balancer health checks.

Terminal window
curl http://localhost:8443/api/v1/health
{
"status": "ok",
"version": "1.0.0",
"agents_count": 4,
"uptime": "2h34m12s"
}

Bring Your Own Key lets API consumers override the model for a single request. This must be enabled in Settings for each provider. Useful for multi-tenant deployments where each customer provides their own API key.

Terminal window
curl -N http://localhost:8443/api/v1/schemas/{schema_id}/chat \
-H "Authorization: Bearer bb_your_token" \
-H "Content-Type: application/json" \
-H "X-Model-Provider: anthropic" \
-H "X-Model-API-Key: sk-ant-user-provided-key" \
-H "X-Model-Name: claude-sonnet-4-20250514" \
-d '{"message": "Hello"}'

Browse the built-in catalog of known models and providers. No authentication required.

Terminal window
# List all models (filterable by provider, tier, supports_tools)
curl "http://localhost:8443/api/v1/models/registry?provider=anthropic&tier=1"
# List all providers
curl http://localhost:8443/api/v1/models/registry/providers

See Model Registry for full documentation.

Query tool call history for compliance and debugging. Requires admin scope.

Terminal window
curl "http://localhost:8443/api/v1/audit/tool-calls?agent=sales-agent&from=2026-03-01" \
-H "Authorization: Bearer bb_your_token"

Returns paginated results with session ID, agent name, tool name, input/output, status, duration, and timestamp. See REST API: Tool call audit log for the full query parameter reference.

Check current rate limit consumption for a specific key. Requires admin scope.

Terminal window
curl "http://localhost:8443/api/v1/rate-limits/usage?key_header=X-Org-Id&key_value=org-123" \
-H "Authorization: Bearer bb_your_token"

Returns rule name, key, tier, used/limit counts, window duration, and reset time. See Configuration: Rate Limits for setup.

Terminal window
curl http://localhost:8443/metrics

Returns Prometheus-compatible metrics. No authentication required. See Production: Prometheus Metrics for available metric names and Kubernetes integration.