Skip to main content

Deployment Options

The AI Gateway can be deployed in multiple ways to suit your infrastructure needs:

NPM/Bun

Quick local development

Docker

Containerized deployment

Node.js Server

Self-hosted production server

Cloudflare Workers

Edge deployment

Kubernetes

Scalable orchestration

Cloud Providers

AWS, Azure, GCP
For a fully managed solution without infrastructure concerns, consider Portkey’s hosted gateway which processes billions of tokens daily in production.

Quick Start (npx)

The fastest way to get started:
1

Run with npx

No installation required - just run:
Or with Bun:
2

Verify it's running

The gateway starts on port 8787:
  • API: http://localhost:8787/v1
  • Console: http://localhost:8787/public/
Test it:
You should see: AI Gateway says hey!
3

Make your first request

Now follow the quickstart guide to make your first API call.
This method is perfect for local development and testing. For production, use Docker or a Node.js server.

Docker

Deploy using Docker for containerized production environments.
1

Run with Docker

Pull and run the latest image from Docker Hub:
The gateway is now running at http://localhost:8787
2

Run with environment variables

Pass configuration via environment variables:
3

Build from source (optional)

Clone the repository and build your own image:

Docker Compose

For multi-container setups with Redis caching:
1

Download docker-compose.yaml

2

Start the services

This starts:
  • AI Gateway on port 8787
  • Redis for caching (if configured)
3

View logs

4

Stop the services

The Docker image is built from the Dockerfile which uses a multi-stage build for optimal size.

Node.js Server

Run the gateway as a standalone Node.js application.
1

Clone the repository

2

Install dependencies

Or with Bun:
3

Build the project

This compiles the TypeScript code and prepares the production bundle.
4

Start the server

Or use npm script:
5

Configure (optional)

Create a conf.json file to customize settings. See conf_sample.json for available options.You can also use environment variables:
For development, use npm run dev:node which includes hot-reload.

Running as a Service

Create a systemd service file for production:
/etc/systemd/system/portkey-gateway.service
Enable and start:

Cloudflare Workers

Deploy to Cloudflare’s edge network for low-latency global distribution.
1

Clone and setup

2

Configure Wrangler

Make sure you have the Wrangler CLI installed and authenticated:
3

Deploy to Cloudflare

This builds and deploys the gateway to Cloudflare Workers.
4

Get your worker URL

Wrangler will output your worker URL:
Cloudflare Workers have request limits on the free tier. Consider upgrading for production use.

Kubernetes

Deploy to Kubernetes for production-grade orchestration.
1

Create deployment manifest

Create deployment.yaml:
2

Apply to cluster

3

Verify deployment

4

Access the gateway

Get the external IP:
For production, consider adding:
  • Horizontal Pod Autoscaling (HPA)
  • Resource limits and requests
  • Ingress controller for HTTPS
  • ConfigMaps for configuration
  • Secrets for API keys

AWS EC2

Quick deployment to AWS EC2 using CloudFormation.
1

Use CloudFormation template

The repository includes a CloudFormation template for one-click deployment:Deploy to AWS EC2
2

Configure parameters

Set:
  • VPC ID
  • Subnet ID
  • Instance Type (t2.micro for testing, t3.small for production)
3

Launch stack

CloudFormation will:
  • Launch an EC2 instance
  • Install Docker
  • Run the gateway container
  • Configure security groups (port 8787)
4

Access your gateway

Get the public DNS from CloudFormation outputs:

Other Platforms

Replit

Deploy with one click: Deploy on Replit

Zeabur

Use the template: Deploy on Zeabur

Azure, GCP, OpenShift

For enterprise deployments on:
  • Azure
  • Google Cloud Platform
  • Red Hat OpenShift
  • Other cloud providers
See the enterprise deployment guide or contact the team.

Configuration

Environment Variables

Common configuration options:

Configuration File

Create conf.json for advanced settings:
See conf_sample.json in the repository for all available options.

Verification

After installation, verify your deployment:
1

Health check

Should return: AI Gateway says hey!
2

Test API endpoint

3

Check the console

Open http://localhost:8787/public/ to view the web console.

Next Steps

Make Your First Request

Follow the quickstart to make your first API call

Configure Routing

Learn about routing, fallbacks, and load balancing

Add Guardrails

Protect your AI apps with input/output validation

Production Deployment

Best practices for production deployments
Need help? Join our Discord community or check the GitHub repository.