# Use Xantly with OpenHands

[OpenHands](https://github.com/All-Hands-AI/OpenHands) (formerly OpenDevin) is an autonomous coding agent, give it a task, it reads your code, runs commands, writes patches. Under the hood it uses LiteLLM for LLM dispatch, which means any OpenAI-compatible gateway just works. Xantly plugs in with three env vars.

## Prerequisites

- Docker (OpenHands runs the agent in a sandboxed container)
- A Xantly API key, [create one](/dashboard/api-keys)

## Setup

OpenHands reads LiteLLM-style env vars. Set these before running:

```bash
export LLM_API_KEY=xantly_sk_...
export LLM_BASE_URL=https://api.xantly.com/v1
export LLM_MODEL=openai/xantly/auto-quality
```

Note the `openai/` prefix, LiteLLM expects `<protocol>/<model>`.

Then run:

```bash
docker run -it --rm \
  -e LLM_API_KEY \
  -e LLM_BASE_URL \
  -e LLM_MODEL \
  -v /var/run/docker.sock:/var/run/docker.sock \
  -v $HOME/.openhands-state:/.openhands-state \
  -p 3000:3000 \
  docker.all-hands.dev/all-hands-ai/openhands:latest
```

Open [http://localhost:3000](http://localhost:3000) → OpenHands UI loads, with Xantly as the configured provider.

## Configure in UI

Alternative to env vars, once OpenHands is running, open **Settings**:

| Field | Value |
|---|---|
| LLM Provider | `openai` |
| LLM Model | `openai/xantly/auto-quality` |
| Base URL | `https://api.xantly.com/v1` |
| API Key | `xantly_sk_...` |

Save. Restart the agent for the settings to stick.

## First task

In the OpenHands UI, start a new session and give it a goal:

```
Clone github.com/tiangolo/fastapi, run the test suite, summarize failures.
```

OpenHands spins up a sandboxed Docker container, pulls the repo, runs `pytest`, reads output, summarizes. Every LLM call in that flow routes through Xantly.

## Model choice

| Model ID | When |
|---|---|
| `openai/xantly/auto-quality` | Agent default, reliable tool-calling. |
| `openai/anthropic/claude-sonnet-4.6` | Best tool-calling for long agent runs. |
| `openai/openai/gpt-5.4` | Tight structured outputs. |
| `openai/xantly/auto-value` | Budget-conscious long runs. |

**Don't use** `xantly/auto-speed` for OpenHands, speed-tier models trade tool-calling reliability for latency, and OpenHands relies heavily on tool calls.

## Verify

Give the agent a trivial task:

```
Print "pong" to the console using bash.
```

OpenHands should fire a `run_bash` tool call → see `pong` → return. Check your Xantly dashboard for the logged call.

## What you get

- **Agent waterfall fallback.** A mid-task provider outage doesn't kill a long OpenHands run, Xantly silently retries on the next-best model.
- **Semantic cache on sub-prompts.** OpenHands re-asks similar questions within a run ("what does this file do?"), cache returns instantly.
- **Memory across sessions.** If you restart OpenHands and give it the same project, Xantly's L3 memory can resurface prior decisions.
- **Cost visibility.** Each tool call's underlying LLM call logs separately, you see exactly which step burned tokens.
- **Budget caps.** Set a daily USD cap on your Xantly key to avoid runaway agent costs.

## Gotchas

**Prefix ambiguity: `openai/xantly/auto-quality`.** LiteLLM requires the protocol prefix. Full slug is `openai/<xantly-model-id>`. Double-slashes are normal.

**Docker socket mount.** OpenHands needs `/var/run/docker.sock` mounted to spin up sandbox containers. Safe, but double-check if you're on a managed host (some block this).

**Long sessions + budget.** OpenHands can run for 30+ minutes on a single task. Set `Dashboard → API Keys → Daily Budget USD` to a value you're comfortable with. Xantly will return 402 once hit; OpenHands surfaces this as a friendly error.

**Tool-call failures loop.** If a model can't reliably produce tool calls, OpenHands will retry. Pin to `anthropic/claude-sonnet-4.6` or use `xantly/auto-quality` (BaRP picks a reliable tool-caller).

**MCP support.** OpenHands has MCP client support in newer releases. Xantly's outgoing MCP calls pass through normally.

## Next steps

- [Aider](/docs/use-with-aider), less autonomous, more interactive.
- [Cline](/docs/use-with-cline), similar agent pattern in VS Code.
- [Claude Code](/docs/use-with-claude-code), Anthropic's CLI with MCP support.
- [Cost-Optimized Routing](/docs/cost-optimized-routing), how to keep agent runs cheap.
