LangChain & LangGraph
LangChain is the largest LLM framework ecosystem
in Python. LangGraph
is its graph-based agent runtime. Both reach Hyphen through ChatOpenAI with
two changed kwargs.
Code
Setup guide: this config comes from LangChain's official documentation and has not been run end to end against the gateway. Corrections to support@hyphen-solution.com.
The model
Code
base_url, api_key and model are the canonical kwarg names.
openai_api_base, openai_api_key and model_name still work as aliases from
older tutorials, but use the short ones.
Streaming
Code
Tools
Code
A LangGraph agent
create_react_agent is deprecated
In LangGraph v1 the prebuilt create_react_agent from langgraph.prebuilt is
deprecated in favour of create_agent from langchain.agents. The old import
still runs but warns. The snippet below uses the current one.
Code
Pass the model object, not a string
create_agent accepts either a BaseChatModel or a provider string like
"openai:gpt-4o". You must pass the object. A string identifier has
nowhere to carry your base_url, so LangChain would send the request to
OpenAI instead of Hyphen.
Structured output
with_structured_output defaults to a function-calling strategy, which is what
you want here. MiniMax supports tool calling but not response_format, so do
not pass method="json_mode" or method="json_schema".
Code
Gotchas
max_tokensof 2000 or more. 4000 for agents. The M-series reason before answering and a tight cap returns an emptyAIMessage. See Choosing a model.- No
OpenAIEmbeddingsagainst Hyphen. The catalog has no embedding models. Point your vector store somewhere else. - Doc links moved. The API reference now lives at
reference.langchain.com. 429means your monthly budget is spent. See Handling the 429 cap.
Related
- LangChain agents docs
- ChatOpenAI reference
- Structured JSON output: why tool calling and not JSON mode.
- Choosing a model: which model for which job.