Migrating from OpenAI
Switch from the OpenAI API to The Grid by changing three values in your existing code, base URL, API key, and model string. Your SDK, request body, and response shape stay the same.
Two things change for integrators: base URL and model name
Code examples
from openai import OpenAI
client = OpenAI(
base_url="https://api.thegrid.ai/v1", # was: https://api.openai.com/v1
api_key="your-grid-api-key", # from app.thegrid.ai/profile/api-keys
)
response = client.chat.completions.create(
model="text-prime", # was: gpt-5.2
messages=[{"role": "user", "content": "Hello"}],
)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.thegrid.ai/v1", // was: https://api.openai.com/v1
apiKey: "your-grid-api-key",
});
const response = await client.chat.completions.create({
model: "text-prime", // was: gpt-5.2
messages: [{ role: "user", content: "Hello" }],
});Model mapping
General text and reasoning
What you use today
Recommended Grid instrument
Typical use cases
Code generation (preview)
What you use today
Recommended Grid instrument
Typical use cases
Agent tool calling (preview)
What you use today
Recommended Grid instrument
Typical use cases
Three things stay the same: SDK, request shape, response shape
Four real differences from OpenAI
After the switch, route honestly and handle retries
Anthropic SDK as an alternative path
Last updated
Was this helpful?