Install
pip install langchain-openaiExample
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="luv13/glm-5.3-flash",
base_url="https://api.luv13.ai/v1",
api_key=os.environ["LUV13_API_KEY"],
)
reply = llm.invoke("Explain a context window in one sentence.")
print(reply.content)Where the base URL comes from
LangChain picks the base URL in this order:
- The
base_urlargument (also accepted asopenai_api_base). - The
OPENAI_API_BASEenvironment variable. - The
OPENAI_BASE_URLenvironment variable, read by the underlying OpenAI SDK.
Passing base_url directly is the clearest option, and it avoids sending requests to OpenAI by accident.
Notes
ChatOpenAIis built on the OpenAI SDKs, so the same luv13 rules apply: chat completions and model listing are the endpoints to use. See Endpoints.- For retrieval apps, pair a luv13 chat model with embeddings from another service. See Retrieval-Augmented Generation.
- Tool calling through LangChain depends on luv13's tool support. See Tool Calling on luv13.
