Skip to main content
AnyAPI uses API keys to authenticate requests. Your API keys carry many privileges, so be sure to keep them secure! Do not share your secret API keys in publicly accessible areas such as GitHub, client-side code, and so forth.
All API requests must be made over HTTPS. Calls made over plain HTTP will fail. API requests without authentication will also fail.

API Keys

Authentication to the API is performed via HTTP Bearer authentication. Provide your API key as a bearer token in the Authorization header.

Getting Your API Key

You can find and manage your API keys in the AnyAPI.ai Dashboard. Keep your API keys secure and rotate them regularly for optimal security.

Bearer Token Format

Include your API key in the Authorization header using the Bearer authentication scheme:

Basic Authentication Example

Advanced cURL Examples

Basic Chat Completion

Streaming Response

With Custom Headers (Optional)

Error Handling

If your API key is missing or invalid, you’ll receive an error response:

Security Best Practices

Never expose your API keys in client-side code. API keys should only be used in server-side applications where they can be kept secure.

Environment Variables

Store your API key in environment variables:

Rate Limiting

Your API key has rate limits associated with it. Include proper error handling for rate limit responses:

Testing Your Authentication

Use this simple curl command to test if your API key is working:
A successful response will return a list of available models:

Next Steps

Make Your First Request

Learn how to make your first API call with AnyAPI.ai