Overview
Historia Diaria uses OpenRouter API to generate daily stories with AI. This guide walks you through setting up your API key and configuring the model.OpenRouter provides access to multiple AI models with a single API key. You only need one account to use any available model.
Step 1: Create OpenRouter Account
Visit OpenRouter
Go to openrouter.ai and create a free account
Add Credits
Navigate to your account settings and add credits to your account. Most models cost only a few cents per story generation.
Step 2: Configure GitHub Secrets
Your API key must be stored as a GitHub secret to keep it secure.Navigate to Repository Settings
Go to your GitHub repository → Settings → Secrets and variables → Actions
Step 3: How the API Key is Used
The workflow passes the secret to your Python script as an environment variable:.github/workflows/actualizar.yml
generar_historia.py
Model Selection
Historia Diaria uses the OpenRouter API to generate stories. You can choose from various models based on cost and quality.Current Model
The default configuration uses:generar_historia.py
Available Models
Free Models
stepfun/step-3.5-flash:free(Current)google/gemini-flash-1.5(Free tier)- Limited rate limits
Premium Models
openai/gpt-4-turboanthropic/claude-3-opusgoogle/gemini-pro-1.5- Better quality, higher cost
Changing the Model
To use a different model, edit line 23 ingenerar_historia.py:
generar_historia.py
Cost Considerations
Free Tier
The defaultstepfun/step-3.5-flash:free model is completely free but has:
- Rate limits
- Lower priority during peak times
- May have quality variations
Paid Models
Typical costs for a 2-3 paragraph story generation:Budget Models ($0.001 - $0.01 per story)
Budget Models ($0.001 - $0.01 per story)
google/gemini-flash-1.5: ~$0.002 per storyopenai/gpt-3.5-turbo: ~$0.005 per story- Ideal for daily automation
Premium Models ($0.05 - $0.20 per story)
Premium Models ($0.05 - $0.20 per story)
Monthly Cost Estimation
For daily story generation (30 stories/month):| Model | Cost per Story | Monthly Cost |
|---|---|---|
| Free models | $0.00 | $0.00 |
| Gemini Flash | $0.002 | $0.06 |
| GPT-3.5 Turbo | $0.005 | $0.15 |
| GPT-4 Turbo | $0.08 | $2.40 |
| Claude Opus | $0.15 | $4.50 |
Error Handling
The script includes built-in error handling if the API fails:generar_historia.py
Next Steps
Customize Prompts
Learn how to customize the AI prompt and story format
GitHub Actions Setup
Configure the automation workflow