> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://respan.ai/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://respan.ai/docs/_mcp/server.

# LangGraph (gateway)

> Set up LangGraph with the Respan gateway.

Route LangGraph'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 required.

## Setup

#### Install packages

**`Python`**

```bash Python
pip install langgraph langchain-openai python-dotenv
```

**`TypeScript`**

```bash TypeScript
npm install @langchain/langgraph @langchain/openai zod
```

#### Set environment variables

```bash
export RESPAN_API_KEY="YOUR_RESPAN_API_KEY"
```

No `OPENAI_API_KEY` needed — the Respan gateway handles provider authentication.

#### Point LangGraph's LLM to the Respan gateway

**`Python`**

```python Python
import os
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    api_key=os.environ["RESPAN_API_KEY"],
    base_url=os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api"),
    model="gpt-5.5",
)
```

**`TypeScript`**

```typescript TypeScript
import { ChatOpenAI } from "@langchain/openai";

const llm = new ChatOpenAI({
  model: "gpt-5.5",
  apiKey: process.env.RESPAN_API_KEY,
  configuration: {
    baseURL: process.env.RESPAN_BASE_URL ?? "https://api.respan.ai/api",
  },
});
```

Then build and run your graph as usual.

## Switch models

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

```python
llm = ChatOpenAI(api_key=..., base_url="https://api.respan.ai/api", model="gpt-5.5")
llm = ChatOpenAI(api_key=..., base_url="https://api.respan.ai/api", model="gpt-5-mini")
```

> **Note**
>
> `ChatOpenAI` is LangGraph's OpenAI-compatible chat adapter. This page avoids showing Claude or Gemini inside that OpenAI-named adapter; use the Respan API or OpenAI SDK gateway pages for provider-neutral Claude and Gemini examples.

See the [full model list](https://platform.respan.ai/platform/models).