Home / Docs / Migrating from the OpenAI API

Migrating from the OpenAI API

Keep the OpenAI SDK and reach Claude models by changing the base URL.

The gateway exposes an OpenAI-compatible endpoint, so an existing OpenAI codebase can reach Claude models without rewriting request handling.

Python

from openai import OpenAI

client = OpenAI(
    api_key=class="s">"sk-your-gateway-key",
    base_url=class="s">"https://aiprimetech.io/v1",          class=class="s">"c"># the /v1 is required here
)

resp = client.chat.completions.create(
    model=class="s">"claude-sonnet-4-6",  class=class="s">"c"># a Claude model through the OpenAI SDK
    messages=[{class="s">"role": class="s">"user", class="s">"content": class="s">"Hello"}],
)

LangChain

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model=class="s">"claude-sonnet-4-6",
    api_key=class="s">"sk-your-gateway-key",
    base_url=class="s">"https://aiprimetech.io/v1",
)

Checklist

  1. Set base_url to https://aiprimetech.io/v1 — with the suffix.
  2. Swap model ids to ones from Models.
  3. Response parsing is unchanged: choices[0].message.content.
  4. Streaming is unchanged: choices[0].delta.content plus the [DONE] sentinel.
  5. Function calling uses the OpenAI tools shape on this endpoint.
Behaviour differs even when the interface does not. Claude and GPT respond differently to the same prompt, particularly on instruction-following and output formatting. Re-check prompts that depend on a specific style, and re-run evaluations rather than assuming parity.