LangChain
LangChain's ChatOpenAI (from langchain-openai) points at UberLLM with a
base_url and api_key. Everything else — chains, agents, tools, streaming —
works unchanged.
Install
pip install langchain langchain-openai
Python
import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="deepseek/deepseek-v3.1",
base_url="https://api.uberllm.dev/v1",
api_key=os.environ["UBERLLM_API_KEY"],
)
print(llm.invoke("Say hello in one sentence.").content)
base_url takes precedence over the OPENAI_API_BASE / OPENAI_BASE_URL
environment variables, so an explicit kwarg is the most reliable.
Streaming
for chunk in llm.stream("Count to five."):
print(chunk.content, end="", flush=True)
Tools / agents
Because ChatOpenAI talks the OpenAI tool-calling format, bind_tools and the
agent executors work as-is against any tool-capable UberLLM model:
from langchain_core.tools import tool
@tool
def get_weather(city: str) -> str:
"Return the weather for a city."
return f"Sunny in {city}."
agent_llm = llm.bind_tools([get_weather])
print(agent_llm.invoke("What's the weather in Paris?").tool_calls)
JavaScript / TypeScript
import { ChatOpenAI } from "@langchain/openai";
const llm = new ChatOpenAI({
model: "deepseek/deepseek-v3.1",
apiKey: process.env.UBERLLM_API_KEY,
configuration: { baseURL: "https://api.uberllm.dev/v1" },
});
const res = await llm.invoke("Say hello in one sentence.");
console.log(res.content);
Notes
- Append
:flooror:nitroto the model id for cheapest / fastest routing (Models & routing). - No inference markup; you pay the provider's token price (Pricing).