AI
HTTP API
AgentController routes, payloads, and behavior
Route Registration
The AI extension does not mount routes automatically.
controller := ai.NewAgentController(app.Container())
api := app.Router().Group("/api")
controller.Routes(api)Registered Routes
| Method | Path | Handler |
|---|---|---|
GET | /agents | list agents |
POST | /agents | create agent |
GET | /agents/:id | get agent definition |
PUT | /agents/:id | update agent |
DELETE | /agents/:id | delete agent |
POST | /agents/:id/execute | execute agent |
POST | /agents/:id/chat | execute chat call |
GET | /agents/templates | list template types |
Request and Response Shapes
Create Agent
POST /agents
{
"name": "Cache Optimizer",
"type": "cache_optimizer",
"model": "gpt-4",
"temperature": 0.7,
"config": {}
}Notes:
modeldefaults togpt-4if omitted.temperaturedefaults to0.7if omitted.typemust match a built-in template type.
Execute Agent
POST /agents/:id/execute
{
"message": "Analyze cache hit-rate drop over the last 6 hours"
}Response includes agent_id and response.
Chat Endpoint
POST /agents/:id/chat
Behavior is currently equivalent to execute (same agent.Execute(...) call path).
List Templates
GET /agents/templates
Returns template identifiers from AgentFactory.ListTemplates().
Error Semantics
400: invalid JSON payload404: missing agent ID500: creation/execution/runtime errors
API Design Notes
- Agent objects are managed in-memory by
AgentManager. - Delete operation also attempts to remove conversation state from
StateStore. - If you need persistent agent metadata across restarts, store metadata in your own data layer.
How is this guide?