← Integrations · SDKs & frameworks

LangChain setup via the Kiree gateway

Connect LangChain to kiree.net: ChatOpenAI(base_url="https://kiree.net/v1", api_key="sk-…") — chains, agents and RAG with catalog models.

Why the gateway

Why the direct setup does not cover every case

LangChain normally targets the OpenAI endpoint. The gateway exposes an OpenAI-compatible endpoint; pass the base_url and key to ChatOpenAI and run chains, agents and RAG with catalog models.

Setup

Steps to your first request

·

Get a key

Create a sk-… key in the kiree.net console.

·

Install the package

pip install langchain-openai: the separate ChatOpenAI package for LangChain.

·

Set the base_url

ChatOpenAI(base_url="https://kiree.net/v1", api_key="sk-…", model="gpt-4o-mini") — then invoke/stream as usual.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
  base_url="https://kiree.net/v1",
  api_key="sk-…",
  model="gpt-4o-mini",
)
print(llm.invoke("Hello").content)

JS version: new ChatOpenAI({ configuration: { baseURL: "https://kiree.net/v1" }, apiKey: "sk-…", model: "gpt-4o-mini" }). Agents and tool-calling work with models that support function calling.

Check: run the snippet: the reply comes from a gateway model, usage visible in the console.

Models

What to connect in LangChain

Any text model from the catalog works on one key. Below are popular options to start.

Diagnostics

Common errors

!

401 Unauthorized

api_key is wrong or base_url lacks /v1: check the ChatOpenAI arguments.

!

404 model_not_found

The model ID is not from the kiree catalog: use exact IDs, e.g. gpt-4o-mini.

!

ImportError: langchain_openai

Only langchain is installed without langchain-openai: pip install langchain-openai.

FAQ

Frequently asked questions

How do I connect LangChain through the gateway?+

base_url=https://kiree.net/v1 sends requests to the gateway directly.

How are chains and agents billed?+

Tokens for every call are charged from the kiree.net balance.

Do agents with tools work?+

Yes, with models that support function calling: gpt-4o-mini, gpt-6-astra, claude-sonnet-4-6.

Can responses be streamed?+

Yes: llm.stream(...) works through the gateway the same as with the original API.

Get a key for LangChain

Create a key in a couple of minutes; pay only for actual usage, no subscription required.