Environment Variables

PromptShip injects environment variables into your app at deploy time. These are available to your application process automatically.

Platform Variables

These are injected by PromptShip based on your app's configuration. You don't need to set them — they appear automatically.

Variable When Description
PORT Always The port your app must listen on. Bind to 0.0.0.0:$PORT, not localhost.
DATABASE_URL When Postgres attached PostgreSQL connection string. Format: postgresql://user:pass@host:5432/dbname
REDIS_URL When Valkey attached Redis-compatible connection string. Format: redis://:pass@host:6379
VALKEY_URL When Valkey attached Same as REDIS_URL. Use whichever your library expects.

You can see which platform variables will be injected by calling get_app. The response includes platform_env_vars per environment.

PORT

Every app must listen on the PORT environment variable. The platform routes HTTPS traffic to this port inside your container.

Python (Flask)

import os
app.run(host='0.0.0.0', port=int(os.environ.get('PORT', 8080)))

Python (gunicorn)

gunicorn --bind 0.0.0.0:$PORT app:app

Node.js

const port = process.env.PORT || 8080;
app.listen(port, '0.0.0.0');

Go

port := os.Getenv("PORT")
if port == "" {
    port = "8080"
}
http.ListenAndServe(":"+port, nil)

DATABASE_URL

Injected after attaching Postgres with attach_postgres. Available on the next deploy.

Standard PostgreSQL connection string format. Most ORMs and database libraries accept it directly:

Python (SQLAlchemy)

import os
from sqlalchemy import create_engine

engine = create_engine(os.environ['DATABASE_URL'])

Node.js (pg)

const { Pool } = require('pg');
const pool = new Pool({ connectionString: process.env.DATABASE_URL });

Go

db, err := sql.Open("postgres", os.Getenv("DATABASE_URL"))

REDIS_URL / VALKEY_URL

Injected after attaching Valkey with attach_valkey. Both contain the same connection string. Available on the next deploy.

Python (redis-py)

import os
import redis

r = redis.from_url(os.environ['REDIS_URL'])

Node.js (ioredis)

const Redis = require('ioredis');
const client = new Redis(process.env.REDIS_URL);

User Secrets

Add your own environment variables with set_secret. Secrets are encrypted at rest and injected at deploy time.

set_secret(
  app_name: "my-api",
  environment: "dev",
  key: "STRIPE_API_KEY",
  value: "sk_test_..."
)

Secrets are per-environment. Set them separately for dev and prod. Redeploy after setting secrets for them to take effect.

Reserved names

The following variable names are reserved and cannot be used as secret keys: