Agent Server¶
Drop-in FastAPI wrapper — POST /invoke, POST /stream,
GET/DELETE /threads/{id}, GET /health.
AgentServer ¶
AgentServer(agent: Any, title: str = 'Locus Agent Server', description: str = 'HTTP API for a Locus AI Agent', api_key: str | None = None, allow_unauthenticated: bool = False)
Wrap a Locus Agent as a FastAPI application.
Example
from locus.agent import Agent, AgentConfig from locus.server import AgentServer
agent = Agent(config=AgentConfig(system_prompt="Hello", model=model)) server = AgentServer(agent=agent, api_key="secret") server.run(host="127.0.0.1", port=8000)
Source code in src/locus/server/app.py
run ¶
Run the server with uvicorn.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
host
|
str
|
Bind address. Defaults to loopback — using a
non-loopback host requires either |
'127.0.0.1'
|
port
|
int
|
Bind port. |
8000
|
**kwargs
|
Any
|
Additional uvicorn.run() arguments. |
{}
|