Files
elizaos--eliza/plugins/plugin-openrouter
wehub-resource-sync 426e9eeabd
Benchmark Bridge Tests / benchmark (bunx @biomejs/biome check packages/lifeops-bench/src, benchmark-lint) (push) Waiting to run
Benchmark Bridge Tests / benchmark (bunx vitest run --config packages/lifeops-bench/vitest.config.ts --root packages/lifeops-bench --passWithNoTests, benchmark-tests) (push) Waiting to run
Build Agent Image / build-and-push (push) Waiting to run
Chat shell gestures / Chat shell gesture + parity e2e (push) Waiting to run
Cloud Gateway Discord / Test (push) Waiting to run
Cloud Gateway Webhook / Test (push) Waiting to run
Cloud Tests / lint-and-types (push) Waiting to run
Cloud Tests / unit-tests (push) Waiting to run
Cloud Tests / integration-tests (push) Waiting to run
Cloud Tests / e2e-tests (push) Blocked by required conditions
CodeQL Advanced / Analyze (javascript-typescript) (push) Waiting to run
Deploy Apps Worker (Product 2) / Determine environment (push) Waiting to run
Deploy Apps Worker (Product 2) / Deploy apps worker to apps-control host (${{ needs.determine-env.outputs.environment }}) (push) Blocked by required conditions
Deploy Eliza Provisioning Worker / Determine environment (push) Waiting to run
Deploy Eliza Provisioning Worker / Deploy worker to Hetzner host (${{ needs.determine-env.outputs.environment }} @ ${{ needs.determine-env.outputs.deployment_sha }}) (push) Blocked by required conditions
Dev Smoke / Classify changed paths (push) Waiting to run
Dev Smoke / bun run dev onboarding chat (push) Blocked by required conditions
Dev Smoke / Vite HMR dependency-level smoke (push) Blocked by required conditions
Electrobun Submodule Guard / electrobun gitlink is fetchable (push) Waiting to run
Publish @elizaos/example-code / check_npm (push) Waiting to run
Publish @elizaos/example-code / publish_npm (push) Blocked by required conditions
Publish @elizaos/plugin-elizacloud / verify_version (push) Waiting to run
Publish @elizaos/plugin-elizacloud / publish_npm (push) Blocked by required conditions
Sandbox Live Smoke / Sandbox live smoke (push) Waiting to run
Snap Build & Test / Build Snap (amd64) (push) Waiting to run
Snap Build & Test / Build Snap (arm64) (push) Waiting to run
supply-chain / sbom (push) Waiting to run
supply-chain / vulnerability-scan (push) Waiting to run
Build, Push & Deploy to Phala Cloud / build-and-push (push) Waiting to run
Test Packaging / Validate Packaging Configs (push) Waiting to run
Test Packaging / PyPI on Python ${{ matrix.python }} (push) Waiting to run
Test Packaging / Pack & Test JS Tarballs (push) Waiting to run
Test Packaging / elizaos CLI global-install smoke (node + bun) (push) Waiting to run
UI Fixture E2E / ui-fixture-e2e (push) Waiting to run
UI Fixture E2E / fixture-e2e (push) Waiting to run
UI Story Gate / story-gate (push) Waiting to run
vault-ci / test (macos-latest) (push) Waiting to run
vault-ci / test (ubuntu-latest) (push) Waiting to run
vault-ci / test (windows-latest) (push) Waiting to run
vault-ci / app-core wiring tests (push) Waiting to run
verify-patches / verify patches/CHECKSUMS.sha256 (push) Waiting to run
Voice Benchmark Smoke / voice-emotion fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voiceagentbench fixture smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench-quality unit smoke (push) Waiting to run
Voice Benchmark Smoke / voicebench TypeScript unit (no audio) (push) Waiting to run
Voice Benchmark Smoke / voice bench smoke summary (push) Blocked by required conditions
Windows CI / windows ([bun run --cwd packages/app-core test bun run --cwd packages/elizaos test bun run --cwd packages/cloud/shared test], app-and-cli) (push) Waiting to run
Windows CI / windows ([bun run --cwd packages/scenario-runner test bun run --cwd packages/vault test bun run --cwd packages/security test bun run --cwd plugins/plugin-coding-tools test], framework-packages) (push) Waiting to run
Windows CI / windows ([bun run --cwd plugins/plugin-elizacloud test bun run --cwd plugins/plugin-discord test bun run --cwd plugins/plugin-anthropic test bun run --cwd plugins/plugin-openai test bun run --cwd plugins/plugin-app-control test bun run --cwd plugins/pl… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run build --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/agent --concurrency=4 node packages/scripts/run-bash-linux-only.mjs scripts/verify-riscv64-buildpaths.sh node packages/scripts/run… (push) Waiting to run
Windows CI / windows ([node packages/scripts/run-turbo.mjs run typecheck --filter=@elizaos/core --filter=@elizaos/shared --filter=@elizaos/cloud-shared --concurrency=4 bun run --cwd packages/core test bun run --cwd packages/shared test], core-runtime, 75) (push) Waiting to run
Test Packaging / Build & Test PyPI Package (push) Waiting to run
Voice Workbench / headless workbench (mocked backends) (push) Has been cancelled
Voice Workbench / real acoustic lane (nightly, provisioned only) (push) Has been cancelled
ci / test (push) Has been cancelled
ci / lint-and-format (push) Has been cancelled
ci / build (push) Has been cancelled
ci / dev-startup (push) Has been cancelled
gitleaks / gitleaks (push) Has been cancelled
Markdown Links / Relative Markdown Links (push) Has been cancelled
Quality (Extended) / Homepage Build (PR smoke) (push) Has been cancelled
Quality (Extended) / Comment-only diff guard (push) Has been cancelled
Quality (Extended) / Format + Type Safety Ratchet (push) Has been cancelled
Quality (Extended) / Develop Gate (secret scan + UI determinism) (push) Has been cancelled
Quality (Extended) / Develop Gate (lint) (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:43:05 +08:00
..

@elizaos/plugin-openrouter

elizaOS plugin that routes text generation, image description, image generation, and text embedding through the OpenRouter API, giving Eliza agents access to hundreds of hosted models via a single API key.

Usage

Add the plugin to your character configuration:

"plugins": ["@elizaos/plugin-openrouter"]

Configuration

The plugin requires the OpenRouter API key and can be configured via environment variables or character settings.

Character Settings Example:

"settings": {
  "OPENROUTER_API_KEY": "your_openrouter_api_key",
  "OPENROUTER_BASE_URL": "https://openrouter.ai/api/v1", // Optional: Default is OpenRouter endpoint
  "OPENROUTER_SMALL_MODEL": "google/gemini-flash", // Optional: Overrides default small model
  "OPENROUTER_LARGE_MODEL": "google/gemini-pro", // Optional: Overrides default large model
  "OPENROUTER_IMAGE_MODEL": "x-ai/grok-2-vision-1212", // Optional: Overrides default image model
  "OPENROUTER_IMAGE_GENERATION_MODEL": "google/gemini-2.5-flash-image-preview", // Optional: Overrides default image generation model
  "OPENROUTER_EMBEDDING_MODEL": "openai/text-embedding-3-small", // Optional: Overrides default embedding model
  "OPENROUTER_EMBEDDING_DIMENSIONS": "1536", // Optional: Sets embedding vector dimensions (384, 512, 768, 1024, 1536, 2048, 3072)
  "OPENROUTER_BROWSER_BASE_URL": "https://your-proxy.example.com/openrouter"
  // Fallbacks if specific OPENROUTER models are not set
  "SMALL_MODEL": "google/gemini-flash",
  "LARGE_MODEL": "google/gemini-pro",
  "IMAGE_MODEL": "x-ai/grok-2-vision-1212",
  "IMAGE_GENERATION_MODEL": "google/gemini-2.5-flash-image-preview",
  "EMBEDDING_MODEL": "openai/text-embedding-3-small",
  "EMBEDDING_DIMENSIONS": "1536"
}

.env File Example:

OPENROUTER_API_KEY=your_openrouter_api_key
# Optional overrides:
OPENROUTER_BASE_URL=https://openrouter.ai/api/v1
OPENROUTER_SMALL_MODEL=google/gemini-flash
OPENROUTER_LARGE_MODEL=google/gemini-pro
OPENROUTER_IMAGE_MODEL=x-ai/grok-2-vision-1212
OPENROUTER_IMAGE_GENERATION_MODEL=google/gemini-2.5-flash-image-preview
OPENROUTER_EMBEDDING_MODEL=openai/text-embedding-3-small
OPENROUTER_EMBEDDING_DIMENSIONS=1536
# Browser proxy (frontend builds only)
OPENROUTER_BROWSER_BASE_URL=https://your-proxy.example.com/openrouter
# Fallbacks if specific OPENROUTER models are not set
SMALL_MODEL=google/gemini-flash
LARGE_MODEL=google/gemini-pro
IMAGE_MODEL=x-ai/grok-2-vision-1212
IMAGE_GENERATION_MODEL=google/gemini-2.5-flash-image-preview
EMBEDDING_MODEL=openai/text-embedding-3-small
EMBEDDING_DIMENSIONS=1536

Configuration Options

  • OPENROUTER_API_KEY (required): Your OpenRouter API key.
  • OPENROUTER_BASE_URL: Custom API endpoint (default: https://openrouter.ai/api/v1).
  • OPENROUTER_BROWSER_BASE_URL: Browser-only base URL to a proxy endpoint that forwards requests to OpenRouter without exposing keys.

Browser mode and proxying

When bundled for the browser, this plugin avoids sending Authorization headers. Set OPENROUTER_BROWSER_BASE_URL to a server-side proxy you control that injects the OpenRouter API key. This prevents exposing secrets in frontend builds.

Example minimal proxy (Express):

import express from "express";
import fetch from "node-fetch";

const app = express();
app.use(express.json());

app.post("/openrouter/*", async (req, res) => {
  const url = `https://openrouter.ai/api/v1/${req.params[0]}`;
  const r = await fetch(url, {
    method: "POST",
    headers: {
      Authorization: `Bearer ${process.env.OPENROUTER_API_KEY}`,
      "Content-Type": "application/json",
    },
    body: JSON.stringify(req.body),
  });
  res
    .status(r.status)
    .set(Object.fromEntries(r.headers))
    .send(await r.text());
});

app.listen(3000);
  • OPENROUTER_SMALL_MODEL: Specific model to use for TEXT_SMALL. Overrides SMALL_MODEL if set.
  • OPENROUTER_LARGE_MODEL: Specific model to use for TEXT_LARGE. Overrides LARGE_MODEL if set.
  • OPENROUTER_IMAGE_MODEL: Specific model to use for IMAGE_DESCRIPTION. Overrides IMAGE_MODEL if set.
  • OPENROUTER_IMAGE_GENERATION_MODEL: Specific model to use for IMAGE generation. Overrides IMAGE_GENERATION_MODEL if set.
  • OPENROUTER_EMBEDDING_MODEL: Specific model to use for TEXT_EMBEDDING. Overrides EMBEDDING_MODEL if set.
  • OPENROUTER_TRANSCRIPTION_MODEL: Specific model to use for TRANSCRIPTION (default: openai/whisper-large-v3). Overrides TRANSCRIPTION_MODEL if set.
  • OPENROUTER_EMBEDDING_DIMENSIONS: Number of dimensions for embedding vectors. Supported values: 384, 512, 768, 1024, 1536, 2048, 3072. Defaults to 1536.
  • OPENROUTER_AUTO_CLEANUP_IMAGES: Boolean flag for auto-cleanup of generated images, read by shouldAutoCleanupImages() in utils/config.ts (default: "false").
  • SMALL_MODEL: Fallback model for small tasks (default: "google/gemini-2.5-flash-lite"). Used if OPENROUTER_SMALL_MODEL is not set.
  • LARGE_MODEL: Fallback model for large tasks (default: "google/gemini-2.5-flash"). Used if OPENROUTER_LARGE_MODEL is not set.
  • IMAGE_MODEL: Fallback model for image analysis (default: "x-ai/grok-2-vision-1212"). Used if OPENROUTER_IMAGE_MODEL is not set.
  • IMAGE_GENERATION_MODEL: Fallback model for image generation (default: "google/gemini-2.5-flash-image-preview"). Used if OPENROUTER_IMAGE_GENERATION_MODEL is not set.
  • EMBEDDING_MODEL: Fallback model for text embeddings (default: "openai/text-embedding-3-small"). Used if OPENROUTER_EMBEDDING_MODEL is not set.
  • TRANSCRIPTION_MODEL: Fallback model for audio transcription (default: "openai/whisper-large-v3"). Used if OPENROUTER_TRANSCRIPTION_MODEL is not set.
  • EMBEDDING_DIMENSIONS: Fallback dimension setting for embeddings (default: "1536"). Used if OPENROUTER_EMBEDDING_DIMENSIONS is not set.

Provided Models

The plugin registers these model types:

  • TEXT_NANO: Fastest/cheapest text generation; falls back to the small model when no nano override is set.
  • TEXT_SMALL: Fast, cost-effective text generation (default: google/gemini-2.5-flash-lite). Supports tools, toolChoice, and responseSchema.
  • TEXT_MEDIUM: Mid-tier text generation; falls back to the small model when no medium override is set.
  • TEXT_LARGE: Complex text generation tasks (default: google/gemini-2.5-flash). Supports tools, toolChoice, and responseSchema.
  • TEXT_MEGA: Largest text tasks; falls back to the large model when no mega override is set.
  • RESPONSE_HANDLER: Should-respond decisions; falls back to the nano model.
  • ACTION_PLANNER: Action planning; falls back to the medium model.
  • IMAGE_DESCRIPTION: Analyzes images and provides descriptive text (default: x-ai/grok-2-vision-1212).
  • IMAGE: Generates images from text prompts (default: google/gemini-2.5-flash-image-preview).
  • TEXT_EMBEDDING: Vector embeddings with configurable dimensions (default: openai/text-embedding-3-small, 1536 dims).
  • TRANSCRIPTION: Transcribes audio through OpenRouter's /audio/transcriptions endpoint (default: openai/whisper-large-v3).

Transcription inputs may be URL strings, Buffer, Blob / File, core { audioUrl, prompt? }, or local { audio, model?, language?, temperature?, format?, mimeType? } objects. The handler sends base64 input_audio JSON to OpenRouter and returns the transcript text.