Openrouter
openrouterYAML config
evalguard.config.yaml
providers:
- id: openrouter:anthropic/claude-3.5-sonnet
config:
apiKey: ${OPENROUTER_API_KEY}TypeScript usage
typescript
import { createProvider } from "@evalguard/core";
const provider = createProvider("openrouter", process.env.OPENROUTER_API_KEY);
const response = await provider.chat(
[{ role: "user", content: "Hello" }],
{ model: "anthropic/claude-3.5-sonnet" },
);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
- 011. Sign up for an account on the Openrouter platform.
- 022. Obtain your API key from the account dashboard.
- 033. Review the API documentation to understand the endpoints and request formats.
- 044. Test the API with sample requests using your API key.
- 055. 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