Running a social media account solo is exhausting. You have to research niches, write captions, design slides, and publish twice a day, every day.
If you try to automate this using a single LLM (like GPT-4o) running on a simple cron job, you run into three massive walls:
- Halucination & Bad Output: A single model will eventually write cringey hashtags or break the layout.
- Ephemeral Environments: Running on a free hosting platform or GitHub Actions means your server is destroyed every run—saving state is incredibly difficult.
- API Cost Runaways: Querying high-end creative models for every draft will drain your bank account. To solve this, I built Veltrix — an autonomous publishing engine that orchestrates 18+ active APIs and publishes twice daily to Instagram and Threads for roughly $0.0002 per post. Here is the exact architecture, the fallback gates, and the code. --- ## 1. The 18-API Key Topology Veltrix doesn't just call one model; it manages an entire footprint of APIs to handle data gathering, generation, verification, and publishing:
- Core Generation & Audits: Gemini Pro (Primary Brain), Groq (Llama 70B), Cerebras (gpt-oss-120b), OpenRouter (Gemma 31B).
- Media & Brand Graphics: SiliconFlow (Flux/SD3), Hugging Face Inference, Unsplash Image Search, Logo.dev, Brandfetch.
-
Database & Ops: Supabase, local SQLite (
veltrix.db), Cloudinary (media hosting), Discord webhooks. - Direct Publishing & Git: Instagram Graph API, Threads API, GitHub Actions API. To protect my wallet, I set up a gated paid API model: Gemini Pro is only invoked for final generation after the draft successfully passes a series of free/low-cost verification audits. --- ## 2. The Architectural Workflow Here is how a post moves from a raw trigger to a published carousel slide:
- GitHub Actions Cron Tick triggers the script.
- Load Checkpoint JSON fetches any pending reviews.
- Gemini drafts the topic and caption.
- Adaptive Embedding Deduplication runs a similarity check.
- Text Auditor (Groq & Cerebras) runs a dual-model consensus check.
- Gemini generates the final creative slide data (only if audits pass).
- Playwright Chromium renders and screenshots the HTML slide template.
- Cloudinary hosts the images publicly.
9. Meta Graph API publishes the post to Instagram & Threads.
3. Core Code Implementations
Here are the key Python modules that handle the heavy lifting:
text_auditor.py — Adversarial Model Auditing
To prevent mistakes, I never let a model grade its own homework. This module queries Groq and Cerebras independently and requires a 2-out-of-2 consensus approval before opening the paid API gate:
import os
import json
from groq import Groq
from cerebras.client import Cerebras
# Init clients using our credentials config
groq_client = Groq(api_key=os.getenv("GROQ_API_KEY"))
cerebras_client = Cerebras(api_key=os.getenv("CEREBRAS_API_KEY"))
def audit_draft_with_llm(client, model_name: str, draft: str) -> dict:
prompt = """
Analyze this social media draft. You are an editor. Check for:
1. Grammatical errors or cringey hashtag stuffing.
2. Factuality and structural formatting.
Return ONLY a raw JSON object: {"approved": true/false, "reason": "string"}
"""
response = client.chat.completions.create(
model=model_name,
messages=[
{"role": "system", "content": prompt},
{"role": "user", "content": draft}
],
response_format={"type": "json_object"}
)
return json.loads(response.choices[0].message.content)
def verify_text_content(draft: str) -> bool:
# Heuristics pre-screen (costs $0)
if len(draft.split("#")) > 5:
print("Pre-screen failed: Emoji or hashtag density too high.")
return False
# Consensus chain run in parallel
try:
groq_result = audit_draft_with_llm(groq_client, "llama-3.3-70b-versatile", draft)
cerebras_result = audit_draft_with_llm(cerebras_client, "gpt-oss-120b", draft)
# Absolute consensus required (2 of 2)
consensus = groq_result["approved"] and cerebras_result["approved"]
if not consensus:
print(f"Audit rejected. Groq: {groq_result['reason']} | Cerebras: {cerebras_result['reason']}")
return consensus
except Exception as e:
# Fall back to OpenRouter free models if Groq/Cerebras fail
print(f"Primary auditors failed: {e}. Routing to OpenRouter fallback...")
return fallback_audit_openrouter(draft)
database.py — Making State Survive Container Destruction
Because GitHub Actions containers are completely destroyed after a job ends, I built a checkpoint serializer that stores base64-encoded media bytes locally. The next cron runner picks it up to verify and post it:
python
import json
import base64
from datetime import datetime, timedelta
CHECKPOINT_FILE = "pipeline_checkpoint.json"
def save_checkpoint(topic: str, caption: str, media_paths: list):
payload = {
"timestamp": datetime.utcnow().isoformat(),
"status": "pending_review",
"topic": topic,
"caption": caption,
"media": []
}
# Base64 encode local slide images to serialize into JSON
for path in media_paths:
with open(path, "rb") as image_file:
encoded_bytes = base64.b64encode(image_file.read()).decode('utf-8')
payload["media"].append({"path": path, "bytes": encoded_bytes})
with open(CHECKPOINT_FILE, "w") as f:
json.dump(payload, f)
print("Checkpoint saved. Ready for human review window.")
def load_checkpoint() -> dict:
try:
with open(CHECKPOINT_FILE, "r") as f:
data = json.load(f)
# Self-expire checkpoints older than 24 hours to avoid stale runs
created = datetime.fromisoformat(data["timestamp"])
if datetime.utcnow() - created > timedelta(hours=24):
print("Checkpoint expired. Aborting.")
return {}
return data
except FileNotFoundError:
return {}
- Operational Fallback Logic When running 18 separate APIs, something will break. Veltrix handles this using multi-tiered fallbacks:
Database Fallback: Remote logs write to Supabase via webhooks. If Supabase is down, the system writes to local SQLite (veltrix.db) and commits a JSON update back to the Git repo.
Visual Slide Generation: Premium slide illustrations are generated via SiliconFlow (Flux). If SiliconFlow rate-limits, it drops back to Hugging Face, and finally falls back to Gemini's internal image creator.
Brand Assets: In carousels comparing tools, logos are resolved by Logo.dev ➡️ Brandfetch API ➡️ Brandfetch CDN ➡️ Google Favicon API ➡️ local text fallback.
Key Metrics Since Launch
Inference cost / post: ~$0.0002 (Thanks to gating Gemini behind Llama)
API limits hit: 0 (Thanks to 12h handle cooldowns and circuit breakers)
Silent crashes: 0 (Thanks to health checks monitoring budget-aware failures vs quiet days)
By treating models as independent validating agents rather than single sources of truth, you can deploy fully autonomous cron-bots with zero risk of public failure on virtually zero budget.
Let me know how you guys handle quotas and secrets in your pipelines!
Check out the full interactive workspace and live charts at theayush.pages.dev.

Top comments (1)
Hey dev community! 👋 I'm Ayush, the 17-year-old creator of Veltrix. I built this alongside Vurlo (e-commerce SaaS) and Vcentre (competitor scraping) to learn how to scale production-grade automated systems on a budget.
I'd love to hear your feedback on the consensus architecture, or how you guys manage credentials/quotas in your own pipelines.
You can check out all my active projects and their codebases on my portfolio: theayush.pages.dev/
Let me know if you have any questions! 🚀