> 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.

# OpenHands (gateway)

> Set up OpenHands with the Respan gateway.

Route [OpenHands](https://openhands.dev)' LLM calls through the Respan gateway for automatic logging, caching, and model switching. OpenHands uses LiteLLM under the hood and accepts any OpenAI-compatible base URL, so only your `RESPAN_API_KEY` is needed.

## Setup

#### Install the OpenHands CLI

```bash
uv tool install openhands --python 3.12
```

#### Set environment variables

Add to your shell profile (`.bashrc`, `.zshrc`, or PowerShell `$PROFILE`):

```bash
export LLM_MODEL="openai/gpt-4o"
export LLM_BASE_URL="https://api.respan.ai/api"
export LLM_API_KEY="YOUR_RESPAN_API_KEY"
```

Keep the `openai/` prefix on the model. It tells LiteLLM to use the OpenAI-compatible protocol, and the gateway receives the part after the prefix.

No separate provider key needed. The Respan gateway handles provider authentication.

#### Run OpenHands

OpenHands ignores `LLM_*` environment variables unless you pass `--override-with-envs`:

```bash
openhands --override-with-envs
```

For a one-shot, non-interactive run:

```bash
openhands --headless --override-with-envs -t "your task"
```

All LLM calls now route through Respan.

> **Note**
>
> You can also set the same values from inside the CLI. Press `Ctrl+P`, open **Settings**, switch to **Advanced**, and fill in **Custom Model** (`openai/gpt-4o`), **Base URL** (`https://api.respan.ai/api`), and **API Key**. Settings persist in `~/.openhands/`, so you no longer need `--override-with-envs`.

## Switch models

Change `LLM_MODEL` to use any of the 1000+ models available through the gateway. Keep the `openai/` prefix.

```bash
export LLM_MODEL="openai/gpt-4o"
# export LLM_MODEL="openai/claude-sonnet-4-5-20250929"
# export LLM_MODEL="openai/gemini/gemini-3.5-flash"
```

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