ai-automation-workflows
AI Automation Workflows
Build automated AI workflows via inference.sh CLI.

Quick Start
Requires inference.sh CLI (
belt). Install instructions
belt login
# Simple automation: Generate daily image
belt app run falai/flux-dev --input '{
"prompt": "Inspirational quote background, minimalist design, date: '"$(date +%Y-%m-%d)"'"
}'
Automation Patterns
Pattern 1: Batch Processing
Process multiple items with the same workflow.
#!/bin/bash
# batch_images.sh - Generate images for multiple prompts
PROMPTS=(
"Mountain landscape at sunrise"
"Ocean waves at sunset"
"Forest path in autumn"
"Desert dunes at night"
)
for prompt in "${PROMPTS[@]}"; do
echo "Generating: $prompt"
belt app run falai/flux-dev --input "{
\"prompt\": \"$prompt, professional photography, 4K\"
}" > "output_${prompt// /_}.json"
sleep 2 # Rate limiting
done
Pattern 2: Sequential Pipeline
Chain multiple AI operations.
#!/bin/bash
# content_pipeline.sh - Full content creation pipeline
TOPIC="AI in healthcare"
# Step 1: Research
echo "Researching..."
RESEARCH=$(belt app run tavily/search-assistant --input "{
\"query\": \"$TOPIC latest developments\"
}")
# Step 2: Write article
echo "Writing article..."
ARTICLE=$(belt app run openrouter/claude-sonnet-45 --input "{
\"prompt\": \"Write a 500-word blog post about $TOPIC based on: $RESEARCH\"
}")
# Step 3: Generate image
echo "Generating image..."
IMAGE=$(belt app run falai/flux-dev --input "{
\"prompt\": \"Blog header image for article about $TOPIC, modern, professional\"
}")
# Step 4: Generate social post
echo "Creating social post..."
SOCIAL=$(belt app run openrouter/claude-haiku-45 --input "{
\"prompt\": \"Write a Twitter thread (5 tweets) summarizing: $ARTICLE\"
}")
echo "Pipeline complete!"
Pattern 3: Parallel Processing
Run multiple operations simultaneously.
#!/bin/bash
# parallel_generation.sh - Generate multiple assets in parallel
# Start all jobs in background
belt app run falai/flux-dev --input '{"prompt": "Hero image..."}' > hero.json &
PID1=$!
belt app run falai/flux-dev --input '{"prompt": "Feature image 1..."}' > feature1.json &
PID2=$!
belt app run falai/flux-dev --input '{"prompt": "Feature image 2..."}' > feature2.json &
PID3=$!
# Wait for all to complete
wait $PID1 $PID2 $PID3
echo "All images generated!"
Pattern 4: Conditional Workflow
Branch based on results.
#!/bin/bash
# conditional_workflow.sh - Process based on content analysis
INPUT_TEXT="$1"
# Analyze content
ANALYSIS=$(belt app run openrouter/claude-haiku-45 --input "{
\"prompt\": \"Classify this text as: positive, negative, or neutral. Return only the classification.\n\n$INPUT_TEXT\"
}")
# Branch based on result
case "$ANALYSIS" in
*positive*)
echo "Generating celebration image..."
belt app run falai/flux-dev --input '{"prompt": "Celebration, success, happy"}'
;;
*negative*)
echo "Generating supportive message..."
belt app run openrouter/claude-sonnet-45 --input "{
\"prompt\": \"Write a supportive, encouraging response to: $INPUT_TEXT\"
}"
;;
*)
echo "Generating neutral acknowledgment..."
;;
esac
Pattern 5: Retry with Fallback
Handle failures gracefully.
#!/bin/bash
# retry_workflow.sh - Retry failed operations
generate_with_retry() {
local prompt="$1"
local max_attempts=3
local attempt=1
while [ $attempt -le $max_attempts ]; do
echo "Attempt $attempt..."
result=$(belt app run falai/flux-dev --input "{\"prompt\": \"$prompt\"}" 2>&1)
if [ $? -eq 0 ]; then
echo "$result"
return 0
fi
echo "Failed, retrying..."
((attempt++))
sleep $((attempt * 2)) # Exponential backoff
done
# Fallback to different model
echo "Falling back to alternative model..."
belt app run google/imagen-3 --input "{\"prompt\": \"$prompt\"}"
}
generate_with_retry "A beautiful sunset over mountains"
Scheduled Automation
Cron Job Setup
# Edit crontab
crontab -e
# Daily content generation at 9 AM
0 9 * * * /path/to/daily_content.sh >> /var/log/ai-automation.log 2>&1
# Weekly report every Monday at 8 AM
0 8 * * 1 /path/to/weekly_report.sh >> /var/log/ai-automation.log 2>&1
# Every 6 hours: social media content
0 */6 * * * /path/to/social_content.sh >> /var/log/ai-automation.log 2>&1
Daily Content Script
#!/bin/bash
# daily_content.sh - Run daily at 9 AM
DATE=$(date +%Y-%m-%d)
OUTPUT_DIR="/output/$DATE"
mkdir -p "$OUTPUT_DIR"
# Generate daily quote image
belt app run falai/flux-dev --input '{
"prompt": "Motivational quote background, minimalist, morning vibes"
}' > "$OUTPUT_DIR/quote_image.json"
# Generate daily tip
belt app run openrouter/claude-haiku-45 --input '{
"prompt": "Give me one actionable productivity tip for today. Be concise."
}' > "$OUTPUT_DIR/daily_tip.json"
# Post to social (optional)
# belt app run twitter/post-tweet --input "{...}"
echo "Daily content generated: $DATE"
Monitoring and Logging
Logging Wrapper
#!/bin/bash
# logged_workflow.sh - With comprehensive logging
LOG_FILE="/var/log/ai-workflow-$(date +%Y%m%d).log"
log() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"
}
log "Starting workflow"
# Track execution time
START_TIME=$(date +%s)
# Run workflow
log "Generating image..."
RESULT=$(belt app run falai/flux-dev --input '{"prompt": "test"}' 2>&1)
STATUS=$?
if [ $STATUS -eq 0 ]; then
log "Success: Image generated"
else
log "Error: $RESULT"
fi
END_TIME=$(date +%s)
DURATION=$((END_TIME - START_TIME))
log "Completed in ${DURATION}s"
Error Alerting
#!/bin/bash
# monitored_workflow.sh - With error alerts
run_with_alert() {
local result
result=$("$@" 2>&1)
local status=$?
if [ $status -ne 0 ]; then
# Send alert (webhook, email, etc.)
curl -X POST "https://your-webhook.com/alert" \
-H "Content-Type: application/json" \
-d "{\"error\": \"$result\", \"command\": \"$*\"}"
fi
echo "$result"
return $status
}
run_with_alert belt app run falai/flux-dev --input '{"prompt": "test"}'
Python SDK Automation
#!/usr/bin/env python3
# automation.py - Python-based workflow
import subprocess
import json
from datetime import datetime
from pathlib import Path
def run_infsh(app_id: str, input_data: dict) -> dict:
"""Run inference.sh app and return result."""
result = subprocess.run(
["belt", "app", "run", app_id, "--input", json.dumps(input_data)],
capture_output=True,
text=True
)
return json.loads(result.stdout) if result.returncode == 0 else None
def daily_content_pipeline():
"""Generate daily content."""
date_str = datetime.now().strftime("%Y-%m-%d")
output_dir = Path(f"output/{date_str}")
output_dir.mkdir(parents=True, exist_ok=True)
# Generate image
image = run_infsh("falai/flux-dev", {
"prompt": f"Daily inspiration for {date_str}, beautiful, uplifting"
})
(output_dir / "image.json").write_text(json.dumps(image))
# Generate caption
caption = run_infsh("openrouter/claude-haiku-45", {
"prompt": "Write an inspiring caption for a daily motivation post. 2-3 sentences."
})
(output_dir / "caption.json").write_text(json.dumps(caption))
print(f"Generated content for {date_str}")
if __name__ == "__main__":
daily_content_pipeline()
Workflow Templates
Content Calendar Automation
#!/bin/bash
# content_calendar.sh - Generate week of content
TOPICS=("productivity" "wellness" "technology" "creativity" "leadership")
DAYS=("Monday" "Tuesday" "Wednesday" "Thursday" "Friday")
for i in "${!DAYS[@]}"; do
DAY=${DAYS[$i]}
TOPIC=${TOPICS[$i]}
echo "Generating $DAY content about $TOPIC..."
# Image
belt app run falai/flux-dev --input "{
\"prompt\": \"$TOPIC theme, $DAY motivation, social media style\"
}" > "content/${DAY}_image.json"
# Caption
belt app run openrouter/claude-haiku-45 --input "{
\"prompt\": \"Write a $DAY motivation post about $TOPIC. Include hashtags.\"
}" > "content/${DAY}_caption.json"
done
Data Processing Pipeline
#!/bin/bash
# data_processing.sh - Process and analyze data files
INPUT_DIR="./data/raw"
OUTPUT_DIR="./data/processed"
for file in "$INPUT_DIR"/*.txt; do
filename=$(basename "$file" .txt)
# Analyze content
belt app run openrouter/claude-haiku-45 --input "{
\"prompt\": \"Analyze this data and provide key insights in JSON format: $(cat $file)\"
}" > "$OUTPUT_DIR/${filename}_analysis.json"
done
Best Practices
- Rate limiting - Add delays between API calls
- Error handling - Always check return codes
- Logging - Track all operations
- Idempotency - Design for safe re-runs
- Monitoring - Alert on failures
- Backups - Save intermediate results
- Timeouts - Set reasonable limits
Related Skills
# Content pipelines
npx skills add inference-sh/skills@ai-content-pipeline
# RAG pipelines
npx skills add inference-sh/skills@ai-rag-pipeline
# Social media automation
npx skills add inference-sh/skills@ai-social-media-content
# Full platform skill
npx skills add inference-sh/skills@infsh-cli
Browse all apps: belt app list
More from inference-sh/skills
agent-tools
Run 250+ AI apps via inference.sh CLI - image generation, video creation, LLMs, search, 3D, Twitter automation. Models: FLUX, Veo, Gemini, Grok, Claude, Seedance, OmniHuman, Tavily, Exa, OpenRouter, and many more. Use when running AI apps, generating images/videos, calling LLMs, web search, or automating Twitter. Triggers: inference.sh, infsh, ai model, run ai, serverless ai, ai api, flux, veo, claude api, image generation, video generation, openrouter, tavily, exa search, twitter api, grok
745ai-image-generation
Generate AI images with GPT-Image-2, FLUX, Gemini, Grok, Seedream, Reve and 50+ models via inference.sh CLI. Models: GPT-Image-2, FLUX Dev LoRA, FLUX.2 Klein LoRA, Gemini 3 Pro Image, Grok Imagine, Seedream 4.5, Reve, ImagineArt. Capabilities: text-to-image, image-to-image, inpainting, LoRA, image editing, upscaling, text rendering. Use for: AI art, product mockups, concept art, social media graphics, marketing visuals, illustrations. Triggers: flux, image generation, ai image, text to image, stable diffusion, generate image, ai art, midjourney alternative, dall-e alternative, text2img, t2i, image generator, ai picture, create image with ai, generative ai, ai illustration, grok image, gemini image, gpt image, openai image, chatgpt image
736ai-video-generation
Generate AI videos with Google Veo, Seedance 2.0, HappyHorse, Wan, Grok and 40+ models via inference.sh CLI. Models: Veo 3.1, Veo 3, Seedance 2.0, HappyHorse 1.0, Wan 2.5, Grok Imagine Video, OmniHuman, Fabric, HunyuanVideo. Capabilities: text-to-video, image-to-video, reference-to-video, video editing, lipsync, avatar animation, video upscaling, foley sound. Use for: social media videos, marketing content, explainer videos, product demos, AI avatars. Triggers: video generation, ai video, text to video, image to video, veo, animate image, video from image, ai animation, video generator, generate video, t2v, i2v, ai video maker, create video with ai, runway alternative, pika alternative, sora alternative, kling alternative, seedance, happyhorse
733twitter-automation
Automate Twitter/X with posting, engagement, and user management via inference.sh CLI. Apps: x/post-tweet, x/post-create (with media), x/post-like, x/post-retweet, x/dm-send, x/user-follow. Capabilities: post tweets, schedule content, like posts, retweet, send DMs, follow users, get profiles. Use for: social media automation, content scheduling, engagement bots, audience growth, X API. Triggers: twitter api, x api, tweet automation, post to twitter, twitter bot, social media automation, x automation, tweet scheduler, twitter integration, post tweet, twitter post, x post, send tweet
662web-search
Web search and content extraction with Tavily and Exa via inference.sh CLI. Apps: Tavily Search, Tavily Extract, Exa Search, Exa Answer, Exa Extract. Capabilities: AI-powered search, content extraction, direct answers, research. Use for: research, RAG pipelines, fact-checking, content aggregation, agents. Triggers: web search, tavily, exa, search api, content extraction, research, internet search, ai search, search assistant, web scraping, rag, perplexity alternative
626agent-browser
Browser automation for AI agents via inference.sh. Navigate web pages, interact with elements using @e refs, take screenshots, record video. Capabilities: web scraping, form filling, clicking, typing, drag-drop, file upload, JavaScript execution. Use for: web automation, data extraction, testing, agent browsing, research. Triggers: browser, web automation, scrape, navigate, click, fill form, screenshot, browse web, playwright, headless browser, web agent, surf internet, record video
625