主题
LlamaCloud 支持与 Anthropic API 直连以访问 Claude 模型。当你想直接用上 Anthropic 最新的模型、又不想引入 AWS 基础设施依赖时,这是相对 AWS Bedrock 的更简单替代。
前置条件
- 一个有效的 Anthropic 账号
- 来自 Anthropic Console 的 Anthropic API key
- 所支持 Claude 模型的访问权限与配额:
- Claude Sonnet 4.5
环境变量
Anthropic API 集成只用一个环境变量:
ANTHROPIC_API_KEY—— 你的 Anthropic API key(必需)
配置
按下列步骤配置 Anthropic API 集成:
第 1 步:创建 Kubernetes Secret
用你的 Anthropic API key 创建一个 secret:
apiVersion: v1
kind: Secret
metadata:
name: anthropic-credentials
type: Opaque
stringData:
ANTHROPIC_API_KEY: "sk-ant-api03-your-api-key-here"把这个 secret 应用到集群:
终端窗口
kubectl apply -f anthropic-secret.yaml第 2 步:配置 Helm values
在你的 Helm 配置里引用这个 secret:
# External Secret
config:
llms:
anthropic:
secret: "anthropic-credentials"
# or direct configuration (not recommended for production)
config:
llms:
anthropic:
apiKey: "sk-ant-api03-your-api-key-here"验证
配置完成后,请这样验证你的 Anthropic 集成:
- 查看管理界面:确认 Claude 模型出现在 LlamaCloud 管理界面里
- 测试功能:上传一份文档,确认 Claude 模型确在工作
故障排查
常见问题
API key 无效
Error: Invalid API key解决办法:
- 确认 API key 正确且在 Anthropic Console 里可用
- 确认该 key 以
sk-ant-api03-开头 - 检查该 key 是否已过期
认证失败
Error: Authentication failed解决办法:
- 确认你的 Anthropic 账号状态正常
- 确认该 API key 具备必要的权限
- 检查你的账号是否已被暂停
被限流
Error: Rate limit exceeded解决办法:
- 查看你的 Anthropic 用量上限
- 考虑升级你的 Anthropic 套餐
- 必要时做好请求节流
- 盯住使用模式
模型访问问题
Error: Model not available or access denied解决办法:
- 确认你拥有该具体 Claude 模型的访问权
- 某些模型需要单独的准入批准
- 检查模型在你所在地域是否可用
配额超限
Error: Usage quota exceeded解决办法:
- 查看你 Anthropic 账号的用量与上限
- 为 Anthropic 账号充值
- 设好计费告警
- 考虑做用量优化
排查步骤
直接测试 API key:
终端窗口
curl https://api.anthropic.com/v1/messages \ -H "x-api-key: $ANTHROPIC_API_KEY" \ -H "content-type: application/json" \ -H "anthropic-version: 2023-06-01" \ -d '{ "model": "claude-sonnet-4-6", "max_tokens": 1024, "messages": [{"role": "user", "content": "Hello, Claude"}] }'检查 secret 是否已挂载:
终端窗口
kubectl get secret your-anthropic-secret -o yaml kubectl exec deployment/llamacloud-llamaparse -- env | grep ANTHROPIC检查网络连通性:确保你的集群能够访问
api.anthropic.com查日志拿详细错误:
终端窗口
kubectl logs deployment/llamacloud-llamaparse --tail=100 | grep -i error