Origin Docs
GuidesMigration

Migrate to ORGN Gateway from OpenAI

Migrate an existing OpenAI application to ORGN Gateway with minimal code changes — swap base URL, API key, and model IDs.

ORGN Gateway exposes an OpenAI-compatible API. Use the same OpenAI SDK — change base_url, your Gateway API key (sk-ollm-*), and model IDs.

Prerequisites

pip install openai

Basic configuration

from openai import OpenAI

client = OpenAI(
    base_url="https://api.gateway.orgn.com/v1",
    api_key="sk-ollm-YOUR_API_KEY"
)

Chat completion

Specify the model explicitly. IDs use underscores:

response = client.chat.completions.create(
    model="near_glm_4_7",
    messages=[
        {"role": "user", "content": "Why is the sky blue?"}
    ]
)

print(response.choices[0].message.content)
OpenAI model (example)Gateway TEE alternativeGateway ZDR alternative
gpt-4onear_glm_4_7vercel_gpt_4o
gpt-4-turbonear_glm_5vercel_claude_sonnet_4_6

Browse the live catalog: GET https://api.gateway.orgn.com/v1/models or the Gateway console.

export OLLM_API_KEY="sk-ollm-YOUR_API_KEY"
import os
client = OpenAI(
    base_url="https://api.gateway.orgn.com/v1",
    api_key=os.environ["OLLM_API_KEY"]
)

OLLM_API_KEY is the legacy env var name; keys use the sk-ollm- prefix.

Streaming

stream = client.chat.completions.create(
    model="near_glm_4_7",
    messages=[{"role": "user", "content": "Write about secure AI."}],
    stream=True
)

for chunk in stream:
    if chunk.choices and chunk.choices[0].delta:
        print(chunk.choices[0].delta.get("content", ""), end="")

Common errors

ErrorFix
401Verify sk-ollm-* key and base_url includes /v1
Model not foundUse underscore IDs from /v1/models — not OpenAI names or slash format

On this page