Skip to main content
A2Agent exposes an OpenAI-compatible REST API that works with any client library supporting a custom base URL — including the OpenAI SDK, Anthropic SDK, LangChain, or a raw HTTP client — so you can switch to A2Agent without changing a single line of your existing application code.

Base URL

All requests are routed through a single base URL:
https://api.a2agent.me
Every endpoint lives under the /v1/ path prefix. When configuring an SDK, point base_url at https://api.a2agent.me/v1 (OpenAI-style) or set ANTHROPIC_BASE_URL to https://api.a2agent.me (Anthropic-style). See the Compatibility section below for details.

Compatibility

A2Agent supports both the OpenAI and Anthropic request formats. Choose the one that matches your existing setup.

OpenAI format

Set base_url in the SDK constructor and pass your A2Agent key as api_key. No other changes are required.
OpenAI SDK — set base URL and key
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_A2AGENT_KEY",
    base_url="https://api.a2agent.me/v1"
)

response = client.chat.completions.create(
    model="deepseek-chat",
    messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)

Anthropic format

Set the ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN environment variables. The Anthropic SDK will automatically route all requests through A2Agent.
Anthropic SDK — set environment variables
import anthropic
import os

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

client = anthropic.Anthropic()

message = client.messages.create(
    model="glm-5",
    max_tokens=256,
    messages=[{"role": "user", "content": "Hello"}]
)
print(message.content[0].text)

Available Endpoints

MethodEndpointDescription
POST/v1/chat/completionsGenerate a chat response
GET/v1/modelsList available models

Rate Limits

If you exceed your request rate, the API returns a 429 Too Many Requests response. Build exponential back-off into your retry logic to handle these gracefully. To review your current limits or upgrade your plan, visit your A2Agent dashboard.
Before making your first request, you’ll need an API key. See Authentication for instructions on creating and using your key.