Railway

Deploy ElizaOS — Self-Hosted AI Agent with Memory

Self-host an ElizaOS agent — character AI with pgvector memory

Deploy ElizaOS — Self-Hosted AI Agent with Memory

/var/lib/postgresql/data

Deploy and Host ElizaOS on Railway

ElizaOS is the open-source, TypeScript framework for building autonomous AI agents with personality — character-driven agents that hold conversations, remember context across sessions, use plugins, and operate across Discord, Telegram, X, and the web. This template deploys an authenticated ElizaOS agent backed by OpenAI and persistent pgvector memory, so your agent's knowledge and conversation history survive redeploys and its API isn't left open. Define an agent's character, give it long-term memory, and run it 24/7 on your own infrastructure.


What This Template Deploys

ServicePurpose
ElizaOSThe agent runtime — character, plugins, channels, and API
PostgreSQL + pgvectorPersistent long-term memory via vector embeddings

Both connect over Railway's private network. ElizaOS runs your configured agent, and the pgvector database stores conversation history and knowledge as embeddings, so the agent recalls past context and survives redeploys.


About Hosting

ElizaOS is a powerful agent framework, and three specifics make this a production-ready deploy rather than an exposed demo — all handled here.

The agent API is authenticated — not left open. A common ElizaOS mistake is exposing the agent's API publicly with no protection, letting anyone query or drive it. This template secures the agent endpoint so only authenticated requests reach it, which matters because the agent holds your keys and can act. Set a strong secret and keep the endpoint access-controlled.

Memory needs pgvector, not stock Postgres. ElizaOS stores long-term memory as vector embeddings and retrieves relevant context by similarity — which requires the pgvector extension. Standard PostgreSQL can't do vector search, so this template uses the pgvector/pgvector image, ensuring memory retrieval works. Conversation history and knowledge persist in that database, so your agent remembers across redeploys instead of resetting to a blank slate each deploy.

Character files define the agent. ElizaOS agents are driven by a character definition — name, personality, backstory, knowledge, and behavior. This is the core of what makes an Eliza agent distinct: you're not just picking a model, you're authoring a persona. Edit the character configuration to shape how your agent talks, what it knows, and how it behaves, then redeploy.

Bring your own OpenAI key. The agent uses OpenAI for responses and for the embeddings that power memory — set OPENAI_API_KEY, and you pay OpenAI directly for usage. ElizaOS also supports other providers and local models through its plugin system if you want to swap later.

Multi-platform through plugins. ElizaOS connects to Discord, Telegram, X, and the web through plugins, so one agent can operate across channels. Add the plugin and credentials for each platform you want, and the agent maintains memory across them.

Typical cost: ~$10–15/month on Railway for the agent and pgvector database, plus your OpenAI usage. ElizaOS is MIT-licensed and free.


How It Compares

ElizaOS (self-hosted)OpenAI AssistantsCharacter SaaSLangChain agent
Character-drivenYes — core designPartialYesBuild it
Persistent memorypgvector, yoursVendorVendorBuild it
Multi-platformDiscord, TG, X, webAPI onlyTheir platformBuild it
KeysYour own (BYOK)Vendor accountVendorYour own
Data ownershipFull — your infraVendorVendorFull
Self-hostableYesNoNoYes

OpenAI's Assistants API is capable but runs on their servers with their memory. Character SaaS platforms are easy but keep your agent and data. Building an agent from LangChain primitives means wiring memory, character, and channels yourself. ElizaOS's edge is a complete, character-driven agent framework with persistent pgvector memory and multi-platform plugins, self-hosted with your keys and your agent's memory on infrastructure you own.


Deploy in Under 5 Minutes

  1. Click Deploy on Railway — ElizaOS and pgvector PostgreSQL build and wire together (~3 minutes)
  2. Set OPENAI_API_KEY and a strong authentication secret for the agent API
  3. Confirm the pgvector database is connected so memory persists
  4. Edit the character configuration to define your agent's personality and knowledge
  5. Redeploy, then talk to your agent via the web or connect a platform plugin

Your agent's conversation memory persists in pgvector, so it recalls context across sessions and redeploys.


