LangChain

Point LangChain's ChatOpenAI, ChatAnthropic or ChatGoogleGenerativeAI at this gateway with one base URL (Python / JS)

All three LangChain model classes take a custom base URL, so the rest of your code stays as it is. Checked on 2026-11-15 against the official docs and source of Python langchain-openai 1.8.0, langchain-anthropic 1.7.10 and langchain-google-genai 4.5.0, and JS @langchain/openai 1.8.4 and @langchain/anthropic 1.6.5.

Get an API key#

Create one at qd.zsopc.com/dashboard/keys. The examples read it from an environment variable:

export PLATFORM_API_KEY="sk-gpushare-xxx"

Python#

pip install -U langchain-openai langchain-anthropic langchain-google-genai

ChatOpenAI (OpenAI protocol, reaches every text model)#

import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-6.1-sol",                 # claude-sonnet-4-6, deepseek-v4.1-flash and others work too
    base_url="https://qd.zsopc.com/v1",
    api_key=os.environ["PLATFORM_API_KEY"],
    stream_usage=True,                   # off by default with a custom base_url; adds token usage to streams
)
print(llm.invoke("Introduce yourself in one sentence").content)
  • For /v1/responses, pass use_responses_api=True. Without it LangChain may switch to the Responses API on its own based on the model name or the tools you use, so with a third-party endpoint set it explicitly to True or False. Which models support /v1/responses: see the compatibility matrix.
  • Instead of base_url you can also set the OPENAI_BASE_URL environment variable.

ChatAnthropic (Anthropic protocol)#

from langchain_anthropic import ChatAnthropic

claude = ChatAnthropic(
    model="claude-sonnet-4-6",
    base_url="https://qd.zsopc.com",   # no /v1 — the SDK adds /v1/messages
    api_key=os.environ["PLATFORM_API_KEY"],
)

This platform accepts both x-api-key and Authorization: Bearer on /v1/messages, so every version of the anthropic SDK works as is.

ChatGoogleGenerativeAI (Gemini protocol)#

from langchain_google_genai import ChatGoogleGenerativeAI

gemini = ChatGoogleGenerativeAI(
    model="gemini-3.1-pro-low",
    base_url="https://qd.zsopc.com",
    api_version="v1beta",
    api_key=os.environ["PLATFORM_API_KEY"],
)

JavaScript / TypeScript#

npm install @langchain/openai @langchain/anthropic
import { ChatOpenAI } from "@langchain/openai";
import { ChatAnthropic } from "@langchain/anthropic";

const llm = new ChatOpenAI({
  model: "gpt-6.1-sol",
  apiKey: process.env.PLATFORM_API_KEY,
  configuration: { baseURL: "https://qd.zsopc.com/v1" },
});

const claude = new ChatAnthropic({
  model: "claude-sonnet-4-6",
  apiKey: process.env.PLATFORM_API_KEY,
  anthropicApiUrl: "https://qd.zsopc.com", // no /v1
});

console.log((await llm.invoke("Hello")).content);

Which class to use#

  • One code path for every vendor: ChatOpenAI. The gateway translates the protocol for Claude, Gemini and the other non-OpenAI models.
  • Request parameters that only one vendor's protocol has: that vendor's class.
  • Tool calling works on all three protocols; see Tool calling.

Troubleshooting#

SymptomWhat to check
404The OpenAI base URL needs /v1; the Anthropic and Gemini ones don't
401 invalid_api_keyWhether the key was copied in full (76 characters), and whether the environment variable actually reaches the process
400 model_not_foundModel ID spelling — it must match Models exactly
No token usage on streamsAdd stream_usage=True to ChatOpenAI
402 quota_exceededBalance exhausted. Every key shares one account balance — top up on the Top up page

Full error reference: Error codes.