Origin Docs
GuidesOpenAI SDK

Integrate ORGN Gateway with the OpenAI SDK

Configure the OpenAI SDK to route inference through ORGN Gateway — swap base URL, API key, and model IDs.

ORGN Gateway is OpenAI-compatible. Use the official OpenAI SDK with a different base_url and Gateway API key.

Prerequisites

pip install openai

Configuration

from openai import OpenAI

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

Chat completion

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)

Production patterns

Validate responses before rendering:

if response and response.choices:
    print(response.choices[0].message.content)
print(response.usage.total_tokens)

Environment variables

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

TEE vs ZDR

  • near_*, phala_* — TEE with Scanner attestation
  • vercel_* — ZDR frontier models

See Models overview.

On this page