OpenRouter AI Recipe (recipes/openrouter.ts)

inbrain · src/core/ai/recipes/openrouter.ts · typescript · MIT
ai, integration, tag:multi-provider

Single-key fan-out recipe for OpenRouter gateway providing unified access to OpenAI, Anthropic, Google, DeepSeek and other LLM providers via OpenAI-compatible API.

// Source: https://github.com/inbrainfun/inbrain | License: MIT | Copyright 2026 Inbrain Contributors
// Provided via justclaw.it.com; keep this notice with the code.
import type { Recipe } from '../types.ts';

/**
 * OpenRouter — single-key fan-out to OpenAI, Anthropic, Google, DeepSeek, and
 * dozens of other providers via a single OpenAI-compatible endpoint at
 * https://openrouter.ai/api/v1.
 *
 * One key, many models. Use `openrouter:<provider>/<model>` strings:
 *   openrouter:openai/gpt-5.2
 *   openrouter:anthropic/claude-sonnet-4.6
 *   openrouter:google/gemini-3-flash-preview
 *
 * Embeddings: OpenRouter exposes `/v1/embeddings` proxying OpenAI's
 * text-embedding-3-small (1536 dims) plus Matryoshka shrink via the SDK's
 * `dimensions` field. Catalog also includes text-embedding-

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key