This plugin provides integration with various models available through the OpenRouter API via the ElizaOS platform.
Add the plugin to your character configuration:
"plugins": ["@elizaos/plugin-openrouter"]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
// 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"
}.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
# 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
OPENROUTER_API_KEY(required): Your OpenRouter API key.OPENROUTER_BASE_URL: Custom API endpoint (default: https://openrouter.ai/api/v1).OPENROUTER_SMALL_MODEL: Specific model to use forTEXT_SMALLandOBJECT_SMALL. OverridesSMALL_MODELif set.OPENROUTER_LARGE_MODEL: Specific model to use forTEXT_LARGEandOBJECT_LARGE. OverridesLARGE_MODELif set.OPENROUTER_IMAGE_MODEL: Specific model to use forIMAGE_DESCRIPTION. OverridesIMAGE_MODELif set.SMALL_MODEL: Fallback model for small tasks (default: "google/gemini-flash"). Used ifOPENROUTER_SMALL_MODELis not set.LARGE_MODEL: Fallback model for large tasks (default: "google/gemini-pro"). Used ifOPENROUTER_LARGE_MODELis not set.IMAGE_MODEL: Fallback model for image analysis (default: "x-ai/grok-2-vision-1212"). Used ifOPENROUTER_IMAGE_MODELis not set.
The plugin currently provides these model types:
TEXT_SMALL: Optimized for fast, cost-effective text generation using the configured small model.TEXT_LARGE: For more complex text generation tasks requiring larger models, using the configured large model.OBJECT_SMALL: Generates structured JSON objects based on a prompt, using the configured small model.OBJECT_LARGE: Generates structured JSON objects based on a prompt, using the configured large model.IMAGE_DESCRIPTION: Analyzes images and provides descriptive text and titles, using the configured image model.
Note: Features like Image Generation, Audio Transcription, and Embeddings are not currently implemented in this specific OpenRouter plugin.