安全公告 — 恶意 litellm 版本 1.82.7 与 1.82.8 已从 PyPI 移除(存在 API 密钥外泄风险)。请卸载、轮换已暴露凭据,并升级至安全版本(如 1.82.9+)。运行 pip show litellm 以确认。 PyPI · README

部署

在生产环境中部署 AgenticX。

部署

概述

AgenticX 可按以下方式部署:

  • 独立 API 服务器
  • Docker 容器
  • Docker Compose 栈(含数据库与向量存储)

API 服务器

bash
1# Start the Studio API server
2agx serve --port 8000 --host 0.0.0.0
3
4# Or with uvicorn directly
5uvicorn agenticx.server:app --host 0.0.0.0 --port 8000 --workers 4

Docker

dockerfile
1FROM python:3.11-slim
2
3WORKDIR /app
4COPY requirements.txt .
5RUN pip install -r requirements.txt
6
7COPY . .
8
9ENV OPENAI_API_KEY=""
10EXPOSE 8000
11
12CMD ["agx", "serve", "--port", "8000", "--host", "0.0.0.0"]
bash
1docker build -t agenticx-app .
2docker run -p 8000:8000 -e OPENAI_API_KEY=sk-... agenticx-app

Docker Compose

仓库自带可直接使用的 Compose 文件:

bash
1# Minimal setup (app + SQLite)
2docker compose -f deploy/docker-compose.minimal.yml up
3
4# Core setup (app + PostgreSQL + Redis)
5docker compose -f deploy/docker-compose.core.yml up
6
7# Full stack (+ Neo4j + vector stores)
8docker compose -f deploy/docker-compose.yml up

环境变量

bash
1cp deploy/env.example .env
2# Edit .env with your values
VariableDescription
OPENAI_API_KEYOpenAI API key
DATABASE_URLPostgreSQL connection string
REDIS_URLRedis connection string
NEO4J_URINeo4j connection URI
AGX_MAX_TOOL_ROUNDSMax tool rounds per turn
AGX_SECRET_KEYSession signing key

Nginx 反向代理

nginx
1server {
2 listen 80;
3 server_name api.yourdomain.com;
4
5 location / {
6 proxy_pass http://localhost:8000;
7 proxy_http_version 1.1;
8 proxy_set_header Upgrade $http_upgrade;
9 proxy_set_header Connection "upgrade";
10 proxy_set_header Host $host;
11 proxy_set_header X-Real-IP $remote_addr;
12 }
13}

健康检查

bash
1curl http://localhost:8000/health
2# {"status": "ok", "version": "0.x.x"}

扩容

高吞吐部署建议:

  1. 运行多个 worker:uvicorn agenticx.server:app --workers 8
  2. 使用 Redis 存储会话(替代 SQLite)
  3. 使用 PostgreSQL 持久化数据
  4. 部署在负载均衡器之后
  5. 使用 Kubernetes 编排