Prompt engineering and development for a fairy tale generation service

Fairy Tale AI Generation

The goal

The client from Romania approached us with the idea of ​​creating a service for generating children's fairy tales. Text, illustrations, and audio readings of the tale, all of this can be generated using artificial intelligence. The main thing is to properly coordinate the work of several neural networks, synchronize them in order to obtain a complete illustrated text. We carried out mutual integration of the models and fully developed the backend of the new platform. To make reading this case more interesting for you, we added illustrations to the page. The basis of these illustrations is visual and textual quotes from the fairy tale generated by the service.

Budget

$0k

Timeline

3 months

Year

2024

Technologies

How does the platform work

The user logs into the platform, registers, selects a tariff plan, and makes payment. After registration and payment, the user can create a fairy tale by specifying several parameters:

  • Title. The user chooses the title, which influences the final text.
  • Location. Options include a magical forest, a princess's castle, an enchanted kingdom, or a modern city.
  • Genre. Adventure, comedy, fantasy, or stories tailored for the youngest audience.
  • Characters. In this service, the main characters of the tale can be the user's child and their favorite pet, for example, a hamster.
  • Number of Chapters. Each chapter in the tale consists of approximately 5000 characters. Subscribers to the service can access up to 10 chapters in one tale. Handling a large volume of text was the main challenge, which we addressed at the prompt engineering level.

Case banner (mobile version)

Library and Sharing

The stories created by the user will be saved in the "Library" section. Here you can:

  • Read fairy tales without leaving the platform.
  • Convert the generated material into audiobook format and listen to them.
  • Download the illustrated fairy tale in PDF format.
  • Share your stories on social networks.

We understand that the results of neural networks' work may still require minor corrections. Thus, platform subscribers can always edit the text of the tale or regenerate a chapter.

Case banner (mobile version)

Development and Prompt Engineering

Text generation in our project is handled by GPT-4 Turbo, while we utilize DALL·E 3 for creating illustrations. To generate tales consisting of 10 chapters, each with 5000 characters, we make multiple requests to GPT for each chapter. This was necessary because this language model has a limitation of up to 4000 characters per message.

Before generating individual chapters, we request a basic description of the tale and its plot, main characters, and key events. Then, we request a brief description for each chapter separately.

Only after these steps do we ask GPT to create individual chapters for us. Here, we further divide the process to increase the generation speed: we sequentially request each paragraph of the chapter. The neural network creates paragraphs and chapters step by step, considering the full text that was generated earlier. Additionally, GPT takes into account the overall description of the tale and the separate descriptions of all chapters, including those not yet generated.

Case banner (mobile version)

Image Generation

To generate relevant images, we coordinate requests to GPT and DALL·E through the backend. Each chapter contains one illustration, and it should correspond to the text of the tale, maintaining coherence with the overall narrative. Requests to DALL·E also take into account all our variables: user-defined parameters, the overall description of the tale, descriptions of individual chapters, and texts and images of already generated chapters. The user has the option to regenerate any image if they are unsatisfied with the result.

Case banner (mobile version)

Text-to-Speech

Once the illustrated tale is fully prepared, it can be converted into an audiobook without leaving the platform. To implement this feature, we integrated with Google's Cloud Text-to-Speech API. We then subscribed to this service, allowing us to provide users with the option to switch between different voices. Female, male, sweet, stern, low, high, choose which narrator your children will prefer.

Case banner (mobile version)

Monetization

The monetization scheme of this web service involves a subscription model, with payments processed through Stripe. Users will have access to several subscription options: monthly, semi-annual, and annual plans. Depending on the chosen plan, users will be able to generate a different number of tales. Creating an audiobook based on the generated tale will be offered as a separate paid option.

Monetization and subscription were necessary because the AI tools used to create text, images, and audio are paid services. We discussed with the client the possibility of using more affordable tools but decided not to compromise on quality for the sake of free access.

Immediately after launch, the platform will be available in English. Later on, the client plans to add two additional languages: Spanish and Romanian.

Project team

Zakhar Doroshenko

Project Manager

Yan Bortsov

Backend developer

Maxim Ivanov

R&D Engineer

Ready to discuss your project?

Our contacts

Fill out the form to the bottom or email

Email: business@unistory.orgTelegram: unistoryapp

We'll get back to you shortly!

By clicking the button, you consent to the processing of personal data and agree to the privacy policy.

Almaty office

st. Rozybakieva 289/1, office 36,
Almaty, Kazakhstan, 050060

Integrating the future


© 2025 Unistory