Common Use Cases

  • Character AI agents — build agents with a defined personality, backstory, and voice
  • Memory-backed chatbots — assistants that remember users and context across sessions, not stateless calls
  • Multi-platform bots — one agent operating across Discord, Telegram, X, and the web
  • Autonomous agents — agents that use plugins and tools to act, with persistent state
  • Community agents — a persistent, personality-driven bot for a Discord or Telegram community

Configuration

VariableRequiredDescription
OPENAI_API_KEYRequiredYour OpenAI key — powers responses and memory embeddings
POSTGRES_URLAuto-injectedpgvector PostgreSQL connection for persistent memory
Agent auth secretRequiredSecures the agent API so it isn't publicly open
SERVER_PORTPre-setThe port ElizaOS serves its API on
Character configEditableDefines the agent's personality, knowledge, and behavior
Platform plugin keysOptionalDiscord, Telegram, or X credentials to connect channels

Authenticated by default, and memory needs pgvector. The agent API is secured so it isn't left open — set a strong secret. Memory uses the pgvector image (not stock Postgres) so vector retrieval works and persists across redeploys.

Bring your OpenAI key and author the character. OPENAI_API_KEY powers responses and embeddings. Edit the character configuration to define your agent's persona, then redeploy.


Dependencies for ElizaOS Hosting

  • Railway account — ~$10–15/month for the agent and pgvector database, plus OpenAI usage
  • PostgreSQL with the pgvector extension (included and wired)
  • An OpenAI API key for responses and embeddings
  • Optional: Discord, Telegram, or X credentials to connect platform plugins

Deployment Dependencies

Implementation Details

The template runs ElizaOS, a TypeScript multi-agent framework, alongside a pgvector/pgvector PostgreSQL service over Railway's private network. ElizaOS agents are defined by a character configuration — personality, backstory, knowledge, and behavior — and use OpenAI for both responses and the embeddings that drive memory, requiring OPENAI_API_KEY. The agent API is configured to require authentication so the endpoint isn't publicly exposed, which matters because the agent holds provider keys and can take actions.

Long-term memory is stored as vector embeddings in PostgreSQL via the pgvector extension, which enables similarity search for relevant past context; standard Postgres without pgvector cannot perform these vector operations, so the correct image is used. Conversation history and knowledge persist in the database, so the agent recalls context across sessions and survives redeploys rather than resetting.

ElizaOS supports multi-platform operation — Discord, Telegram, X, and web — through its plugin system, with one agent maintaining memory across channels, and additional LLM providers or local models available through plugins. Memory and configuration in PostgreSQL are the components to back up.


Frequently Asked Questions

Is the agent API secured? Yes — this template requires authentication on the agent endpoint so it isn't left publicly open, which is important since the agent holds your keys and can act. Set a strong secret.

Why does it need pgvector? ElizaOS stores memory as vector embeddings and retrieves context by similarity, which requires the pgvector extension. Standard PostgreSQL can't do vector search, so this template uses the pgvector image.

Does my agent's memory persist? Yes — conversation history and knowledge live in the pgvector database, so the agent remembers across sessions and survives redeploys instead of resetting to a blank slate.

How do I change my agent's personality? Edit the character configuration — name, backstory, knowledge, and behavior — then redeploy. The character definition is the core of what makes each Eliza agent distinct.

Which platforms can it connect to? Discord, Telegram, X, and the web through plugins, with one agent maintaining memory across all of them. Add each platform's credentials to connect it.

Do I need my own OpenAI key? Yes — set OPENAI_API_KEY for responses and embeddings, and you pay OpenAI directly. Other providers and local models are available through ElizaOS plugins.


Why Deploy ElizaOS on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your infrastructure so you don't have to deal with configuration, while allowing you to vertically and horizontally scale it.

By deploying ElizaOS on Railway you get a production-ready AI agent with the hard parts solved — an authenticated API so it isn't exposed, pgvector-backed memory that persists across redeploys, OpenAI wired, and automatic HTTPS. A character-driven, memory-backed agent, self-hosted on infrastructure you own.


Template Content

More templates in this category

View Template
Chat Chat
Chat Chat, your own unified chat and search to AI platform.

okisdev
113
View Template
stella
Self-host stella with web, API, Postgres, Redis, and object storage.

Jan Kubica
1
View Template
Hermes Agent | OpenClaw Alternative with Dashboard
Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

codestorm
56