langchain-openai: set the base URL to https://api.laozhang.ai/v1 and use your LaoZhang API key for both chat and embedding models.
Install and configure
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, adduse_responses_api=True:
Create embeddings
FAQ
I get “Unsupported parameter: ‘max_tokens’”
Before November 4, 2026, GPT-6 models rejectedmax_tokens in Chat Completions; LaoZhang API now accepts it. If another model still returns this error, rename a hand-written max_tokens in extra request parameters to max_completion_tokens, or set the output limit through ChatOpenAI’s own argument. See max_tokens.
I get a 401 or 404
Make surebase_url is https://api.laozhang.ai/v1:
- A
base_urlpassed in code isn’t overridden by environment variables. - If you don’t pass one,
OPENAI_API_BASEtakes precedence overOPENAI_BASE_URL, so check both variables. See Invalid API key or 404.