How to switch the OpenAI SDK to GotoAI

Applies to: Developer · Team · Enterprise — Last reviewed 2026-06-29

GotoAI implements the OpenAI API surface. To migrate, change two things: base_url and api_key. Everything else — messages, streaming, tool calls — stays the same.

Before

client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])

After

client = OpenAI(
    api_key=os.environ["GOTOAI_API_KEY"],
    base_url="{{api_base}}",
)
const client = new OpenAI({
  apiKey: process.env.GOTOAI_API_KEY,
  baseURL: "{{api_base}}",
});

What you gain

  • Multi-provider routing and fallback behind one endpoint.
  • A request-level ledger and usage governance.
  • An X-HyperCore-Provider header so the source is never hidden.
Models map by name. If a model is restricted for your key you'll get 403 model_restricted — see Errors.

Verify

Run any existing OpenAI call. The response shape is identical; check the Console's Usage page to confirm the request was recorded.

Next steps