Anthropic API Setup
Loading...
LlamaCloud supports direct integration with the Anthropic API for accessing Claude models. This provides a simple alternative to AWS Bedrock when you want direct access to Anthropicâs latest models without AWS infrastructure dependencies.
Prerequisites
Section titled âPrerequisitesâ- A valid Anthropic account
- Anthropic API key from Anthropic Console
- Access and quota to supported Claude models:
- Claude 3.5 Haiku
- Claude 3.5 Sonnet
- Claude 3.5 Sonnet V2
- Claude 3.7 Sonnet
- Claude 4 Sonnet
Environment Variables
Section titled âEnvironment VariablesâThe Anthropic API integration uses a single environment variable:
ANTHROPIC_API_KEY
- Your Anthropic API key (required)
Configuration
Section titled âConfigurationâFollow these steps to configure Anthropic API integration:
Step 1: Create Kubernetes Secret
Section titled âStep 1: Create Kubernetes SecretâCreate a secret with your Anthropic API key:
apiVersion: v1kind: Secretmetadata: name: anthropic-credentialstype: OpaquestringData: ANTHROPIC_API_KEY: "sk-ant-api03-your-api-key-here"
Apply the secret to your cluster:
kubectl apply -f anthropic-secret.yaml
Step 2: Configure Helm Values
Section titled âStep 2: Configure Helm ValuesâReference the secret in your Helm configuration:
# External SecretllamaParse: config: existingAnthropicApiKeySecret: "anthropic-credentials"
# or direct configuration (not recommended for production)llamaParse: config: anthropicApiKey: "sk-ant-api03-your-api-key-here"
Verification
Section titled âVerificationâAfter configuration, verify your Anthropic integration:
- Check Admin UI: Verify Claude models appear in LlamaCloud admin interface
- Test functionality: Upload a document to confirm Claude models are working
Troubleshooting
Section titled âTroubleshootingâCommon Issues
Section titled âCommon IssuesâAPI Key Invalid
Section titled âAPI Key InvalidâError: Invalid API key
Solution:
- Verify your API key is correct and active in Anthropic Console
- Ensure the key starts with
sk-ant-api03-
- Check that the key hasnât expired
Authentication Failed
Section titled âAuthentication FailedâError: Authentication failed
Solution:
- Confirm your Anthropic account is in good standing
- Verify the API key has the necessary permissions
- Check if your account has been suspended
Rate Limiting
Section titled âRate LimitingâError: Rate limit exceeded
Solution:
- Check your Anthropic usage limits
- Consider upgrading your Anthropic plan
- Implement request throttling if needed
- Monitor usage patterns
Model Access Issues
Section titled âModel Access IssuesâError: Model not available or access denied
Solution:
- Verify you have access to the specific Claude model
- Some models may require special access approval
- Check model availability in your region
Quota Exceeded
Section titled âQuota ExceededâError: Usage quota exceeded
Solution:
- Check your Anthropic account usage and limits
- Add credits to your Anthropic account
- Set up billing alerts
- Consider usage optimization
Debug Steps
Section titled âDebug Stepsâ-
Test API key directly:
Terminal window 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-3-5-sonnet-20241022","max_tokens": 1024,"messages": [{"role": "user", "content": "Hello, Claude"}]}' -
Check secret mounting:
Terminal window kubectl get secret your-anthropic-secret -o yamlkubectl exec deployment/llamacloud-llamaparse -- env | grep ANTHROPIC -
Verify network connectivity: Ensure your cluster can reach
api.anthropic.com
-
Check logs for detailed errors:
Terminal window kubectl logs deployment/llamacloud-llamaparse --tail=100 | grep -i error