Guides
Migrating from OpenAI
Two lines change, base URL and key, and the model string. What stays the same, and what to check.
The change
import os
from openai import OpenAI
client = OpenAI(
base_url="https://api.intelligentinference.ai/v1", # was api.openai.com
api_key=os.environ["I2_API_KEY"], # sk_i2_… instead of sk-…
)
client.chat.completions.create(
model="IntelligentInference/gpt-oss-120b(Global)", # an i2 route id
messages=[{"role": "user", "content": "Hello"}],
)Frameworks that wrap the OpenAI client (LangChain, LlamaIndex, Vercel AI SDK's OpenAI provider, and most agent toolkits) take the same two settings, usually as base_url/baseURL and api_key.
What stays the same
- The request and response bodies of chat completions, including
messages,stream,max_tokens,temperature,usage,finish_reason. - Streaming as server-sent events ending in
data: [DONE]. - The error envelope (
{"error": {"message", "type"}}) and the meaning of401,429and5xx.
What to check
| Area | On i2 |
|---|---|
| Model names | i2 route ids, from the catalogue. There is no gpt-4o; pick the open-weight model that fits and use its id verbatim. |
models.list() | Not served yet (404). Hard-code the route id or read it from configuration. |
| Budget errors | 402 when the organisation's budget or the key's cap is exhausted. OpenAI has no equivalent; handle it explicitly. |
| Rate limits | 60 requests per minute per key. Spread work across keys per service rather than relying on one key's limit. |
| Scope errors | 403 model_scope_error if the key is restricted to other models. |
| Embeddings, images, audio, files, assistants | Not part of the i2 API today. Chat completions is the surface. |
| Response headers | i2 adds nothing you must read. Optionally send X-K2I-Debug-Metrics: true on streams for per-request cost and timing; see Streaming and debug metrics. |
Suggested rollout
- Create a key with a credit cap and
allowed_modelsset to the one route you are migrating to, so the experiment cannot overspend. - Point a staging deployment at i2 with that key; compare outputs and latency in the dashboard's request log, which records time to first token and throughput for every call.
- Move production to a separate key, with its own cap, so its spend and errors are attributed on their own line.
Something unclear or wrong on this page? Tell us. Machine-readable copies: llms.txt.