How to Integrate A2Agent with the OpenAI SDK
A2Agent Team · 2026-06-10T00:00:00Z
Two lines to switch
If your project already uses the OpenAI SDK, moving to A2Agent only requires changing the base URL and API key.
Python
from openai import OpenAI
client = OpenAI(
api_key="YOUR_A2AGENT_KEY",
base_url="https://api.a2agent.me/v1",
)
resp = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": "Hello!"}],
)
print(resp.choices[0].message.content)
Node.js
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.A2AGENT_KEY,
baseURL: "https://api.a2agent.me/v1",
});
const resp = await client.chat.completions.create({
model: "deepseek-v4-flash",
messages: [{ role: "user", content: "Hello!" }],
});
console.log(resp.choices[0].message.content);
Swap models freely
Change the model field to any model from the Models catalog — the rest of your code stays the same.
Tip: see real per-token costs on the Pricing page before you choose a model.