DEV Community

Wasim Safdar
Wasim Safdar

Posted on

How I built AI Services on Apify Using LLMs

Introduction

In this article, I will explore and share my personal experiences on how developers can leverage different AI models and their ecosystems to build multi-agent Actors using Apify infrastructure.

I will share the challenges I faced while developing actors for the $1M Apify challenge, how Apify helped me solve them, and the lessons I learned during development.

Apify connecting different AI technologies

Key Topics:

1. Background
2. Why I joined Apify
3. Getting an idea for the $1M Apify challenge
4. AI Video Ads Generator
5. AI Video to Voiceover Generator
6. AI Ad Music Factory
7. AI YouTube Thumbnails Generator
8. Apify's Payment Model
9. Cost Calculation
10. Storage Option and Structured Output
11. Key Lessons Learned
12. Conclusion

1. Background

I am a freelance developer and an entrepreneur. I enjoy working on hobby projects to understand new technologies. Before participating in the Apify $1M Challenge, I was developing a web-based hobby project focused on AI-powered image editing.

Challenges I faced during project development

  • What technologies should I use?
  • Which programming languages would be the best?
  • Which AI models are good for image editing?
  • What should the business model be?
  • What type of database is required?
  • Which payment gateway should I choose?

Above, I mentioned a few main challenges, but there were a lot of other challenges too. Once I figured out all the challenges, I began developing a web app using HTML and JavaScript. During my research, I discovered that the MediaPipe framework provides powerful capabilities for image classification and segmentation.

After understanding the MediaPipe framework, I started experimenting with it by coding a small prototype web app that could detect features in the image, such as the face, hair, clothes, and the background.

After that, I passed the relevant information to an AI model. Initially, I tested with the OpenAI model. After a few tries, I started getting positive results. However, the model was relatively slow, and it was changing facial identity and other parts of the image.

As the project evolved, I shifted focus towards building a complete project. I implemented a subscription system, set up a project on Google Cloud, and used Firestore for authentication and storing data.

To cut a long story short, after spending several months on development, when I was finally ready to launch my website, I encountered a new set of challenges.

  • The OpenAI model was slow for image generation at that time.
  • I faced an issue with payment integration.
  • I needed to purchase a separate domain name.
  • Firestore updated its API for Google and Facebook authentication, which suddenly caused errors in my application.

To solve these challenges, I switched to Gemini for better performance. I contacted my local bank about the payment integration issues and purchased the domain.

When all things were done, and I was ready to launch my web app, Nano Banana by Gemini was released. I cannot compete with big tech companies using their own technology; therefore, I had to make a tough decision and shut down the project.

2. Why I joined Apify

Around this time, one of my former colleagues, who is based in Denmark and works as a marketing specialist, introduced me to Apify.
He mentioned that it's a powerful platform for web crawling and asked for help to extract data from the Nordic Startup website.

This sparked my interest, and I started exploring Apify. The Apify Academy has excellent documentation and tutorials on its website, which made my learning process smooth and practical. Check out their page.

After learning and getting comfortable with the Apify platform, I built my first Apify Actor to extract data from the Nordic startup website. I found that Apify is a highly scalable cloud infrastructure, and it provides developers with a user-friendly interface for writing custom code in Python and JavaScript.

While working on my hobby project, I faced challenges such as setting up infrastructure, handling payments, managing authentication, and scaling AI models. I quickly realized that these challenges could be easily solved with the Apify platform.

Apify turned out to be an excellent platform for building multi-agent systems(MAS). It allows seamless integration with modern agentic frameworks like LangGraph, CrewAI, TogetherAI, and Hugging Face.

Compared to other platforms that I used to deploy AI models, the Apify interface stood out because of its simplicity and efficiency. There is no need for a complex setup, and many essential components are already handled with the platform, such as payment handling, storage, database management, and user access.

Everything is built on its cloud platform. You can execute Actors for a few seconds to hours, days, depending on your needs. Apify reduces development time and allows users to easily test and use Actors directly from the Apify store.

3. Getting an idea for the Apify $1M challenge.

After exploring Apify and based on my experience with previous hobby projects, I decided to build an AI service for the Apify $1M challenge. After some brainstorming, I narrowed them down to these ideas.

  • AI Video Ads Generator
  • AI Video to Voiceover Generator
  • AI Ad Music Factory
  • AI YouTube Thumbnails Generator

4. AI Video Ads Generator

My primary idea was to give marketing agencies and companies a cost-effective way to create high-quality video Ads for their social media campaigns on social media platforms like Instagram, TikTok, YouTube, and Facebook.

Instead of spending months building a full subscription-based web application handling infrastructure, payments, databases, authentication, and deployment, I could now focus on core functionality.

With Apify's cloud platform:

  • There is no need for complex infrastructure
  • No need to manage databases or storage manually
  • No need to implement payment systems or authentication from scratch
  • No need to purchase or configure a separate domain

Everything is already available and integrated in the Apify platform. By using the Apify cloud platform, I was able to avoid an expensive and complex setup. Apify saved me from a lot of operational overhead.

The work that needs months to be completed can now be completed in a week, ready to be launched and tested on the Apify platform. Below is a screenshot of my Actor, AI Video Ads Generator

