Skip to content

Migration guide

What changes when you move to Inference from OpenAI, Anthropic or Google Gemini.

Migration guide

Migrating from OpenAI

Two things change: the base URL and the API key. Nothing else in your code moves.

Python

# Before
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

# After
from openai import OpenAI
client = OpenAI(
    base_url="https://api.alphacurve.io/v1",
    api_key=os.environ["INFERENCE_API_KEY"],
)

Node / TypeScript

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

// After
const client = new OpenAI({
  baseURL: "https://api.alphacurve.io/v1",
  apiKey: process.env.INFERENCE_API_KEY,
});

The one catch: model IDs need a prefix

BeforeAfter
gpt-4oopenai/gpt-4o
gpt-4o-miniopenai/gpt-4o-mini

Omitting the prefix returns 404 model_not_found.

Migrating from Anthropic

Anthropic's native API uses a different message shape. Pointing the openai SDK at Inference lets you call Claude with OpenAI-style code.

Shape mapping

Anthropic nativeOpenAI-compatible (Inference)
anthropic.Anthropic(api_key=...)OpenAI(base_url="https://api.alphacurve.io/v1", api_key=...)
client.messages.create(...)client.chat.completions.create(...)
system="..." (separate parameter){"role": "system", "content": "..."} first in messages
max_tokens requiredmax_tokens optional
model="claude-sonnet-4-5"model="anthropic/claude-sonnet-4-5"
resp.content[0].textresp.choices[0].message.content
resp.usage.input_tokens / output_tokensresp.usage.prompt_tokens / completion_tokens
tools[].input_schematools[].function.parameters
stop_reason: "end_turn"finish_reason: "stop"

Before (Anthropic SDK)

import os
import anthropic

client = anthropic.Anthropic(api_key=os.environ["ANTHROPIC_API_KEY"])

resp = client.messages.create(
    model="claude-sonnet-4-5",
    max_tokens=1024,
    system="You are concise.",
    messages=[{"role": "user", "content": "Explain routing in one sentence."}],
)
print(resp.content[0].text)

After (openai SDK pointed at Inference)

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.alphacurve.io/v1",
    api_key=os.environ["INFERENCE_API_KEY"],
)

resp = client.chat.completions.create(
    model="anthropic/claude-sonnet-4-5",
    max_tokens=1024,
    messages=[
        {"role": "system", "content": "You are concise."},
        {"role": "user", "content": "Explain routing in one sentence."},
    ],
)
print(resp.choices[0].message.content)

Migrating from Google Gemini

Gemini nativeOpenAI-compatible (Inference)
genai.GenerativeModel("gemini-2.5-pro")model="google/gemini-2.5-pro"
contents=[{"role": "user", "parts": [...]}]messages=[{"role": "user", "content": ...}]
role: "model"role: "assistant"
system_instruction={"role": "system", ...}
generation_config.max_output_tokensmax_tokens
resp.textresp.choices[0].message.content
inline_data / file_data{"type": "image_url", "image_url": {"url": "data:..."}}
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.alphacurve.io/v1",
    api_key=os.environ["INFERENCE_API_KEY"],
)

resp = client.chat.completions.create(
    model="google/gemini-2.5-pro",
    messages=[
        {"role": "system", "content": "You are concise."},
        {"role": "user", "content": "Explain routing in one sentence."},
    ],
)
print(resp.choices[0].message.content)

Migration checklist

  1. Create an API key in the Dashboard and set a monthly spend limit.
  2. Add credits.
  3. Change the base URL to https://api.alphacurve.io/v1, ideally through an environment variable.
  4. Swap in the sk-inf- key.
  5. Add the provider/ prefix to every model ID.
  6. Call GET /v1/models to confirm each ID exists and is available to the key.
  7. Update error handling to read error.code (see Errors).
  8. Canary a small slice of traffic (say 5%) before cutting over fully.
  9. Check the Usage page in the Dashboard to confirm costs match expectations.

Supporting both during the cutover

One environment-driven configuration can serve both sides while you migrate:

import os
from openai import OpenAI

client = OpenAI(
    base_url=os.getenv("LLM_BASE_URL", "https://api.alphacurve.io/v1"),
    api_key=os.environ["LLM_API_KEY"],
)

MODEL = os.getenv("LLM_MODEL", "openai/gpt-4o-mini")

Rolling back

There is no lock-in: everything is standard OpenAI-format code. To go back to a provider directly, revert the base URL, the key, and the model prefix.