Building Our AI Chat Application: Navigating OpenRouter, Replicate, and Modal

By Y.C.

6 min read

November 17, 2024

Listen to the Podcast
--:--
--:--

Introduction

In the ever-evolving landscape of AI technology, creating a cutting-edge application requires not just innovative ideas but also the right set of tools and services. This is the story of how we built our AI product—a character chat website that allows users to create and personalize their chat mates. We'll delve into our technical choices, particularly our experiences with OpenRouter, Replicate, and Modal, highlighting the pros and cons of each and explaining why we made the decisions we did.


Our Product

We set out to develop an AI-powered character chat website focused on providing personalized interactions. Users can create and customize their chat mates, engaging in conversations that feel natural and tailored to their preferences. To achieve this, we needed robust solutions for both text-based interactions and image generation.


Choosing OpenRouter for Text Chat

To power our chat functionality, we required a flexible and reliable Large Language Model (LLM) service. OpenRouter stood out as a compelling option.

Advantages of OpenRouter

  • Multiple LLM Integrations: OpenRouter supports integration with a variety of LLM services, significantly reducing the cost and complexity of connecting to different models.
  • Early Adoption of New Models: When new LLM services emerge, OpenRouter allows us to implement them quickly, keeping our application at the forefront of technological advancements.
  • Flexible Payment Options: The ability to use cryptocurrency for payments adds an extra layer of convenience and flexibility.
  • Built-in Load Balancing and Fallback: OpenRouter comes with built-in load balancing and automatic fallback features, enhancing the reliability and scalability of our application.
  • Rate Limit Management: It handles rate limits internally, simplifying our development process.

Disadvantages of OpenRouter

  • Text-Based Focus: The platform predominantly supports text-based LLM services, which may limit expansion into other modalities.
  • Risk with Niche Models: Relying on less common models carries the risk of them being discontinued or going offline.

Why We Chose OpenRouter

The advantages, especially the ease of integration and flexibility with multiple LLMs, aligned perfectly with our needs. The drawbacks were minimal for us since our service centers around text chat. OpenRouter's features enabled us to deliver a seamless and robust chat experience without significant overhead.


Image Generation: From Replicate to Modal

To enhance user engagement, we wanted to incorporate image generation. Our journey led us from using Replicate initially to eventually adopting Modal.

Starting with Replicate

Advantages

  • Ease of Integration: Replicate offers straightforward integration, making it a quick solution to implement.
  • Diverse Model Availability: A wide range of models is available, providing flexibility in capabilities.
  • Built-in Progress Handling: It includes features to handle model processing progress, improving user experience during image generation.

Disadvantages

  • Customization Challenges: Processing custom models presents a significant learning curve and complexity.
  • Higher Operational Costs: Overall costs are relatively high, impacting our budget considerations.
  • Poor Cold Start Performance: Replicate suffers from inefficient cold starts, with initial requests taking several minutes.

Switching to Modal

Advantages

  • Complete Customization: Modal allows for full customization by implementing pipelines, enabling us to work with any type of large model—including text, image, audio, and video.
  • Optimization Capabilities: It provides libraries to optimize different stages of model processing, significantly improving cold start efficiency and reducing usage costs.
  • Generous Free Credits: Modal currently offers $30 in free credits per month, which is beneficial during development and testing phases.

Disadvantages

  • Higher Learning Curve: Implementing Modal requires using its libraries to create pipelines, which can be complex and time-consuming to learn.

Why We Chose Modal

Our project demanded a highly customized model to meet specific needs. Modal's capabilities allowed us to drastically optimize cold start times—from several minutes with Replicate down to approximately one minute. This enhancement in performance and efficiency justified the initial investment in learning and implementing Modal's platform.


Conclusion

Building an AI application involves navigating a myriad of technologies and making critical decisions that align with your project's goals. Our choices were driven by the need for flexibility, performance, and extensive customization. OpenRouter and Modal provided the tools necessary to achieve our vision, each offering unique advantages that catered to different facets of our application.

By sharing our experiences, we hope to shed light on these platforms and assist others in making informed decisions for their AI projects.