{"slug": "building-ai-rap-generation-tool-with-gemini-api-langchain-cloud-run", "title": "Building AI Rap Generation Tool with Gemini API / LangChain / Cloud Run", "summary": "A developer built Rap Dojo, a web service that generates rap lyrics using Google's Gemini API, LangChain, and Cloud Run. The project, created for a Gemini hackathon, features a simple frontend with no JavaScript framework and a serverless backend to keep costs low. The developer reports infrastructure costs below a few hundred yen per month.", "body_md": "I recently developed **Rap Dojo**, a web service that uses AI to generate rap lyrics. In this article, I’ll share how the project came about, how I built it, and what I learned from launching and running it.\n\nMy original motivation was simple: I wanted to build a working product using an LLM API.\n\nAround that time, Google and Zenn were hosting a Gemini-related hackathon, and I thought, “If I’m going to build something, why not make something interesting with Gemini?”\n\nThat idea led me to start developing Rap Dojo.\n\nThe concept was an AI rap generator that would make it easy for anyone to create a rap.\n\nOf course, you can already ask a conversational AI such as ChatGPT or Gemini to “write me a rap,” and it will generate one for you.\n\nBut when you actually use a chat interface, that freedom can sometimes be overwhelming. People may wonder:\n\nWith Rap Dojo, I wanted to create an experience simple enough that users could generate a rap by entering just a few words, without having to think about complicated prompts.\n\nFor example, you might enter your name, something you like, or something that happened recently, and the AI will turn those ideas into a rap.\n\nI thought that if the experience were simple enough, even people who rarely use generative AI might feel comfortable playing around with it. It could make AI-generated content feel a little more accessible and integrated into everyday life.\n\nThat became the starting point for Rap Dojo.\n\nI intentionally kept Rap Dojo’s architecture as simple as possible.\n\nAt a high level, it consists of:\n\nThe frontend calls the backend API through JavaScript. The backend then uses Gemini to generate a rap based on the user’s input and returns the result to the frontend.\n\nFor the frontend, I decided not to use a framework such as React or a CMS. It is built primarily with HTML and CSS, with some JavaScript.\n\nOne reason I chose this approach is the rapid progress of AI coding tools.\n\nToday, tools such as Claude Code and Antigravity make it possible to build and modify websites efficiently using natural-language instructions.\n\nFor a relatively small web service like this, I therefore felt that introducing a CMS or a large JavaScript framework was unnecessary.\n\nI’m also comfortable working directly with HTML and CSS, so editing the code myself does not create much overhead.\n\nKeeping the architecture simple provides several benefits:\n\nFor small websites and indie projects, I’ve come to believe that avoiding unnecessary technical complexity can be just as important as choosing the right technology.\n\nI use Google Cloud Run for the backend.\n\nRap Dojo does not receive a large volume of traffic continuously, so I did not want to run a server 24/7.\n\nInstead, I chose Cloud Run because its serverless model allows the backend to run only when needed.\n\nConceptually, the flow looks like this:\n\n```\nUser input\n↓\nFrontend (JavaScript)\n↓\nCloud Run API\n↓\nPython / LangChain\n↓\nGemini API\n↓\nRap generation\n↓\nResult returned to frontend\n```\n\nOnce the user input is received, the backend performs the generation process and returns the output to the frontend through the API.\n\nOne of the biggest benefits of this architecture is its low operating cost.\n\nGemini API usage naturally incurs costs depending on usage, but at Rap Dojo’s current traffic level, the Google Cloud infrastructure costs are extremely low.\n\nThe exact amount varies by month, but infrastructure costs generally stay below a few hundred yen per month.\n\nIn the past, launching a web service with a backend meant thinking about servers, hosting, maintenance, and other infrastructure concerns.\n\nToday, by combining a serverless environment such as Cloud Run with a generative AI API, even an individual developer can launch a web application that accepts user input and processes it dynamically at very low cost.\n\nBuilding Rap Dojo reminded me just how much the barrier to launching this kind of product has fallen.\n\nI use Gemini as the LLM behind Rap Dojo.\n\nThe biggest reason is its strong balance between cost and quality.\n\nIn particular, Gemini’s Flash models offer relatively low API costs while still providing more than enough quality for text-generation use cases like this one.\n\nEvery time a user generates a rap, the application makes an LLM API call. As usage grows, those costs accumulate.\n\nThat means indie developers need to think not only about model performance, but also about the cost of each generation.\n\nFrom that perspective, I’ve found the Gemini Flash family very practical for personal projects.\n\nAnother reason I often use Gemini is that Google Cloud credits are relatively accessible through developer programs and events.\n\nGoogle regularly organizes developer events and hackathons, and participation sometimes comes with Google Cloud credits.\n\nAlthough these credits typically expire, some events provide credits worth around ¥10,000–¥20,000, which can be very useful for indie development.\n\nMaking good use of those credits is another reason the Gemini API has become my main choice for personal projects involving LLMs.\n\nRap Dojo currently uses different models depending on the task:\n\nRather than using the most powerful model for every task, I use lighter models where appropriate. This helps keep costs down while maintaining the generation quality I need.\n\nFor indie development, I’ve learned that model selection should not simply be about choosing the “best-performing” model. It is equally important to consider how cheaply you can operate while still meeting the required quality level.\n\nIn Rap Dojo, the rap-generation process is implemented as a two-stage pipeline.\n\nAt a high level, it works like this:\n\n```\nUser input\n↓\n1. Generate the rap\n↓\n2. Format the output\n↓\nDisplay to user\n```\n\nThe main reason I use LangChain is that I wanted a convenient way to connect multiple LLM operations sequentially.\n\nThe first step is to generate the rap itself.\n\nAt this stage, rather than controlling the output format too strictly, I give the LLM more freedom and prioritize creativity and entertainment value.\n\nWith rap lyrics, overly strict formatting requirements can make the output more consistent, but they can also make the writing feel repetitive or less expressive.\n\nSo in the first stage, I prioritize the quality of the content itself.\n\nThe generated rap is then passed to a second process that adjusts it into a format that works well on the website.\n\nFor example, this stage can:\n\nThis step does not require particularly advanced creative ability, so I can use a lighter and cheaper model such as Gemini 3.5 Flash-Lite.\n\nIn other words:\n\nEach model has a different role.\n\nInitially, I considered handling everything within a single prompt:\n\n“Write a rap and output it in this exact format.”\n\nBut after experimenting with the application, I found that separating content generation from output formatting made the system easier to manage.\n\nInstead of asking a single model to do everything, I split the process into:\n\n```\nGenerate\n↓\nReview / format\n```\n\nThis also allows me to choose a model that is appropriate for each task.\n\nEven though Rap Dojo has a relatively simple architecture, I still needed a convenient way to manage multiple LLM operations as a pipeline. That is the main reason I decided to use LangChain.\n\nI use Google Cloud Run to deploy the backend.\n\nThere are several ways to deploy a Python-based web application, so during the early stages of development I considered a number of options, including:\n\nFor this particular use case, however, I found Cloud Run to be the easiest option while also keeping costs low.\n\nWith Rap Dojo, I did not want to publish only an AI demo. I wanted to integrate the rap-generation feature into a proper website running on the custom domain `rapdojo.com`\n\n.\n\nServices such as Streamlit Cloud and Hugging Face are extremely useful for publishing AI application prototypes.\n\nFor the architecture I had in mind, however, it was easier to have an existing custom-domain website call a Python backend through an API.\n\nWith Cloud Run, the architecture can be cleanly separated like this:\n\n```\nrapdojo.com\nHTML / CSS / JavaScript\n        ↓\n   Cloud Run API\n        ↓\n      Python\n        ↓\n   Gemini API\n```\n\nThe website itself remains a conventional HTML website, while Cloud Run handles only the parts that require AI processing.\n\nAnother reason Cloud Run works particularly well for Rap Dojo is that a small indie service like this does not need a backend running continuously.\n\nPython only needs to execute when someone generates a rap.\n\nFor that reason, a serverless service such as Cloud Run was a better fit than maintaining an always-on server.\n\nAt relatively low traffic levels, infrastructure costs can remain very low as well.\n\nI think Cloud Run is a practical option when you want to add Python or generative AI functionality to specific parts of an otherwise conventional website.\n\nI used to associate AI apps with specialized application environments, but in practice, combining a standard HTML-based website with Cloud Run was enough to launch a fully functional service.\n\nOne thing I noticed after operating Rap Dojo in production is the instability that comes with relying on an external LLM API.\n\nWith a conventional website, as long as your own servers and code are functioning correctly, you can generally continue providing the service.\n\nA generative AI application introduces another dependency:\n\n```\nRap Dojo\n↓\nLLM API\n↓\nExternal AI service\n```\n\nAs a result, even when there is nothing wrong with your own code, the application may temporarily become unavailable because of issues on the LLM provider’s side.\n\nDuring the early development of Rap Dojo, I used a GPT API.\n\nAt one point, an API specification change caused a process that had previously been working to suddenly stop.\n\nI had not changed my own code, but a change to the external API still affected the service.\n\nThat experience made me much more aware of this risk.\n\nI had similar experiences after switching to Gemini.\n\nWith one of the Gemini Flash models I was using at the time, high load on the model side occasionally resulted in API errors, temporarily preventing users from generating rap lyrics.\n\nThe service is more stable now, but once you operate a real product, you quickly realize that you cannot assume an LLM API will succeed 100% of the time.\n\nThe main lesson from this experience is that when building a generative AI service, implementing only the success path is not enough.\n\nYou also need to consider scenarios such as:\n\nFor a production service, it is important to think about what happens when the LLM fails, including error messages, retries, and potentially falling back to another model.\n\nIn traditional web development, I mainly thought about my own code and infrastructure.\n\nAI web applications add another dependency: the external LLM service.\n\nOperating Rap Dojo taught me that designing around this dependency is an important part of building AI products.\n\nAfter launching Rap Dojo, I learned several things beyond the technical side of development.\n\nOne of the most interesting lessons was that even a small web service on a brand-new domain can attract meaningful traffic if it combines a niche user need with effective SEO.\n\nFor Rap Dojo, I registered the domain `rapdojo.com`\n\nand built the site with SEO in mind from the beginning.\n\nSEO is also part of my professional background, so I researched search demand and optimized the site and its content accordingly.\n\nAs a result, the site began ranking for relevant Japanese keywords such as **“ラップ AI”** (“rap AI”) and **“ラップ 作って”** (“make me a rap”).\n\nToday, around 3,000 people visit the site each month.\n\nOf course, this is not a large-scale service. But considering that I am not running any advertising and started from a completely new domain, I think it is an encouraging result for an indie web application.\n\nThis experience made me think that the following combination can work particularly well for indie projects:\n\n```\nNiche search demand\n+\nA genuinely useful tool\n+\nSEO\n```\n\nThere was, however, another important lesson.\n\nGetting users to visit a product and turning that product into a viable source of revenue are two completely different challenges.\n\nRap Dojo is mainly something people use casually for fun, and I do not think it is the kind of service most users would pay for.\n\nFor that reason, it remains essentially free to use.\n\nHowever, even a free service has operating costs.\n\nGemini API, Google Cloud, and other services all cost a small amount of money each month.\n\nThat creates a simple situation:\n\n“There is no revenue, but the product still costs a little money every month.”\n\nAt the same time, the site has gained search rankings and people are actively using it, so shutting it down feels like a waste.\n\nAs a result, Rap Dojo has become a product that I continue to maintain while paying a small amount each month to keep it running.\n\nFor one project like Rap Dojo, this is not a major issue.\n\nBut if I were to create five or ten similar personal projects, each one would come with API fees, cloud costs, domain fees, and ongoing maintenance work.\n\nThat has made me realize that for my next web product, I should think not only about building and launching it, but also about how I plan to maintain it afterward.\n\nFor example:\n\nDefining criteria like these in advance may be useful.\n\nWith indie development, building and launching something is fun in itself, so it is easy to keep creating new products without thinking too much about what happens afterward.\n\nHowever, if you want to manage several products over the long term, deciding what to keep and what to shut down may be just as important as deciding what to build.\n\nThat said, I currently have no plans to shut down Rap Dojo.\n\nI do not plan to make major feature additions or actively develop it on an ongoing basis, but I still use it from time to time to create rap lyrics for fun.\n\nRather than trying to turn Rap Dojo into a large business, I plan to maintain it as a small AI product that I built and still use myself.\n\nFrom a monetization perspective, it has not been a successful product.\n\nBut in terms of what I learned, the project has been extremely valuable:\n\nOverall, it has been a very rewarding project.\n\nI’d like to finish with a short introduction about myself.\n\nAs a hobby, I build AI-powered products and indie projects like Rap Dojo.\n\nProfessionally, I primarily work in SEO, and more recently I have also been conducting research and analysis related to GEO and AI Search.\n\nMy main areas of interest include:\n\nWhen it comes to indie development, I enjoy more than simply writing code.\n\nI like coming up with an idea, turning it into a real product, launching it, attracting users through SEO, and then operating and improving it over time.\n\nIf you read this article and thought:\n\nI’d be very happy to connect.\n\nYou can find more information about the projects and research I’m working on here:\n\n**Heysho**\n\n[https://heysho.com/](https://heysho.com/)", "url": "https://wpnews.pro/news/building-ai-rap-generation-tool-with-gemini-api-langchain-cloud-run", "canonical_source": "https://dev.to/heysho/building-and-launching-an-ai-rap-generation-service-with-gemini-api-langchain-cloud-run-1pc", "published_at": "2026-08-27 08:34:43+00:00", "updated_at": "2026-08-27 08:48:39.618602+00:00", "lang": "en", "topics": ["generative-ai", "ai-products", "ai-tools", "developer-tools"], "entities": ["Rap Dojo", "Gemini", "LangChain", "Cloud Run", "Google", "Zenn"], "alternates": {"html": "https://wpnews.pro/news/building-ai-rap-generation-tool-with-gemini-api-langchain-cloud-run", "markdown": "https://wpnews.pro/news/building-ai-rap-generation-tool-with-gemini-api-langchain-cloud-run.md", "text": "https://wpnews.pro/news/building-ai-rap-generation-tool-with-gemini-api-langchain-cloud-run.txt", "jsonld": "https://wpnews.pro/news/building-ai-rap-generation-tool-with-gemini-api-langchain-cloud-run.jsonld"}}