NezhaGateNezhaGate

NezhaGate serves both an OpenAI-compatible API and an Anthropic API, so the official SDKs only need a new base URL and key.

Two base URLs

ProtocolBase URLFor
OpenAIhttps://nezhagate.com/v1Every chat model, plus the image and video endpoints
Anthropichttps://nezhagate.com/anthropicClaude models (the Anthropic SDK adds /v1/messages itself)

The examples read the key from the NEZHAGATE_API_KEY environment variable; never put a key in code.

OpenAI SDK

pip install openai
import os
from openai import OpenAI

client = OpenAI(base_url="https://nezhagate.com/v1", api_key=os.environ["NEZHAGATE_API_KEY"])
r = client.chat.completions.create(
    model="gpt-5.5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(r.choices[0].message.content)

The OpenAI SDK also reads the OPENAI_BASE_URL and OPENAI_API_KEY environment variables. client.responses.create(...) calls the Responses API, which serves the GPT models only.

Anthropic SDK

pip install anthropic
import os
from anthropic import Anthropic

client = Anthropic(base_url="https://nezhagate.com/anthropic", api_key=os.environ["NEZHAGATE_API_KEY"])
m = client.messages.create(
    model="claude-sonnet-5",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(next(b.text for b in m.content if b.type == "text"))

Point base_url at /anthropic, without /v1. The ANTHROPIC_BASE_URL and ANTHROPIC_API_KEY environment variables work too.

LangChain

pip install langchain-openai
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-5.5",
    base_url="https://nezhagate.com/v1",
    api_key=os.environ["NEZHAGATE_API_KEY"],
    use_responses_api=False,
    stream_usage=True,
)
print(llm.invoke("Hello").content)

LangChain switches some GPT models, or requests with certain parameters, to the Responses API on its own; use_responses_api=False (useResponsesApi: false in JavaScript) keeps it on the chat endpoint. With a custom base_url, streaming returns no usage unless you set stream_usage=True.

Vercel AI SDK

npm install ai @ai-sdk/openai
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const gw = createOpenAI({ baseURL: "https://nezhagate.com/v1", apiKey: process.env.NEZHAGATE_API_KEY });
const { text } = await generateText({ model: gw.chat("gpt-5.5"), prompt: "Hello" });
console.log(text);

Since AI SDK 5, gw("model-id") uses the Responses API; gw.chat("model-id") uses the chat endpoint and works with every model. With @ai-sdk/anthropic, set baseURL to https://nezhagate.com/anthropic/v1 (with /v1).

Troubleshooting

404 from the OpenAI SDK

base_url is missing /v1; it should be https://nezhagate.com/v1.

404 from the Anthropic SDK

base_url ends in /v1, so requests go to /anthropic/v1/v1/messages. Stop at /anthropic.

A non-GPT model fails through a framework

The framework may have switched to the Responses API, which serves GPT models only: set use_responses_api=False in LangChain, or use gw.chat(...) in the Vercel AI SDK.

More integrations