
Deploy Portkey
A powerful AI gateway for routing, guardrails, fallbacks, and 200+ LLMs.
Redis
Just deployed
/data
Portkeyai
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
- Wait until both Portkey AI Gateway and Redis are running.
- Generate a public domain for the Portkey service on port
8787. - Keep the Redis service private.
- Verify the gateway health endpoint.
- Open the Portkey interface under
/public/. - Configure your preferred LLM provider credentials or gateway configuration.
- Point your AI application to the Portkey
/v1endpoint. - Verify that requests are being routed successfully through the gateway.
- 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
| Feature | Portkey | LiteLLM | OpenRouter-style Gateway | Direct Provider APIs |
|---|---|---|---|---|
| Unified LLM gateway | ✅ | ✅ | ✅ | ❌ |
| OpenAI-compatible API | ✅ | ✅ | ✅ | ⚠️ |
| Multi-provider routing | ✅ | ✅ | ✅ | ❌ |
| Fallbacks | ✅ | ✅ | ✅ | ❌ |
| Guardrails | ✅ | ✅ | ⚠️ | ❌ |
| Shared Redis cache | ✅ | ✅ | Depends | ❌ |
| Self-hosted | ✅ | ✅ | Depends | ❌ |
| Provider abstraction | ✅ | ✅ | ✅ |