首页 教程 常见问题

Agent SDK 安全部署

安全部署 Agent SDK 代理到生产环境的最佳实践。

安全原则

API 密钥安全

import os

# 不要硬编码 API 密钥
# client = Anthropic(api_key="sk-ant-...")  # 错误做法

# 使用环境变量
client = Anthropic(api_key=os.environ.get("ANTHROPIC_API_KEY"))

# 或使用密钥管理服务
from vault import get_secret
client = Anthropic(api_key=get_secret("anthropic-api-key"))

沙箱环境

部署检查清单

下一步