NouveauBranchez n’importe quel agent sur UberLLM : une clé, tous les modèles, au prix catalogue ou moins.
UberLLM

LangChain

Le ChatOpenAI de LangChain (à partir de langchain-openai) pointe vers UberLLM avec un base_url et api_key. Tout le reste — chains, agents, tools, streaming — fonctionne sans changement.

Installation

pip install langchain langchain-openai

Python

import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="deepseek/deepseek-v4-flash",
    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 a priorité sur les variables d'environnement OPENAI_API_BASE / OPENAI_BASE_URL, donc un kwarg explicite est le plus fiable.

Streaming

for chunk in llm.stream("Count to five."):
    print(chunk.content, end="", flush=True)

Outils / agents

Parce que ChatOpenAI utilise le format d'appel d'outils d'OpenAI, bind_tools et les exécuteurs d'agents fonctionnent tels quels avec n'importe quel modèle UberLLM compatible avec les outils :

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-v4-flash",
  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

  • Chaque appel est envoyé à un fournisseur tiers disponible pour le modèle (Modèles et routage).
  • Chaque appel est facturé au prix du fournisseur, sans frais UberLLM (Tarification).