Skip to main content

Quick start

Run the gateway directly without cloning anything:
npx @portkey-ai/gateway
The gateway starts and listens on http://localhost:8787.
Use bunx as a drop-in replacement for npx if you have Bun installed. It resolves and runs packages faster.

Build from source

Clone the repository and build when you need to customise the gateway or pin a specific version.
1

Clone the repository

git clone https://github.com/portkey-ai/gateway
cd gateway
2

Install dependencies and build

npm install
npm run build
npm run build runs rollup -c to produce optimised CommonJS bundles in the build/ directory.
3

Start the server

node build/start-server.js
The server listens on port 8787 by default.

Development mode

For local development with live reload:
npm run dev:node
npm run dev:node uses tsx to run src/start-server.ts directly without a build step.

Production configuration

Place a conf.json file in the project root before starting the server. The gateway loads it at startup:
conf.json
{
  "plugins_enabled": ["default", "portkey"],
  "credentials": {
    "portkey": {
      "apiKey": "your-portkey-api-key"
    }
  },
  "cache": false
}
For Redis-backed caching, set the REDIS_CONNECTION_STRING environment variable before starting the server:
REDIS_CONNECTION_STRING=redis://your-redis-host:6379 node build/start-server.js
See the configuration reference for all available fields and environment variables.

Available scripts

ScriptDescription
npm run dev:nodeDevelopment server with tsx (no build step)
npm run buildProduction build with Rollup
npm run start:nodeStart production server from build/
npm run test:gatewayRun gateway tests
npm run formatFormat code with Prettier

Build docs developers (and LLMs) love