LangChain
Use LangChain with Boundless through ChatOpenAI: install, base URL and key, streaming and a tool call.
LangChain reaches Boundless through ChatOpenAI, which speaks chat completions.
Install#
Base URL and key#
Name a model with the ID from the models table.
Make a request#
Stream the reply#
Call a tool#
message.tool_calls holds the name and parsed arguments. Run the tool and send a ToolMessage back to continue. Tool calling shows the loop on the raw API.
Known differences#
ChatOpenAIis built for OpenAI. Fields that only OpenAI defines are not guaranteed to work. Stay with chat completions.- Not every model supports tools.
GET /v1/model/infolists the capability flags. - Credits that run out return
402withbudget_exceeded. Rate limits return429, which LangChain retries by default. See Errors. - A reasoning model spends
max_tokenson thinking too. See Reasoning. - To use the Messages API instead, use the Anthropic SDK or
langchain-anthropicwithbase_urlset to the gateway root.