-
Notifications
You must be signed in to change notification settings - Fork 168
Deployment Guide
weego edited this page May 28, 2026
·
1 revision
LightAgent is a Python library. Most production deployments wrap it in an application service such as FastAPI, Flask, a worker process, or an internal automation job.
Use environment variables for provider credentials:
export OPENAI_API_KEY="your_api_key"
export OPENAI_BASE_URL="https://api.openai.com/v1"Avoid hardcoding keys in code, examples, or Wiki pages.
from fastapi import FastAPI
from pydantic import BaseModel
from LightAgent import LightAgent
app = FastAPI()
agent = LightAgent(
model="gpt-4.1",
api_key=None,
base_url=None,
)
class ChatRequest(BaseModel):
query: str
user_id: str = "default_user"
@app.post("/chat")
def chat(req: ChatRequest):
result = agent.run(req.query, user_id=req.user_id, result_format="object")
return {
"content": result.content,
"trace_id": result.trace_id,
"error": result.error,
}Use stream=True when building a streaming endpoint:
def generate(query: str, user_id: str):
for chunk in agent.run(query, stream=True, user_id=user_id):
yield chunkFor typed events, use result_format="event" and serialize each StreamEvent.
- Pin package versions.
- Use environment variables or secret managers.
- Add request timeouts at the application layer.
- Keep tool outputs compact.
- Add memory namespace policies for shared backends.
- Disable or isolate built-in code execution tools for untrusted users.
- Enable trace only where data handling is approved.
- Add rate limits and concurrency controls.
- Log
trace_id, user id, tool names, and status metadata.
LightAgent itself can be used in stateless request handlers, but memory backends, logs, trace exports, and application histories are stateful. Decide where each state type lives:
- conversation history: application database
- long-term memory: memory backend
- trace and logs: observability stack
- files and artifacts: object storage
LightAgent Wiki - see the repository, releases, and issues.
- Home
- Quick Start
- Core Concepts
- API Reference
- Examples Cookbook
- Migration Guide
- Tools
- Tool Generator
- Memory
- MCP
- Skills
- LightFlow
- Tree of Thought
- Self-Learning
- Multi-Agent
- Tracing and Debugging
- Langfuse Observability
- Model Providers
- browser-use Integration
- Testing and CI
- Deployment Guide
- Architecture
- Security
- Known Limitations
- FAQ
- FAQ 中文
- Roadmap
- Release Process
- Contributing