---
title: "Move an OpenRouter caller to a Caveman local trial"
description: "This guide moves one development caller from OpenRouter to a direct provider through Caveman's local proxy. It is useful when you want to measure context compression independently of OpenRouter's rout"
canonical: https://caveman.so/switch/openrouter
last-updated: 2026-09-07
---

# Move an OpenRouter caller to a Caveman local trial

This guide moves one development caller from OpenRouter to a direct provider through Caveman's local proxy. It is useful when you want to measure context compression independently of OpenRouter's routing choices.

You need your own credential for the destination provider. OpenRouter credits and keys do not transfer. Keep the existing OpenRouter route available until the candidate passes your task checks.

## Save the configuration you depend on

Record the base URL, model ID, provider ordering, fallback rules, and any request options that are specific to OpenRouter. Save required headers without copying secret values into the experiment log. Note whether your application uses the OpenAI-compatible API, the OpenRouter client SDK, or its agent SDK.

The example below targets a caller that already uses the OpenAI Python client. An agent SDK migration also needs tool-loop and state handling; changing its URL alone is not equivalent.

Before buying or enabling anything else, confirm that the destination account has access to the model and capabilities your task needs. Use an existing approved test credential.

## Map the model and endpoint

OpenRouter's endpoint includes `/api/v1`. Caveman's direct OpenAI mount uses `/openai/v1`. The model string also belongs to the destination provider's catalog.

| Existing setting | Candidate setting |
| --- | --- |
| OpenRouter base URL | `http://127.0.0.1:8787/openai/v1` for OpenAI |
| `OPENROUTER_API_KEY` | A direct `OPENAI_API_KEY` |
| OpenRouter model ID | The corresponding model ID supported by OpenAI |
| OpenRouter routing options | Remove or replace only after identifying their behavior |
| OpenRouter account usage | Direct-provider usage for the candidate |

Do not strip a prefix and assume the result exists. Confirm the current provider model ID and keep it fixed for the comparison.

## Start the local test path

```bash
npm install -g @caveman-ai/cli
caveman setup --install
caveman tools config set think.mode compress
caveman start
```

Run the application on the same host as the loopback listener. For a container, `127.0.0.1` is the container itself; use a supported same-host arrangement rather than exposing the listener to the network.

Use an environment variable to select the destination model, and keep the credential outside source:

```python
import os
from openai import OpenAI

client = OpenAI(
    base_url="http://127.0.0.1:8787/openai/v1",
    api_key=os.environ["OPENAI_API_KEY"],
)
response = client.chat.completions.create(
    model=os.environ["DIRECT_MODEL_ID"],
    messages=[{"role": "user", "content": "Reply with the word ready."}],
)
print(response.choices[0].message.content)
```

This first request verifies connectivity. Its short prompt is not a compression benchmark. Use a captured tool-heavy task for the next check.

## Validate the features your application uses

Test structured output, each tool-call shape, streaming completion, and cancellation if they are part of the workload. Keep the baseline's retry budget explicit. Removing OpenRouter's fallback behavior without replacing it can change reliability even when normal requests pass.

On paths without native agent recovery tools, compression depends on the proxy's supported recovery behavior. Confirm that your request mode is eligible. Do not mark unchanged streaming traffic as optimized.

Record the provider request result and total usage. Unknown model pricing in a local report is not zero cost. Compare with the destination provider's usage records and the OpenRouter baseline using [the measurement guide](/guides/measure-agent-cost).

## Keep OpenRouter if you only need context changes

A named compatibility mount can be evaluated for an OpenAI-shaped upstream. Follow [the provider-route reference](https://docs.caveman.so/docs/proxy/providers) and validate the exact extensions your application uses. We do not present that as certified support for every OpenRouter feature.

For coding agents, [local output compression](/guides/prompt-compression) can also be tested before making a provider-account migration. Pick the smallest change that answers your cost question.

## Roll back

Restore the saved OpenRouter client, model ID, and routing options. Start a fresh conversation so it does not contain handles from the candidate's local store. Keep the candidate store until any remaining trial sessions finish.

Compare this guide with [OpenRouter's quickstart](https://openrouter.ai/docs/quickstart) and the [Caveman comparison](/compare/openrouter). A successful local trial is the evidence needed to discuss a wider rollout; it does not transfer billing or historical usage records.
