Skip to content
site logo mobile

Code Snippets Library >

YouTube Title Generator

🔑 ID:







This is the full code that generates YouTube Titles for you which we explained in Thursday Pulses.


import openai

# Your OpenAI Key
openai.api_key = "YOUR_API_KEY"

model = "gpt-3.5-turbo"

video_topic = "VIDEO_TOPIC"

# Open AI Function
def openai_generate(user_prompt, selected_model):
    completion =
        model=selected_model, messages=[{"role": "user", "content": user_prompt}]
    return completion.choices[0].message.content

# The Prompt
prompt = """
As an expert YouTuber with 10 Years Experience.
your task is to generate 10 YouTube video titles based on the INPUT VIDEO TOPIC 
and ensure high CTR for my upcoming video.

First, use your expertise to develop the first 5 titles,
ensuring they are engaging, accurately represent the video content,
and abide by YouTube's optimal practices for high CTR.

For the remaining five, pick 5 templates that best fit the video's theme from the 
given list and use them to craft the titles.

Templates List:
-How To Not (Unwanted Outcome)-(Encouraging Words)!!
-The Simple (Task) that (Defeated) EVERYONE Except (Authority Figure)
-6 TOP (Objects) to Save You From (Unwanted Event)
-(Objects) I Never (Action) (Current Year)
-(Activity) Challenge That Will Change Your Life (30 DAYS RESULTS)
-12 (Objects) that can (Achieve Goal)
-[Achieve Goal] on [Platform] (easy [Activity] for beginners!)
-[Time Frame] Killer [Activity] ([Benefit])
-How to (Achieve Goal) in (Time Frame) [by (Current Year)]


IMPORTANT: The output should be a JSON array only, don't write anything else!

# Main Script
final_prompt = prompt.format(topic=video_topic)

result = openai_generate(final_prompt, model)



Untitled design (82)

GitHub Link

✖️ Not Available

Untitled design (83)

Download File

✖️ Not Available

If you’re encountering any problems or need further assistance with this code, we’re here to help! Join our community on the forum or Discord for support, tips, and discussion.