AI Video Ads Generator screenshort

On the Apify store, users can easily use different Actors without going through the complexity of subscriptions. Apify's pay-as-you-go model makes it simple and cost-effective to access and scale services as needed.

Users can enter and upload various types of data, such as text, images, and files, through the Actor's input field. Check out the Actors input specification page.

5. AI Video to Voiceover Generator

My second idea was an AI Video to Voiceover Generator.

Most AI-generated videos do not include voiceovers. For example, imagine a school teacher or a mother who wants to generate story videos for children. Does it make sense to hire a professional voiceover artist every time?

This is the problem my Actor aims to solve. It allows users to easily generate voiceovers for their videos. Currently, the Actor supports videos between 3 and 10 seconds. Below are the screenshots of my Actor on the Apify store.

AI Video to Voiceover Generator screenshot

50 different English voice notes are supported now. In the future, I will add voice tones of other languages.

Different voice tones

One of the biggest advantages of using Apify is that it also provides an API endpoint for every Actor. Using these endpoints, developers can easily integrate Actors with automation tools such as n8n, Make, and Zapier. Developers can also integrate one Actor with another Actor. For example, the AI Video to Voiceover Generator can be integrated with the AI Video Ads Generator to generate voiceovers for video Ads.

6. AI Ad Music Factory

My third idea was focused on generating a music video using AI. AI Ad Music Factory enables users to create background music for advertisements, brand videos, and social media content within seconds. Below is a screenshot of the Actor.

AI Ad Music Factory screenshot

Using AI orchestration, I developed this Actor so that the user can compose high-impact AI-Powered music for products, brands, advertisements, and social media videos or services.

With this Actor, the user can:

  • Generate multiple lyrical variations
  • Generate different music compositions for each set of lyrics
  • Define the style, mood, and direction of music using prompts

7. AI YouTube Thumbnails Generator

This Actor generates high-impact, high-performance AI-generated thumbnails from YouTube video URLs.

It reads the content of your YouTube video and also takes input from the user on what kind of thumbnail the user wants to generate. Using an AI orchestration layer, it can generate 100 thumbnails at one time. Below is a screenshot of this Actor.

AI YouTube Thumbnails Generator screenshot

AI YouTube Thumbnails Generator supports 3 reference images. You can upload your own photo to show in the thumbnail, and also upload 2 more photos to guide the subject, background, and composition. It supports premium and basic AI models that you can choose from.

8. Apify's Payment Model

One of the biggest advantages of Apify is its simple and transparent payment structure.

Most websites that provide AI services rely on monthly or yearly subscription-based models. Even though they show a low subscription rate, once you start using their service, they start charging you more, depending on the number of tokens used and other hidden factors. Then you need to buy more credits to complete your work.

All the above complexity of the payment structure is eliminated by the Apify brilliant Pay-Per-Event model, which is also a requirement for the Apify $1M challenge. With this approach, users only pay for specific events, typically tied to successful results.

There is no need to subscribe, manage credits, or worry about unused capacity. This model is not only simpler but also more cost-effective.

9. Cost Calculation

If you are a developer planning to build an AI service on Apify, it is important to consider the overall cost structure carefully. Check out the Apify documentation for pricing here.

Here are the key factors to keep in mind.

  • AI API cost based on different models
  • Apify platform charges
  • Testing and debugging cost
  • Competitor pricing

AI services are provided by multiple vendors such as Together AI, WaveSpeedAI, Google Cloud, Hugging Face, and ElevenLabs. AI models provided by different vendors have different pricing structures. These typically depend on factors such as token usage, model complexity, prompt length, and operational costs.

Using the Apify "Pay-Per-Event" model, you can define pricing based on specific actions within your Actor.

10. Storage Option and Structured Output

Apify cloud infrastructure provides better storage capabilities and allows you to present output data in a structured and user-friendly format.

There is no need to set up and manage a separate database. Everything can be handled directly within the platform.

As a developer, you can:

  • Create temporary directories to store intermediate files during execution.
  • Use the Apify Key-Value store to save generated assets such as images and videos
  • Retrieve and store data using unique IDs
  • Display outputs in a structured format for end users
  • Allow users to easily download generated files

Below is a screenshot of one of my Apify Actor outputs.

Actor's structured output

11. Key Lessons Learned

Instead of overthinking or waiting for the perfect idea, starting with a hobby project helped me to understand real-world challenges in AI development.

Building a full SaaS product from scratch, such as handling payments, databases, authentication, and deployment, can take several months. Choosing Apify significantly reduced this overhead, and you can start generating revenue quickly, and can test your idea with real users.

12. Conclusion

Apify is an excellent platform for developers who want to build fast and launch quickly.

If you are a developer looking to create an AI application, instead of diving into the complexities of full-stack web development, consider using Apify. It allows you to focus on building core functionality without worrying about infrastructure, payments, or deployments.

Every challenge in this journey pushed me towards a better solution. I highly recommend exploring Apify's documentation and following their tutorials to get started. Once you begin building, you will quickly realize how powerful and enjoyable the platform is to work with.

Top comments (0)