Skip to main content
LangChain connects to LaoZhang API through langchain-openai: point the chat and embedding clients at the LaoZhang API base URL and pass your key. GPT-6, Gemini, DeepSeek, and other text models all work with the same client.

Install and configure

All the examples below read the key from that variable:
To switch models, change only model, for example to gemini-3.8-flash or deepseek-v4-flash. Prices are in the model catalog. You can also set the OPENAI_API_KEY and OPENAI_BASE_URL environment variables and leave api_key and base_url out of your code.

Call tools

tool_calls returns the tool name and arguments, such as {'name': 'get_weather', 'args': {'city': 'Paris'}}. After running the tool, send the result back as a ToolMessage, or let a LangGraph agent handle the loop.

Stream the output

Use the Responses API

When you need features of OpenAI’s Responses API, add use_responses_api=True:

Create embeddings

Available embedding models and dimensions are in the Embeddings API.

FAQ

I get “Unsupported parameter: ‘max_tokens’”

GPT-6 models don’t accept max_tokens. Setting the output limit through ChatOpenAI’s own argument usually works; if you added that field by hand in extra request parameters, rename it to max_completion_tokens. See max_tokens.

I get a 401 or 404

Make sure base_url is https://api.laozhang.ai/v1 and isn’t overridden by an environment variable such as OPENAI_BASE_URL. See Invalid API key or 404.