Railway

Deploy Portkey

A powerful AI gateway for routing, guardrails, fallbacks, and 200+ LLMs.

Deploy Portkey

Just deployed

/data

Just deployed

Deploy and Host Portkey AI Gateway on Railway

Portkey AI Gateway is an open-source AI gateway designed to route, control, and optimize requests across multiple LLM providers through a unified API layer.

This Railway template deploys Portkey AI Gateway with Redis, giving you a lightweight, production-oriented gateway stack with shared caching over Railway private networking.

About Hosting Portkey AI Gateway

This template deploys Portkey AI Gateway as the public-facing API layer and Redis as its internal cache backend.

Portkey handles LLM request routing, retries, fallbacks, guardrails, provider abstraction, and gateway-level policies, while Redis provides a shared cache store that can be reused across gateway restarts or multiple gateway replicas.

The stack communicates internally through Railway's private network, so Redis does not need to be publicly exposed.

Included Services

  • Portkey AI Gateway — Public AI gateway and OpenAI-compatible API layer
  • Redis — Shared cache backend for gateway requests
  • Railway Private Networking — Internal communication between Portkey and Redis

Common Use Cases

  • Route requests across multiple LLM providers
  • Build a unified API endpoint for AI applications
  • Add fallback logic between different models or providers
  • Centralize AI provider configuration
  • Apply gateway-level guardrails and policies
  • Cache repeated LLM requests using Redis
  • Reduce duplicate provider calls
  • Build an OpenAI-compatible AI gateway
  • Add an abstraction layer between applications and LLM providers
  • Scale gateway instances while sharing a common Redis cache

Dependencies for Portkey AI Gateway Hosting

This template includes:

  • Portkey AI Gateway
  • Redis

PostgreSQL is not required for the standard open-source gateway deployment.

Portkey AI Gateway

Portkey runs as the public service in this template.

The gateway listens on:

8787

Its API is available under:

/v1

The deployment also exposes the Portkey web interface under:

/public/

A typical deployed endpoint will look like:

https://your-portkey-domain.up.railway.app/v1

Redis Cache

Redis runs as an internal service and is used as Portkey's shared cache backend.

Portkey connects to Redis using Railway service references and private networking.

The Redis service does not require a public domain.

This improves the deployment by keeping cache traffic inside Railway's private network while allowing the gateway itself to remain publicly accessible.

Important Environment Variables

Portkey AI Gateway

PORT

Defines the HTTP port used by the gateway.

CACHE_STORE

Configured as redis so Portkey uses Redis as its cache backend.

REDIS_URL

References the Redis connection URL exposed by the Redis service.

LOG_LEVEL

Controls gateway logging verbosity.

PORTKEY_CLIENT_AUTH

Can be used as an additional gateway authentication secret where supported by the deployed Portkey version.

Treat this value as sensitive and do not expose it in frontend applications.

Redis

Redis is configured with:

  • Private Railway hostname
  • Port 6379
  • Default Redis user
  • Automatically generated password
  • Internal Redis connection URL

The Redis URL is consumed directly by the Portkey service through a Railway service reference.

Networking

The intended architecture is:

Internet
   │
   ▼
Railway HTTPS
   │
   ▼
Portkey AI Gateway
      :8787
         │
         │ Railway Private Network
         ▼
       Redis
       :6379

Only the Portkey service needs a public domain.

Redis should remain private.

Persistent Storage

Redis persistence is optional for this template.

If Redis is used only as a cache, losing cached entries after a Redis restart does not prevent Portkey from functioning. The cache will simply be rebuilt as new requests are processed.

If long-lived Redis persistence is required, a Railway Volume can be added to the Redis service.

After Deployment

  1. Wait until both Portkey AI Gateway and Redis are running.
  2. Generate a public domain for the Portkey service on port 8787.
  3. Keep the Redis service private.
  4. Verify the gateway health endpoint.
  5. Open the Portkey interface under /public/.
  6. Configure your preferred LLM provider credentials or gateway configuration.
  7. Point your AI application to the Portkey /v1 endpoint.
  8. Verify that requests are being routed successfully through the gateway.
  9. Confirm Redis connectivity from the Portkey logs if cache functionality is enabled.

Security Notice

Do not expose Redis publicly.

Keep all provider API keys, Redis credentials, and gateway authentication secrets in Railway environment variables.

For production workloads:

  • Use restricted provider credentials where possible
  • Avoid exposing administrative secrets to frontend applications
  • Protect public gateway endpoints appropriately
  • Rotate compromised credentials immediately
  • Keep Redis accessible only through Railway private networking

Portkey vs Alternatives

FeaturePortkeyLiteLLMOpenRouter-style GatewayDirect Provider APIs
Unified LLM gateway
OpenAI-compatible API⚠️
Multi-provider routing
Fallbacks
Guardrails⚠️
Shared Redis cacheDepends
Self-hostedDepends
Provider abstraction
Centralized gateway layer

Portkey is a strong fit when you want a dedicated AI gateway layer between your applications and multiple LLM providers without coupling each application directly to individual provider APIs.

Why Deploy Portkey AI Gateway 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.

Deploying Portkey AI Gateway on Railway provides:

  • Automatic HTTPS networking
  • Private communication with Redis
  • Simple secret management
  • Easy redeployments and upgrades
  • Integrated logs
  • Shared Redis caching
  • A lightweight two-service architecture
  • No PostgreSQL dependency for the standard gateway deployment

This template provides a straightforward way to self-host Portkey AI Gateway with Redis while keeping the infrastructure simple, secure, and production-oriented.


Template Content

More templates in this category

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

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

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

codestorm
64