Skip to main content

Overview

a21e exposes an OpenAI-compatible /v1/chat/completions endpoint. If your application already uses the OpenAI SDK, you can switch to a21e by changing two lines — the base URL and API key.

Setup

from openai import OpenAI

client = OpenAI(
    api_key="YOUR_A21E_API_KEY",
    base_url="https://api.a21e.com/v1",
)

response = client.chat.completions.create(
    model="auto",
    messages=[
        {"role": "user", "content": "Explain dependency injection in Go"}
    ],
)

Model mapping

The model parameter maps to a21e’s tier system:
Valuea21e tierBehavior
autoAutoa21e selects the best model
economyEconomyFastest, lowest cost
standardStandardBalanced
premiumPremiumHighest quality
Any model name (e.g., gpt-4o)AutoAccepted but a21e selects the actual model

What’s different from raw OpenAI

When you use a21e’s OpenAI-compatible endpoint, your request gets the full a21e pipeline:
  • Prompt synthesis — your message is enhanced with curated techniques
  • Memory injection — relevant memories from past sessions are applied
  • Workspace context — preferences, persona, and repo context are included
  • Quality scoring — outputs are scored for continuous improvement
The response format matches the OpenAI spec exactly, so existing integrations work without changes.

Streaming

Streaming is supported via the standard stream: true parameter:
stream = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Write a Makefile for a Go project"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")