Agents & tooling

OpenClaw, Hermes, Cursor, Continue, LangChain — anything that takes a base_url.

Anything that takes a base_url and a key works with IranRouter — no plugin, no adapter. This page gives the configuration for the common ones.

Environment variables (most tools)

Shell
export OPENAI_BASE_URL="https://iranrouter.com/v1"
export OPENAI_API_KEY="ir-..."

To make it permanent, put both lines in ~/.zshrc or ~/.bashrc. Some older libraries look for OPENAI_API_BASE instead of OPENAI_BASE_URL; if it will not connect, set both.

OpenClaw

Shell
export OPENAI_BASE_URL="https://iranrouter.com/v1"
export OPENAI_API_KEY="ir-..."
openclaw

Hermes

YAML
provider:
  type: openai
  base_url: https://iranrouter.com/v1
  api_key: ir-...
  model: anthropic/claude-sonnet-4.5

Tools that speak Anthropic

Shell
export ANTHROPIC_BASE_URL="https://iranrouter.com/anthropic"
export ANTHROPIC_API_KEY="ir-..."

The prefix is /anthropic, not /v1: the SDK and Claude Code append "/v1/messages" to the base URL themselves.

Details of /v1/messages →

Cursor

In Settings → Models, enable "Override OpenAI Base URL", enter the base URL and your ir- key, then add the model by its full ID (for example anthropic/claude-sonnet-4.5) as a custom model.

Text
Base URL: https://iranrouter.com/v1
API key:  ir-...

Continue

YAML
models:
  - name: Claude via IranRouter
    provider: openai
    model: anthropic/claude-sonnet-4.5
    apiBase: https://iranrouter.com/v1
    apiKey: ir-...

LangChain

Python
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="openai/gpt-4o-mini",
    api_key="ir-...",
    base_url="https://iranrouter.com/v1",
)

Before you leave an agent running

An autonomous agent can fire hundreds of requests in minutes. Two things before an overnight run:

  1. Give each agent its own key. You can then kill one without killing the rest, and usage reporting tells you which agent spent what.
  2. Put a daily budget on that key. A ceiling means a coding mistake cannot spend past your number.

An agent can also check its own headroom first: GET /v1/key