Origin Docs
GuidesMigration

Troubleshoot Gateway Migration

Diagnose authentication, model ID, and SDK configuration issues when migrating from OpenAI to ORGN Gateway.

Common failures when migrating to ORGN Gateway: wrong base_url, OpenAI key still in use, or slash-format model IDs.

Client configuration

base_url not updated

Without base_url, the OpenAI SDK defaults to OpenAI — not Gateway.

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

Correct URL: https://api.gateway.orgn.com/v1 — not /chat/completions, not missing /v1.

Node.js: baseURL casing

const client = new OpenAI({
  baseURL: "https://api.gateway.orgn.com/v1",
  apiKey: process.env.OLLM_API_KEY,
});

baseUrl (lowercase) is silently ignored.

Wrong API key

echo $OLLM_API_KEY

Do not mix OPENAI_API_KEY and OLLM_API_KEY.

Authentication (401)

The request reached Gateway but credentials failed.

  1. Regenerate key in the Gateway console.
  2. Confirm base_url is https://api.gateway.orgn.com/v1.
  3. Restart the app after updating env vars.

Model errors

Model not found

Gateway IDs differ from OpenAI. Use underscores:

WrongCorrect
near/GLM-4.6near_glm_4_7
gpt-4overcel_gpt_4o or near_glm_4_7
GLM-4.6near_glm_4_7
response = client.chat.completions.create(
    model="near_glm_4_7",
    messages=[{"role": "user", "content": "Test"}]
)

List models: curl https://api.gateway.orgn.com/v1/models -H "Authorization: Bearer sk-ollm-..."

Response handling

Guard before reading choices[0].message.content:

if hasattr(response, "choices") and response.choices:
    print(response.choices[0].message.content)

Verify requests reach Gateway

Open the Gateway console — confirm the request appears with expected model and token count. If nothing appears, traffic is still routing to OpenAI or failing locally.

Debugging checklist

  • base_url is exactly https://api.gateway.orgn.com/v1
  • OLLM_API_KEY loaded (not OpenAI key)
  • Model ID uses underscores (near_glm_4_7)
  • Request visible in Gateway console
  • Response parsing guarded

On this page