Skip to main content

ShortGPT Hello World Example

This guide provides a basic example of how to use the shortGPT framework. ShortGPT encapsulates the entire process of content automation into content engines. In this example, we'll show you how to instantiate the FactsShortEngine, which will automate the production of the "Interesting Facts" niche of Shorts.


Before you start, make sure you have followed the installation steps and have your API keys ready.


from shortGPT.config.api_db import ApiKeyManager, ApiProvider
from shortGPT.config.asset_db import AssetDatabase, AssetType
from shortGPT.engine.facts_short_engine import FactsShortEngine
from import ElevenLabsVoiceModule
from shortGPT.config.languages import Language
from import EdgeTTSVoiceModule, EDGE_TTS_VOICENAME_MAPPING

# Set API Keys
ApiKeyManager.set_api_key(ApiProvider.OPENAI, "your_openai_key")
ApiKeyManager.set_api_key(ApiProvider.ELEVEN_LABS, "your_eleven_labs_key")

# Add Assets
AssetDatabase.add_remote_asset("minecraft background cube", AssetType.BACKGROUND_VIDEO, "")
AssetDatabase.add_remote_asset('chill music', AssetType.BACKGROUND_MUSIC, "")
AssetDatabase.add_local_asset('my_music', AssetType.AUDIO, "./my_music.wav")

# Configure the ElevenLabs Voice Module
eleven_labs_key = ApiKeyManager.get_api_key(ApiProvider.ELEVEN_LABS)
voice_module = ElevenLabsVoiceModule(api_key = eleven_labs_key, voiceName="Antoni")
## You can also use the EdgeTTS for Free voice synthesis
voice_name = EDGE_TTS_VOICENAME_MAPPING[Language.GERMAN]['male']
voice_module = EdgeTTSVoiceModule(voice_name)

# Configure Content Engine
facts_video_topic = "Interesting scientific facts from the 19th century"
content_engine = FactsShortEngine(voiceModule=voice_module,
background_video_name="minecraft background cube", # <--- use the same name you saved in the AssetDatabase
background_music_name='chill music', # <--- use the same name you saved in the AssetDatabase
num_images=5, # If you don't want images in your video, put 0 or None

# Generate Content
for step_num, step_logs in content_engine.makeContent():
print(f" {step_logs}")

# Get Video Output Path

That's it! You have now successfully generated your first content using the shortGPT framework.