Integration

OpenRouter through the Vigil proxy

OpenRouter, a routing layer at openrouter.ai that forwards OpenAI-compatible requests to many model providers and bills in credits. Point your SDK's base URL at Vigil, add one header, and every OpenRouter call is logged with its cost, tokens, latency, errors and agent, then forwarded to https://openrouter.ai unchanged unless you switch on an optimisation. Prompt caching never changes answers. History trimming and model routing can: both are opt-in, run in Shadow first, and stop automatically if errors, cut-off answers or failed answers rise.

What Vigil records per OpenRouter call

Each OpenRouter call is one record: model id, tokens, cache reads and writes, latency, status, error code and agent. What a record holds, what happens to your OpenRouter key and what the hop costs in latency are answered once in the FAQ: what Vigil sees, your provider key and added latency.

Cost is left empty for this provider. OpenRouter prices are an upstream passthrough plus a fee, and the authoritative cost its responses carry is denominated in credits whose USD ratio is unverified. These calls are logged and monitored; their cost column stays empty rather than converting at a rate we cannot confirm.

Setup

The OpenRouter base URL is https://api.vigil.tools/{user_id}/openrouter; a request path such as /v1/chat/completions is forwarded unchanged, and your OpenRouter key stays in OPENROUTER_API_KEY. The path after the segment is whatever your client already uses, /v1 for most OpenAI-compatible APIs. The two Vigil headers, the modes and the error codes are the same for every provider: see the LLM proxy setup.

your OpenRouter client
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.OPENROUTER_API_KEY,   // unchanged
  baseURL: "https://api.vigil.tools/{user_id}/openrouter/v1",
  defaultHeaders: {
    // MUST be X-Vigil-Key: Authorization already carries your OpenRouter key.
    "X-Vigil-Key": "vk_your_vigil_key",
    "X-Vigil-Agent": "my-agent",
  },
});

const completion = await client.chat.completions.create({
  model: "<your model id>",
  messages: [{ role: "user", content: "Hello!" }],
});

Vigil forwards everything after /openrouter unchanged to https://openrouter.ai. The path above is whatever your client already uses — /v1 is the OpenAI-compatible default and is right for most, but some providers prefix it with a product segment. If you get a 404, compare it against the base URL in your OpenRouter config: the part after https://openrouter.ai is exactly what belongs here. OpenRouter prices are an upstream passthrough plus a fee, and the authoritative cost its responses carry is denominated in credits whose USD ratio is unverified. These calls are logged and monitored; their cost column stays empty rather than converting at a rate we cannot confirm.

your OpenRouter client
from openai import OpenAI

client = OpenAI(
    api_key=os.environ["OPENROUTER_API_KEY"],  # unchanged
    base_url="https://api.vigil.tools/{user_id}/openrouter/v1",
    default_headers={
        "X-Vigil-Key": "vk_your_vigil_key",
        "X-Vigil-Agent": "my-agent",
    },
)

completion = client.chat.completions.create(
    model="<your model id>",
    messages=[{"role": "user", "content": "Hello!"}],
)

Vigil forwards everything after /openrouter unchanged to https://openrouter.ai. The path above is whatever your client already uses — /v1 is the OpenAI-compatible default and is right for most, but some providers prefix it with a product segment. If you get a 404, compare it against the base URL in your OpenRouter config: the part after https://openrouter.ai is exactly what belongs here. OpenRouter prices are an upstream passthrough plus a fee, and the authoritative cost its responses carry is denominated in credits whose USD ratio is unverified. These calls are logged and monitored; their cost column stays empty rather than converting at a rate we cannot confirm.

terminal
curl https://api.vigil.tools/{user_id}/openrouter/v1/chat/completions \
  -H "content-type: application/json" \
  -H "Authorization: Bearer $OPENROUTER_API_KEY" \
  -H "X-Vigil-Key: vk_your_vigil_key" \
  -H "X-Vigil-Agent: my-agent" \
  -d '{
    "model": "<your model id>",
    "messages": [{ "role": "user", "content": "Hello!" }]
  }'

Vigil forwards everything after /openrouter unchanged to https://openrouter.ai. The path above is whatever your client already uses — /v1 is the OpenAI-compatible default and is right for most, but some providers prefix it with a product segment. If you get a 404, compare it against the base URL in your OpenRouter config: the part after https://openrouter.ai is exactly what belongs here. OpenRouter prices are an upstream passthrough plus a fee, and the authoritative cost its responses carry is denominated in credits whose USD ratio is unverified. These calls are logged and monitored; their cost column stays empty rather than converting at a rate we cannot confirm.

Prompt caching on OpenRouter

Vigil leaves the body untouched, so cache markers your own client sets are forwarded to whatever OpenRouter routes to. Vigil adds no key of its own.

With optimisation On: the provider caches automatically or not at all; Vigil records cache use and does not change the request. In Shadow, Vigil measures what caching would have saved and changes nothing. Off records the call and nothing more.

Questions

Which OpenRouter models does Vigil price?
None yet. OpenRouter prices are an upstream passthrough plus a fee, and the authoritative cost its responses carry is denominated in credits whose USD ratio is unverified. These calls are logged and monitored; their cost column stays empty rather than converting at a rate we cannot confirm.

Other providers: Anthropic · AWS Bedrock · Google Vertex · OpenAI · Google Gemini · Mistral · xAI Grok · DeepSeek · Together AI · Fireworks AI · Groq · Cerebras · Baseten · Moonshot · Z.ai · Cloudflare Workers AI