Overview

OpenRouter acts as a unified interface to access multiple LLM providers through a single API. This simplifies working with different AI models in your application.

Available Models

OpenRouter supports leading LLM providers:
  • GPT-4 (OpenAI)
  • Claude 3 (Anthropic)
  • Gemini Pro (Google)
  • Mistral
  • And many more… (see OpenRouter Models for the full list)

Example Usage

// app/actions/ai.ts
'use server';

import { streamText } from 'ai';
import { openrouter } from '@/lib/openrouter';

export async function TextStream(prompt: string) {

 const result = streamText({
		model: openrouter("gemini-1.5-flash"),
		messages: [
      {
        role: "user",
        content: prompt,
      },
    ],
	}); // streamText is a function from the ai package

  return result;
}