Skip to main content

Authenticate Using Bearer Token

Learn how to authenticate your API requests using Bearer token authentication.

Overview

All Eden AI V3 API requests require authentication using a Bearer token. This token identifies your account and tracks usage for billing and rate limiting purposes.

Getting Your API Token

  1. Sign up or log in to your Eden AI Dashboard
  2. Navigate to API Keys section
  3. Copy your API key
  4. Keep it secure - never commit it to version control or share publicly

Authentication Header

Include your API token in the Authorization header with the Bearer scheme:
Authorization: Bearer YOUR_API_KEY

Examples

cURL

Best Practices

Store Tokens Securely

Never hardcode API tokens in your source code. Use environment variables or secret management systems:

Add to .gitignore

Ensure your .env file and any files containing API keys are excluded from version control:
# .gitignore
.env
.env.local
*.key
secrets.json

Rotate Keys Regularly

For security, periodically rotate your API keys:
  1. Generate a new key in the dashboard
  2. Update your application with the new key
  3. Delete the old key after confirming the new one works

Use Different Keys for Different Environments

Create separate API keys for development, staging, and production environments to:
  • Track usage separately
  • Revoke access independently
  • Maintain security isolation

Authentication Errors

401 Unauthorized

Cause: Invalid or missing API token Solutions:
  • Verify your token is correct
  • Check the Authorization header format: Bearer YOUR_TOKEN
  • Ensure the token hasn’t been revoked
  • Confirm there are no extra spaces or newline characters

402 Payment Required

Cause: Insufficient credits in your account Solutions:
  • Add credits to your account in the dashboard
  • Check your current balance
  • Review your usage patterns

Testing Authentication

Test your authentication with a simple request:

Using Client Libraries

If you’re using an HTTP client library, most support automatic header management:

Next Steps