Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file removed .test
Empty file.
74 changes: 72 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Chat with AI to build React apps instantly. An example app made by the [Firecrawl](https://firecrawl.dev/?ref=open-lovable-github) team. For a complete cloud solution, check out [Lovable.dev](https://lovable.dev/) ❤️.

<img src="https://media1.giphy.com/media/v1.Y2lkPTc5MGI3NjExbmZtaHFleGRsMTNlaWNydGdianI4NGQ4dHhyZjB0d2VkcjRyeXBucCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/ZFVLWMa6dVskQX0qu1/giphy.gif" alt="Open Lovable Demo" width="100%"/>
<img src="https://media2.giphy.com/media/v1.Y2lkPTc5MGI3NjExODAwZGJzcDVmZGYxc3MyNDUycTliYnAwem1qbzhtNHh0c2JrNDdmZCZlcD12MV9pbnRlcm5hbF9naWZfYnlfaWQmY3Q9Zw/LMYzMkNmOecj3yFw81/giphy.gif" alt="Open Lovable Demo" width="100%"/>

## Setup

Expand All @@ -29,6 +29,10 @@ OPENAI_API_KEY=your_openai_api_key # https://platform.openai.com
GEMINI_API_KEY=your_gemini_api_key # https://aistudio.google.com/app/apikey
GROQ_API_KEY=your_groq_api_key # https://console.groq.com

# Optional: OpenRouter - Access 100+ free and paid AI models
# Get API key at https://openrouter.ai
OPENROUTER_API_KEY=your_openrouter_api_key

# =================================================================
# FAST APPLY (Optional - for faster edits)
# =================================================================
Expand Down Expand Up @@ -62,6 +66,72 @@ pnpm dev # or npm run dev / yarn dev

Open [http://localhost:3000](http://localhost:3000)

## 🚀 Using OpenRouter (Recommended!)

OpenRouter gives you access to 100+ AI models, many completely **FREE**. It's the easiest way to try different models without managing multiple API keys!

### Why OpenRouter?
- ✅ **100+ models** including Llama 3.3, Mistral, Claude, GPT-4, and more
- ✅ **Many FREE models** with no credit card required
- ✅ **Pay-as-you-go** - only pay for what you use
- ✅ **Unified API** - same interface for all models
- ✅ **Easy fallbacks** - automatically use alternative models if one fails

### Quick Setup

1. **Get OpenRouter API Key**
- Visit https://openrouter.ai
- Sign up (free, no credit card needed)
- Copy your API key from https://openrouter.ai/keys

2. **Add to `.env.local`**
```env
OPENROUTER_API_KEY=your_openrouter_api_key
```

3. **Select an OpenRouter Model**
- In the UI, find model names starting with `openrouter/`
- Try free models like:
- `meta-llama/llama-3.3-70b-instruct` (best free option)
- `mistralai/mistral-large`
- `cohere/command-r-plus`

### Available OpenRouter Models

**Free Models:**
- Meta Llama 3.3 70B
- Mistral Large
- Cohere Command R+
- And many more!

**Premium Models:**
- OpenAI GPT-4, GPT-4 Turbo
- Anthropic Claude 3
- Google Gemini

Check https://openrouter.ai/models for the complete list and pricing.

### API Endpoint

Use the `/api/models` endpoint to browse available models:

```bash
# Get all OpenRouter models
curl http://localhost:3000/api/models?provider=openrouter

# Filter free models only
curl http://localhost:3000/api/models?provider=openrouter&free=true

# Search by name
curl http://localhost:3000/api/models?search=llama
```

## License

MIT

````

## License

MIT
MIT
18 changes: 18 additions & 0 deletions app/api/analyze-edit-intent/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { createOpenAI } from '@ai-sdk/openai';
import { createGoogleGenerativeAI } from '@ai-sdk/google';
import { generateObject } from 'ai';
import { z } from 'zod';
import createOpenRouter from '@/lib/ai/openrouter-client';
// import type { FileManifest } from '@/types/file-manifest'; // Type is used implicitly through manifest parameter

// Check if we're using Vercel AI Gateway
Expand All @@ -31,6 +32,15 @@ const googleGenerativeAI = createGoogleGenerativeAI({
baseURL: isUsingAIGateway ? aiGatewayBaseURL : undefined,
});

// OpenRouter provider (if API key is configured)
let openrouter: any = null;
if (process.env.OPENROUTER_API_KEY) {
openrouter = createOpenRouter({
apiKey: process.env.OPENROUTER_API_KEY,
baseURL: 'https://openrouter.ai/api/v1',
});
}

// Schema for the AI's search plan - not file selection!
const searchPlanSchema = z.object({
editType: z.enum([
Expand Down Expand Up @@ -115,6 +125,14 @@ export async function POST(request: NextRequest) {
}
} else if (model.startsWith('google/')) {
aiModel = googleGenerativeAI(model.replace('google/', ''));
} else if (model.startsWith('openrouter/')) {
if (!openrouter) {
return NextResponse.json({
success: false,
error: 'OpenRouter API key not configured'
}, { status: 400 });
}
aiModel = openrouter(model.replace('openrouter/', ''));
} else {
// Default to groq if model format is unclear
aiModel = groq(model);
Expand Down
Loading