Skip to content

OpenRouter

Setup

Get your API key from OpenRouter, and export it as an environment variable:

export OPENROUTER_API_KEY=<YOUR_OPENROUTER_API_KEY>

Examples

from toolfront import Database

db = Database("postgresql://user:pass@host/db")

# Google Gemini via OpenRouter
result = db.ask(..., model="openrouter:google/gemini-2.0-flash-exp")

# Anthropic Claude via OpenRouter
result = db.ask(..., model="openrouter:anthropic/claude-3.5-sonnet")

OpenRouter Model Names

Always specify an OpenRouter model with the openrouter: prefix.