Skip to content

RustyCoderX/Openrouter

Repository files navigation

UnifiedAi

A unified AI chat interface powered by OpenRouter, allowing users to interact with multiple AI models in a clean, responsive web application.

Features

  • Multi-Model Support: Choose from popular AI models including GPT-4o Mini, GPT-4o, Claude 3 Haiku, Claude 3 Sonnet, and Gemini Pro
  • Custom API Integration: Connect to external AI providers by providing your own API endpoint, key, and model name
  • Real-time Chat: Seamless conversation experience with message history
  • Dark Mode Support: Automatic theme switching based on system preferences
  • Responsive Design: Works on desktop and mobile devices
  • Usage Limits: Built-in rate limiting for OpenRouter models (3 requests per model)
  • Buy Credits: Direct link to purchase OpenRouter credits

Tech Stack

  • Frontend: Next.js 15, React, TypeScript, Tailwind CSS
  • Backend: Next.js API Routes
  • AI Provider: OpenRouter (with custom API support)
  • Styling: Tailwind CSS with dark mode
  • Icons: Custom SVG logo

Getting Started

Prerequisites

  • Node.js 18+
  • npm, yarn, pnpm, or bun
  • OpenRouter API key (get one at openrouter.ai)

Installation

  1. Clone the repository:
git clone <repository-url>
cd router
  1. Install dependencies:
npm install
  1. Create a .env.local file in the root directory and add your OpenRouter API key:
OPENROUTER_API_KEY=your-api-key-here
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser.

Usage

Using OpenRouter Models

  1. Select your preferred model from the dropdown
  2. Type your message in the text box
  3. Press Enter or click Send

Using Custom AI APIs

  1. Check the "Use Custom API" checkbox
  2. Enter your API URL (e.g., https://api.openai.com/v1/chat/completions)
  3. Enter your API key
  4. Enter the model name
  5. Start chatting

Project Structure

router/
├── app/
│   ├── api/chat/
│   │   └── route.ts          # Chat API endpoint
│   ├── globals.css           # Global styles
│   ├── layout.tsx            # Root layout
│   └── page.tsx              # Main chat interface
├── public/
│   ├── logo.svg              # App logo
│   └── ...                   # Other static assets
├── .env.local                # Environment variables
└── README.md                 # This file

API Reference

POST /api/chat

Send a chat message to an AI model.

Request Body:

{
  "message": "Hello, world!",
  "model": "openai/gpt-4o-mini",
  "useCustom": false,
  "customUrl": "",
  "customKey": "",
  "customModel": ""
}

Response:

{
  "reply": "Hello! How can I help you today?"
}

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

License

This project is licensed under the MIT License.

Acknowledgments

Openrouter

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors