Skip to main content

OpenRouter Integration

Use your own AI models through OpenRouter API.

Overview

OpenRouter provides access to multiple AI models through a single API:

  • Claude (Anthropic)
  • GPT-4, GPT-5 (OpenAI)
  • Gemini (Google)
  • Llama (Meta)
  • And many more

Setup

1. Get OpenRouter API Key

  1. Go to OpenRouter
  2. Sign up or log in
  3. Navigate to API Keys
  4. Create a new key

2. Add to Your Project

In Prompt To App:

  1. Click ExtensionsOpenRouter
  2. Enter your API key
  3. Select models to use

Use Cases

Custom AI Features

"Add a chatbot that uses GPT-4 to answer customer questions"

AI generates:

  • Chat interface component
  • OpenRouter API integration
  • Message history management
  • Streaming response handling

Content Generation

"Create a blog post generator using Claude Sonnet"

AI generates:

  • Input form for topic/keywords
  • OpenRouter API call
  • Markdown rendering
  • Export functionality

Example Implementation

const response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.OPENROUTER_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'anthropic/claude-3.5-sonnet',
messages: [
{ role: 'user', content: 'Hello!' }
],
}),
});

const data = await response.json();
console.log(data.choices[0].message.content);

Available Models

  • anthropic/claude-3.5-sonnet
  • openai/gpt-4-turbo
  • google/gemini-pro
  • meta-llama/llama-3-70b

See OpenRouter Models for full list.