A
Auraon
/Docs
SDK

SDK Examples

Auraon works with the official OpenAI SDK in any language — just swap the base URL and API key.

Python

Install the OpenAI Python package:

bash
pip install openai
python
import openai

client = openai.OpenAI(
    api_key="br-your-api-key",
    base_url="https://api.auraon.ai/v1"
)

# Auraon auto-routes to the best model
response = client.chat.completions.create(
    model="auto",  # or specify: "claude-opus-4", "gpt-4o"
    messages=[
        {"role": "user", "content": "Explain quantum entanglement"}
    ]
)

print(response.choices[0].message.content)

Streaming

python
from openai import OpenAI

client = OpenAI(
    api_key="br-your-api-key",
    base_url="https://api.auraon.ai/v1"
)

stream = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Write a poem"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

TypeScript / Node.js

Install the OpenAI Node.js package:

bash
npm install openai
typescript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "br-your-api-key",
  baseURL: "https://api.auraon.ai/v1",
});

// Pay as you go — credit card or invoice
const response = await client.chat.completions.create({
  model: "auto",
  messages: [
    { role: "user", content: "Write a React component" }
  ],
});

console.log(response.choices[0].message.content);

Streaming

typescript
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "br-your-api-key",
  baseURL: "https://api.auraon.ai/v1",
});

const stream = client.chat.completions.stream({
  model: "auto",
  messages: [{ role: "user", content: "Write a poem" }],
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

cURL

No installation needed — works with any HTTP client.

bash
curl https://api.auraon.ai/v1/chat/completions \
  -H "Authorization: Bearer br-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "auto",
    "messages": [
      {
        "role": "user",
        "content": "What is the capital of France?"
      }
    ]
  }'

Environment variables

We recommend configuring your API key via environment variables:

bash
# .env
OPENAI_API_KEY=br-your-api-key
OPENAI_BASE_URL=https://api.auraon.ai/v1

Both the Python and TypeScript SDKs automatically read OPENAI_API_KEY and OPENAI_BASE_URL from the environment, so no code changes are needed.