Openrouter

openrouter

YAML config

providers:
  - id: openrouter:anthropic/claude-3.5-sonnet
    config:
      apiKey: ${OPENROUTER_API_KEY}

TypeScript usage

import { createProvider } from "@evalguard/core";

const provider = createProvider("openrouter", process.env.OPENROUTER_API_KEY);
const response = await provider.complete({
  model: "anthropic/claude-3.5-sonnet",
  messages: [{ role: "user", content: "Hello" }],
});

Authentication

Set OPENROUTER_API_KEY in your environment. EvalGuard validates the key on first call and surfaces typed errors for 401 / 403 / rate-limit responses (with Retry-After parsing).

Setup walkthrough

  1. 1. Sign up for an account on the Openrouter platform.
  2. 2. Obtain your API key from the account dashboard.
  3. 3. Review the API documentation to understand the endpoints and request formats.
  4. 4. Test the API with sample requests using your API key.
  5. 5. Integrate the API into your application as per your requirements.

Gotchas

  • API rate limits can vary based on the model used; ensure to check the documentation for specifics.
  • Some models may not be available in certain regions due to compliance issues.
  • The API key must be included in every request; missing it will result in authentication errors.

Cost note

Pricing starts at $0.002 per 1,000 tokens for the cheapest models and goes up to $0.06 per 1,000 tokens for flagship models.

Recommended models

Eval / judge
gpt-3.5-turbo
Agent / tool-use
gpt-4
Code
code-davinci-002
Vision
dall-e-2

LLM-generated (llm-gpt-4o) · 2026-05-23