How to switch the OpenAI SDK to GotoAI
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}}",
)What you gain
- Multi-provider routing and fallback behind one endpoint.
- A request-level ledger and usage governance.
- An
X-HyperCore-Providerheader 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.