Guide

Migrate from OpenAI in 3 lines

Aniron speaks the OpenAI chat completions API. Point your existing SDK at our base URL, swap the API key, and prefix model names with aniron/. Streaming, function calling, and error handling all work the same.

Three changes

01

Set baseURL

Add the baseURL parameter to your OpenAI client constructor. Point it at https://api.aniron.ai/v1. Everything else stays the same.

const client = new OpenAI({
  baseURL: 'https://api.aniron.ai/v1',
  apiKey: process.env.OPENAI_API_KEY,
});
02

Replace API key

Generate a Aniron API key at app.aniron.ai. Replace your OpenAI key with it. The key is shown once โ€” save it in your environment or secrets manager.

.env
# Before
OPENAI_API_KEY=sk-proj-abc123...

# After
ANIRON_KEY=sk-aniron-def456...
03

Prefix model name

Add aniron/ to the front of your model name. gpt-4 becomes aniron/gpt-4. This tells the gateway which upstream provider to route to.

model: 'aniron/gpt-4'  // was 'gpt-4'

Full example

Before (OpenAI direct)

import OpenAI from 'openai';

const client = new OpenAI({
  apiKey: process.env.OPENAI_API_KEY,
});

const completion = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello' }],
});

After (Aniron routing)

import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.aniron.ai/v1',  // ๐Ÿ‘ˆ Add this
  apiKey: process.env.ANIRON_KEY,        // ๐Ÿ‘ˆ Change this
});

const completion = await client.chat.completions.create({
  model: 'aniron/gpt-4',                 // ๐Ÿ‘ˆ Prefix with aniron/
  messages: [{ role: 'user', content: 'Hello' }],
});

The response object is identical. If your code parses completion.choices[0].message.content, it still works. Error handling, streaming chunks, and function calls all follow the same shape.

What stays the same

SDK

No Aniron-specific library. Use the official openai package, same version.

Request format

Messages array, temperature, max_tokens, top_p โ€” all parameters work as documented.

Response shape

Same JSON structure. id, object, created, model, choices, usage โ€” nothing moves.

Streaming

Set stream: true. Server-sent events arrive in the same format, same delta shape.

Function calling

Tools parameter passes through. GPT-4/Claude/Gemini handle tool calls identically.

Error codes

400 for bad input, 401 for invalid key, 402 when balance is zero, 429 on rate limit.

Frequently asked questions

Do I need to change my SDK?

No. Aniron speaks the OpenAI chat completions API. The official openai package, LangChain, LlamaIndex, and any other library that supports OpenAI-compatible endpoints work without modification.

Does streaming still work?

Yes. Set stream: true in the request. The same server-sent event format is returned. Your existing streaming handlers do not need to change.

What about function calling?

Function calling (tool use) passes through unchanged for models that support it. GPT-4, Claude, and Gemini all handle tools the same way through Aniron as they do direct.

Can I keep some requests on OpenAI direct?

Yes. Create two client instances with different base URLs. Route some calls through Aniron, others direct to OpenAI. Useful during a gradual migration or A/B test.

Is there a cost to migrate?

The migration itself is free. You pay Aniron usage rates, which are typically 10-15% cheaper than OpenAI list for GPT-4 and comparable for GPT-4o. Check /pricing for current rates.

Migrate your first request

Get a Aniron API key and change three lines. Test it with a single request before switching production traffic.