AI Agent Infrastructure — Self-Hosted Multi-Model Orchestrator
Self-hosted AI agent infrastructure using Hermes Agent, 9router, n8n, and open-source models on a single VPS.
Overview
A self-hosted AI agent orchestration system running on a single VPS — combining Hermes Agent as the reasoning engine, 9router as a unified model gateway, n8n for workflow automation, and PostgreSQL/pgvector for semantic memory. This infrastructure powers daily workflows: coding assistance, content creation, Persian article research, automated news pipelines, and multi-agent translation systems.
The Problem
Cloud-dependent AI tools fragment the workflow. Each tool uses a different provider, different API key, different pricing model. Switching between OpenAI, Anthropic, and open-source models means managing multiple accounts, keys, and cost centers. For someone learning AI by building — not by theory — this friction kills momentum. The goal was a single endpoint where every agent picks the right model automatically, with no per-provider account management.
Architecture
The system uses a lightweight orchestration layer on a single VPS to route, execute, and persist AI operations:
Model Gateway Layer (9router) receives every LLM request through a single OpenAI-compatible endpoint and routes it to the optimal model — Anthropic for reasoning-heavy coding, DeepSeek for cost-efficient general tasks, GPT for structured output. Selection happens automatically based on the agent’s declared needs and context budget constraints.
Agent Runtime (Hermes Agent) hosts a growing set of skill-based agents that load their own context, knowledge base, and tool sets — content writing, Persian translation, code review, GitHub automation, and research synthesis. Each skill is a self-contained workflow with its own reference files and guardrails.
Workflow Engine (n8n) + Vector Store (pgvector) schedules and orchestrates long-running pipelines — RSS monitoring → summarization → translation → human approval → WordPress publishing. pgvector stores embeddings for semantic retrieval, powering both the CV chatbot and news research agent.
Ingestion & Monitoring (FreshRSS + Caddy) FreshRSS aggregates RSS feeds for the news pipeline while Caddy manages TLS, reverse proxying, and automatic certificate renewal across all services.
Results
- Single model gateway replaces 4+ provider dashboards
- Sub-200ms model switching with no cold starts per request
- Zero cloud vendor lock-in — models can be swapped or added via 9router config
- All agents share a common memory and tool infrastructure
Technical Challenges
The architecture decision — one VPS vs. distributed — was the first trade-off. Self-hosting a model gateway alongside n8n, pgvector, FreshRSS, and Caddy on a single machine required lightweight image choices and careful port management. The second challenge was semantic memory: ensuring pgvector embeddings stay fresh while the knowledge base grows requires scheduled re-indexing triggered via n8n cron jobs.
Stack
Hermes Agent, 9router, n8n, PostgreSQL/pgvector, FreshRSS, Caddy, Docker.