Skip to Content
Launching the open-source gateway

LangChain (gateway)

Route LangChain’s underlying LLM calls through the Respan gateway to use 1000+ models from different providers. Only your Respan API key is needed. No separate provider keys are required.

Paste this into your coding agent:

Help me set up the Respan gateway with the LangChain integration. Follow https://www.respan.ai/docs/integrations/gateway/lang-chain.md

Setup

Install packages

Terminal
pip install langchain langchain-openai python-dotenv

Set environment variables

Terminal
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"

No OPENAI_API_KEY needed: the Respan gateway handles provider authentication.

Point LangChain to the Respan gateway

Python
import os from langchain_openai import ChatOpenAI llm = ChatOpenAI( api_key=os.environ["RESPAN_API_KEY"], base_url="https://gateway.respan.ai", model="gpt-5.5", ) response = llm.invoke("Say hello through the Respan gateway.") print(response.content)

LangGraph

LangGraph uses LangChain’s chat models, so the same ChatOpenAI works in a graph. Install langgraph next to langchain-openai and pass llm to your nodes or agents.

Terminal
pip install langgraph langchain-openai

Switch models

Change the model parameter on ChatOpenAI to use another OpenAI model through the same gateway-backed endpoint.

Python
llm = ChatOpenAI( api_key=os.environ["RESPAN_API_KEY"], base_url="https://gateway.respan.ai", model="gpt-5.5", ) llm = ChatOpenAI( api_key=os.environ["RESPAN_API_KEY"], base_url="https://gateway.respan.ai", model="gpt-5-mini", )

See the full model list .

Respan parameters

Pass additional Respan parameters via extra_body for gateway features.

Python
llm = ChatOpenAI( base_url="https://gateway.respan.ai", api_key=os.environ["RESPAN_API_KEY"], model="gpt-5.5", extra_body={ "customer_identifier": "user_123", "metadata": {"session_id": "abc123"}, "thread_identifier": "conversation_456", }, )

See Respan params & metadata for the full list.