Skip to main content
Every request to the A2Agent API must include your API key as a Bearer token in the Authorization header. Requests that omit the header or supply an invalid key are rejected before they reach any model. You can create and manage your keys from the A2Agent dashboard.

Header Format

Include the following header with every API request:
Authorization: Bearer YOUR_A2AGENT_KEY
Replace YOUR_A2AGENT_KEY with the key you copied from your dashboard. Keys are sensitive — treat them like passwords.

OpenAI SDK

Pass your key to the api_key argument when instantiating the client. The SDK attaches the Authorization header automatically on every request.
OpenAI SDK — pass key and base URL
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_A2AGENT_KEY",
    base_url="https://api.a2agent.me/v1"
)
Alternatively, export OPENAI_API_KEY=YOUR_A2AGENT_KEY in your shell and omit the api_key argument — the SDK will pick it up from the environment.

Anthropic SDK

The Anthropic SDK reads authentication credentials from two environment variables. Set both before initialising the client:
Anthropic SDK — set auth environment variables
import anthropic
import os

os.environ["ANTHROPIC_AUTH_TOKEN"] = "YOUR_A2AGENT_KEY"
os.environ["ANTHROPIC_BASE_URL"] = "https://api.a2agent.me"

client = anthropic.Anthropic()

curl

You can authenticate raw HTTP requests by adding the Authorization header directly to your curl command:
curl — Bearer token in Authorization header
curl https://api.a2agent.me/v1/chat/completions \
  -H "Authorization: Bearer YOUR_A2AGENT_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "deepseek-chat", "messages": [{"role": "user", "content": "Hello"}]}'

Error Responses

If authentication or authorisation fails, the API returns one of the following HTTP status codes:
StatusMeaning
401 UnauthorizedThe Authorization header is missing, malformed, or contains an invalid key. Check that you copied your key correctly and that it has not been revoked.
403 ForbiddenYour account is suspended or your balance is insufficient to complete the request. Top up your balance from your A2Agent dashboard.
429 Too Many RequestsYou have exceeded your request rate limit. Wait briefly and retry, preferably with exponential back-off.
Never expose your API key in client-side JavaScript, mobile app bundles, or public version-control repositories. If a key is accidentally leaked, revoke it immediately from your dashboard and issue a new one.
To create your first key, sign in to your A2Agent account and navigate to API Keys.