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.
Most teams switch to The Grid in three lines of code. Our Consumption API is OpenAI-compatible, so the SDK, request body, response shape, and streaming behavior you already know all work. The model name becomes an instrument string like text-prime and the rest of your code stays put.
If continuity with OpenAI's latest GPT family matters more than task-tier routing, use gpt-sol-latest.
This section covers how to make the switch cleanly, how to route workloads across Grid instruments, and what to do when something goes wrong.
Two things change for integrators: base URL and model name
If your code calls the OpenAI API today, switching to The Grid takes three changes:
Base URL. Point at
https://api.thegrid.ai/v1instead ofhttps://api.openai.com/v1.API key. Use a Grid API key from app.thegrid.ai/profile/api-keys.
Model string. Replace the OpenAI model name with a Grid instrument like Text Prime, Code Max, or Agent Prime.
That's the entire migration. The SDK stays the same. chat.completions.create() stays the same. Streaming, tool calling, structured outputs, and standard generation parameters (temperature, top_p, max_tokens, stop) all behave the same way.
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.6-terra
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.6-terra
messages: [{ role: "user", content: "Hello" }],
});Model mapping
These are starting points. The model parameter is just a string, so you can mix instruments freely within the same application. Use text-standard for classification, text-max for analysis, and code-prime for code review, all in the same codebase. The full list lives in Current instruments.
General text and reasoning
GPT-5.6 Sol
text-max
Deep reasoning, extended thinking, complex multi-step prompts, math and logic
GPT-5.6 Terra
text-prime
Everyday workhorse: writing, summarization, Q&A, analysis
GPT-5.6 Luna
text-standard
High-throughput, classification, extraction, simple generation
Code generation
GPT-5.6 Sol (for code)
code-max
Complex architecture, multi-file refactors, deep debugging
GPT-5.6 Terra (for code)
code-prime
Daily coding: completion, review, standard debugging
GPT-5.6 Luna (for code)
code-standard
Autocomplete, linting, fast inline suggestions
Agent tool calling
GPT-5.6 Sol (agent use)
agent-max
Autonomous multi-step tasks, deep tool chains, long-horizon agents
GPT-5.6 Terra (agent use)
agent-prime
Reliable multi-step tool use, standard agent loops
GPT-5.6 Luna (agent use)
agent-standard
Fast tool calls, simple loops, high-throughput orchestration
If you're not sure where to start, default to Text Prime. It covers most everyday work. You can switch tiers per-request as evidence accumulates. See Routing patterns for how to allocate workloads honestly.
Three things stay the same: SDK, request shape, response shape
The SDK. Keep
openai(Python) oropenai(Node). No new dependency.The request shape. Messages array,
temperature,top_p,max_tokens,stop,stream,tools,tool_choice,response_format. All the same.The response shape.
chat.completionandchat.completion.chunkobjects with the same fields.Streaming. Server-sent events with the same chunk format.
Tool calling. Function definitions and
tool_callswork the same way.Structured outputs. JSON mode and JSON schema work the same way.
Four real differences from OpenAI
Instrument strings, not upstream model names. The
modelparameter takes a Grid instrument:text-prime,code-max,gpt-sol-latest, and so on. Passing an upstream model name such asgpt-5.6-terrareturns a 404.Pricing is market-driven. Prices come from a real order book, per million tokens, and move with supply and demand. Live pricing is in the app at thegrid.ai/pricing.
Balance management. If your USD balance hits zero mid-request, you get a
402error. Set up Auto-Reload in the dashboard to keep your credits topped up automatically.What's not on The Grid. The Assistants API, file uploads, DALL-E, Whisper, TTS, embeddings, fine-tuning, and the Batch API are OpenAI products, not part of the inference contract. We cover chat completions with tool calling and structured outputs. If you use those OpenAI-only features, leave those calls pointed at OpenAI and route chat completions through The Grid.
After the switch, route honestly and handle retries
Once requests are flowing, two things matter:
Route honestly. Don't run everything on Max. The bulk of the savings comes from putting throughput-heavy and structured workloads on Standard, daily work on Prime, and reserving Max for tasks where getting it wrong has real consequences. See Routing patterns.
Handle retryable errors.
429,500,503, and402are retryable with exponential backoff. See Troubleshooting and Best practices.
If you hit a wall, the Troubleshooting page has the common errors and fixes.
Anthropic SDK as an alternative path
If you maintain code that uses the Anthropic SDK alongside OpenAI, you don't need to consolidate on a single SDK to use The Grid. The Messages API beta endpoint at https://messages-beta.api.thegrid.ai/v1 accepts Anthropic-format requests against the same instruments and the same balance. See Migrating from Anthropic for the details.
Last updated
Was this helpful?