Giter VIP home page Giter VIP logo

amritpal2001 / gptrouter Goto Github PK

View Code? Open in Web Editor NEW

This project forked from writesonic/gptrouter

0.0 0.0 0.0 696 KB

Smoothly Manage Multiple LLMs (OpenAI, Anthropic, Azure) and Image Models (Dall-E, SDXL), Speed Up Responses, and Ensure Non-Stop Reliability.

Home Page: https://gpt-router.writesonic.com/

License: MIT License

Shell 0.04% JavaScript 1.14% Python 8.27% TypeScript 90.20% Batchfile 0.27% Dockerfile 0.07%

gptrouter's Introduction

๐Ÿš€ GPTRouter

Your AI Model Gateway - Smoothly Manage Multiple LLMs and Image Models, Speed Up Responses, and Ensure Non-Stop Reliability.

Twitter Follow

๐ŸŒ Why GPTRouter?

At Writesonic, after three years of navigating the world of large language models, we identified key challenges and built GPTRouter to solve them.

Solving Real-World Challenges:

  1. Model Independence: Don't put all your eggs in one basket. GPTRouter lets you break free from the limitations of relying on just one AI model like OpenAI. If one model is down, GPTRouter keeps you up and running by seamlessly switching to another.

  2. Beat the Latency: Slow response times? Not anymore. GPTRouter is designed to tackle latency issues, especially with hefty models like GPT-4. Experience a smoother, faster user interaction without delays.

  3. Diverse Model Integration: Why settle for one when you can have more? GPTRouter supports multiple language and image generation models, providing fallback options so your system remains robust and versatile.

Key Features:

  • ๐ŸŒ Universal API: One API to connect them all. Easily switch between models like OpenAI, Azure OpenAI, Anthropic, Replicate, Stable Diffusion, Cohere, and more.
  • ๐Ÿ”€ Smart Fallbacks: Keep your services uninterrupted. GPTRouter automatically switches to alternative models if your primary choice is unavailable.
  • ๐Ÿ”„ Automatic Retries: GPTRouter intelligently retries failed requests, reducing manual effort and improving reliability.
  • โฑ๏ธ Fast and Responsive: Designed to reduce latency, GPTRouter ensures your interactions with AI models are quick and efficient.

Supported Models:

Supported Models Completion Streaming Async Completion Async Streaming
OpenAI โœ… โœ… โœ… โœ…
Azure OpenAI โœ… โœ… โœ… โœ…
Anthropic โœ… โœ… โœ… โœ…
Replicate โœ… โœ… โœ… โœ…
Stable Diffusion โœ… โ— โœ… โ—
Dalle-3 โœ… โ— โœ… โ—
Cohere โœ… โœ… โœ… โœ…
More to come ๐Ÿ•ค ๐Ÿ•ค ๐Ÿ•ค ๐Ÿ•ค

โ— Streaming not applicable to Image Models

๐Ÿ•ค Coming Soon

โœจ Contributors Welcome! โœจ

Quick Start

Ready to get started? Here's how:


Prerequisites

Getting The Server Running

  • To run the GPTRouter server locally, follow the steps here
  • Alternatively, use our Preview Deployment with the baseURL https://gpt-router-preview.writesonic.com/. Get your API key by filling out the form here.

Once the Server is running, you can integrate GPTRouter into your application using our Python SDK or via the API Docs. Meanwhile, we are working on JS and other clients and are looking for contributors to help out.

Using the Python SDK

Install GPTRouter using pip:

pip install gptrouter

Or with conda:

conda install gptrouter -c conda-forge

Usage Example

from gpt_router.client import GPTRouterClient
from gpt_router.models import ModelGenerationRequest, GenerationParams
from gpt_router.enums import ModelsEnum, ProvidersEnum


client = GPTRouterClient(base_url='your_base_url', api_key='your_api_key')

messages = [
    {"role": "user", "content": "Write me a short poem"},
]
prompt_params = GenerationParams(messages=messages)
claude2_request = ModelGenerationRequest(
    model_name=ModelsEnum.CLAUDE_INSTANT_12,
    provider_name=ProvidersEnum.ANTHROPIC.value,
    order=1,
    prompt_params=prompt_params,
)

response = client.generate(ordered_generation_requests=[claude2_request])
print(response.choices[0].text)

Discover More: Explore streaming and other examples here.


On the Horizon:

  • Integrations with Langchain and LlamaIndex, expanding your options even further.

๐Ÿ“– Documentation

For comprehensive documentation, visit: GPTRouter Documentation

๐Ÿ› ๏ธ Installation and Setup

Detailed installation instructions and setup guidance can be found in our Getting Started Guide.

๐Ÿค Contributing

We welcome contributions from the community! If you're interested in improving GPTRouter, see our Contribution Guidelines.

๐Ÿ”— Links

gptrouter's People

Contributors

elmeister avatar gupta-anubhav12 avatar akbws avatar unownone avatar samanyougarg avatar dhairya-writesonic avatar amritpal2001 avatar gowthamtirri avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.