{
  "manifest_version": "1.0.0",
  "template": {
    "id": "1ef97810-90d4-4e1f-be29-3b07d0a8f602",
    "slug": "litellm-v1-ai-gateway-with-spend-trackin",
    "name": "LiteLLM v1 AI Gateway with Spend Tracking",
    "description": "One OpenAI-compatible API for 100+ LLMs with keys, budgets and rate limits.",
    "url": "https://railway.com/deploy/litellm-v1-ai-gateway-with-spend-trackin",
    "upstream": {
      "repo_url": "https://github.com/baranberkay96/litellm-railway"
    }
  },
  "services": [
    {
      "name": "Redis",
      "source": {
        "image": "redis:8.2"
      },
      "needs_volume": true,
      "volume_mount_path": "/data",
      "http": false
    },
    {
      "name": "LiteLLM",
      "source": {
        "repo": "https://github.com/baranberkay96/litellm-railway"
      },
      "needs_volume": false,
      "http": true
    },
    {
      "name": "Postgres",
      "source": {
        "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
      },
      "needs_volume": true,
      "volume_mount_path": "/var/lib/postgresql/data",
      "http": false
    }
  ],
  "required_inputs": [
    {
      "key": "REDISHOST",
      "service": "Redis",
      "description": "Private network hostname of the Redis service, only resolvable from services in the same environment",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "REDISPORT",
      "service": "Redis",
      "description": "Port that Redis listens on",
      "secret": false,
      "strategy": "default",
      "default": "6379"
    },
    {
      "key": "REDISUSER",
      "service": "Redis",
      "description": "Username for authenticating with Redis",
      "secret": false,
      "strategy": "default",
      "default": "default"
    },
    {
      "key": "REDIS_URL",
      "service": "Redis",
      "description": "Connection string for connecting to Redis using the private network",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDISPASSWORD",
      "service": "Redis",
      "description": "Alias of REDIS_PASSWORD for clients that expect the unseparated name",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDIS_PASSWORD",
      "service": "Redis",
      "description": "Randomly generated password for authenticating with Redis",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "HOST",
      "service": "LiteLLM",
      "description": "Bind address; :: accepts IPv4 and IPv6 so other Railway services can call the gateway privately.",
      "secret": false,
      "strategy": "default",
      "default": "::"
    },
    {
      "key": "PORT",
      "service": "LiteLLM",
      "description": "HTTP port of the proxy and Admin UI (public domain target).",
      "secret": false,
      "strategy": "default",
      "default": "4000"
    },
    {
      "key": "REDIS_HOST",
      "service": "LiteLLM",
      "description": "Redis host for response caching and shared router state (rate limits, cooldowns) across workers/replicas.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "REDIS_PORT",
      "service": "LiteLLM",
      "description": "Redis port.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "LITELLM_LOG",
      "service": "LiteLLM",
      "description": "Log level (DEBUG, INFO, WARNING, ERROR). Use ERROR at high request volume.",
      "secret": false,
      "strategy": "default",
      "default": "INFO"
    },
    {
      "key": "NUM_WORKERS",
      "service": "LiteLLM",
      "description": "Uvicorn worker processes. ~0.6-1 GB RAM each; for more throughput prefer adding replicas.",
      "secret": false,
      "strategy": "default",
      "default": "2"
    },
    {
      "key": "UI_PASSWORD",
      "service": "LiteLLM",
      "description": "Admin UI password. Generated; read it from this variable.",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "UI_USERNAME",
      "service": "LiteLLM",
      "description": "Admin UI username (/ui).",
      "secret": false,
      "strategy": "default",
      "default": "admin"
    },
    {
      "key": "DATABASE_URL",
      "service": "LiteLLM",
      "description": "Postgres for models, virtual keys, teams, budgets and spend logs. Migrations run on start.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "LITELLM_MODE",
      "service": "LiteLLM",
      "description": "Production mode: no .env loading inside the container.",
      "secret": false,
      "strategy": "default",
      "default": "PRODUCTION"
    },
    {
      "key": "REDIS_PASSWORD",
      "service": "LiteLLM",
      "description": "Redis password.",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "LITELLM_SALT_KEY",
      "service": "LiteLLM",
      "description": "Encrypts provider credentials stored in Postgres. Generated once; never change it after adding models.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "STORE_MODEL_IN_DB",
      "service": "LiteLLM",
      "description": "Lets you add and edit models from the Admin UI (stored encrypted in Postgres).",
      "secret": false,
      "strategy": "default",
      "default": "True"
    },
    {
      "key": "LITELLM_CACHE_MODE",
      "service": "LiteLLM",
      "description": "Response cache mode: default_off = opt-in per request (cache: {use-cache: true}); default_on = cache every identical request.",
      "secret": false,
      "strategy": "default",
      "default": "default_off"
    },
    {
      "key": "LITELLM_MASTER_KEY",
      "service": "LiteLLM",
      "description": "Admin API key (must start with sk-). Use it to create virtual keys; keep private.",
      "secret": true,
      "strategy": "generate",
      "generate": "random_base64_32"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "LiteLLM",
      "description": "Seconds the old deployment keeps serving in-flight (streaming) requests during a redeploy.",
      "secret": false,
      "strategy": "default",
      "default": "120"
    },
    {
      "key": "PGDATA",
      "service": "Postgres",
      "description": "Location where the database will be initialized",
      "secret": false,
      "strategy": "default",
      "default": "/var/lib/postgresql/data/pgdata"
    },
    {
      "key": "PGHOST",
      "service": "Postgres",
      "description": "Railway Private Domain Name.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "PGPORT",
      "service": "Postgres",
      "description": "Port to connect to Postgres.",
      "secret": false,
      "strategy": "default",
      "default": "5432"
    },
    {
      "key": "PGUSER",
      "service": "Postgres",
      "description": "Required variable for Data panel",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGDATABASE",
      "service": "Postgres",
      "description": "Required variable for the data panel.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "PGPASSWORD",
      "service": "Postgres",
      "description": "Required variable for Data panel",
      "secret": true,
      "strategy": "railway_provided",
      "railway_source": "reference_variable"
    },
    {
      "key": "POSTGRES_DB",
      "service": "Postgres",
      "description": "Default database created when image is started.",
      "secret": false,
      "strategy": "default",
      "default": "railway"
    },
    {
      "key": "DATABASE_URL",
      "service": "Postgres",
      "description": "URL to connect to Postgres database.",
      "secret": false,
      "strategy": "railway_provided",
      "railway_source": "railway_private_domain"
    },
    {
      "key": "POSTGRES_USER",
      "service": "Postgres",
      "description": "User to connect to Postgres DB",
      "secret": false,
      "strategy": "default",
      "default": "postgres"
    },
    {
      "key": "SSL_CERT_DAYS",
      "service": "Postgres",
      "description": "SSL certificate expiry in days.",
      "secret": false,
      "strategy": "default",
      "default": "820"
    },
    {
      "key": "POSTGRES_PASSWORD",
      "service": "Postgres",
      "description": "Password to connect to DB",
      "secret": true,
      "strategy": "generate",
      "generate": "strong_password"
    },
    {
      "key": "RAILWAY_DEPLOYMENT_DRAINING_SECONDS",
      "service": "Postgres",
      "description": "Allow Postgres to cleanly shut down",
      "secret": false,
      "strategy": "default",
      "default": "60"
    }
  ],
  "deploy": {
    "mcp": {
      "server": "railway",
      "tool": "deploy_template",
      "args": {
        "template_code": "litellm-v1-ai-gateway-with-spend-trackin"
      }
    },
    "cli": "railway deploy --template litellm-v1-ai-gateway-with-spend-trackin",
    "api": {
      "method": "POST",
      "path": "/graphql/v2",
      "body": {
        "query": "mutation templateDeploy($input: TemplateDeployV2Input!) { templateDeployV2(input: $input) { projectId workflowId } }",
        "variables": {
          "input": {
            "templateId": "1ef97810-90d4-4e1f-be29-3b07d0a8f602",
            "serializedConfig": {
              "buckets": {},
              "services": {
                "069e475c-6f1e-5cc4-87e8-2640432af96c": {
                  "icon": "https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg",
                  "name": "Redis",
                  "deploy": {
                    "startCommand": "/bin/sh -c \"rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH\"",
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "redis:8.2"
                  },
                  "variables": {
                    "REDISHOST": {
                      "isOptional": true,
                      "description": "Private network hostname of the Redis service, only resolvable from services in the same environment",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "REDISPORT": {
                      "isOptional": true,
                      "description": "Port that Redis listens on",
                      "defaultValue": "6379"
                    },
                    "REDISUSER": {
                      "isOptional": true,
                      "description": "Username for authenticating with Redis",
                      "defaultValue": "default"
                    },
                    "REDIS_URL": {
                      "isOptional": true,
                      "description": "Connection string for connecting to Redis using the private network",
                      "defaultValue": "redis://${{ REDISUSER }}:${{ REDIS_PASSWORD }}@${{ REDISHOST }}:${{ REDISPORT }}"
                    },
                    "REDISPASSWORD": {
                      "isOptional": true,
                      "description": "Alias of REDIS_PASSWORD for clients that expect the unseparated name",
                      "defaultValue": "${{REDIS_PASSWORD}}"
                    },
                    "REDIS_PASSWORD": {
                      "isOptional": true,
                      "description": "Randomly generated password for authenticating with Redis",
                      "defaultValue": "{{REDIS_PASSWORD}}"
                    }
                  },
                  "networking": {
                    "tcpProxies": {},
                    "serviceDomains": {}
                  },
                  "volumeMounts": {
                    "7be27bd7-0eef-5351-b958-1d0d2f064e11": {
                      "mountPath": "/data"
                    }
                  }
                },
                "8c1c1990-4a87-5546-a788-f93f865862d8": {
                  "icon": "https://cdn.jsdelivr.net/gh/selfhst/icons@main/svg/litellm.svg",
                  "name": "LiteLLM",
                  "build": {
                    "builder": "DOCKERFILE"
                  },
                  "deploy": {
                    "healthcheckPath": "/health/readiness",
                    "restartPolicyType": "ON_FAILURE",
                    "healthcheckTimeout": 300,
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "repo": "baranberkay96/litellm-railway",
                    "branch": "main",
                    "rootDirectory": "/services/litellm"
                  },
                  "variables": {
                    "HOST": {
                      "isOptional": true,
                      "description": "Bind address; :: accepts IPv4 and IPv6 so other Railway services can call the gateway privately.",
                      "defaultValue": "::"
                    },
                    "PORT": {
                      "isOptional": true,
                      "description": "HTTP port of the proxy and Admin UI (public domain target).",
                      "defaultValue": "4000"
                    },
                    "REDIS_HOST": {
                      "isOptional": true,
                      "description": "Redis host for response caching and shared router state (rate limits, cooldowns) across workers/replicas.",
                      "defaultValue": "${{Redis.REDISHOST}}"
                    },
                    "REDIS_PORT": {
                      "isOptional": true,
                      "description": "Redis port.",
                      "defaultValue": "${{Redis.REDISPORT}}"
                    },
                    "LITELLM_LOG": {
                      "isOptional": true,
                      "description": "Log level (DEBUG, INFO, WARNING, ERROR). Use ERROR at high request volume.",
                      "defaultValue": "INFO"
                    },
                    "NUM_WORKERS": {
                      "isOptional": true,
                      "description": "Uvicorn worker processes. ~0.6-1 GB RAM each; for more throughput prefer adding replicas.",
                      "defaultValue": "2"
                    },
                    "UI_PASSWORD": {
                      "isOptional": true,
                      "description": "Admin UI password. Generated; read it from this variable.",
                      "defaultValue": "{{UI_PASSWORD}}"
                    },
                    "UI_USERNAME": {
                      "isOptional": true,
                      "description": "Admin UI username (/ui).",
                      "defaultValue": "admin"
                    },
                    "DATABASE_URL": {
                      "isOptional": true,
                      "description": "Postgres for models, virtual keys, teams, budgets and spend logs. Migrations run on start.",
                      "defaultValue": "${{Postgres.DATABASE_URL}}"
                    },
                    "LITELLM_MODE": {
                      "isOptional": true,
                      "description": "Production mode: no .env loading inside the container.",
                      "defaultValue": "PRODUCTION"
                    },
                    "GEMINI_API_KEY": {
                      "isOptional": true,
                      "description": "Optional. Default Google AI Studio (Gemini) key.",
                      "defaultValue": ""
                    },
                    "OPENAI_API_KEY": {
                      "isOptional": true,
                      "description": "Optional. Default OpenAI key used when a model has no key of its own.",
                      "defaultValue": ""
                    },
                    "REDIS_PASSWORD": {
                      "isOptional": true,
                      "description": "Redis password.",
                      "defaultValue": "${{Redis.REDIS_PASSWORD}}"
                    },
                    "LITELLM_SALT_KEY": {
                      "isOptional": true,
                      "description": "Encrypts provider credentials stored in Postgres. Generated once; never change it after adding models.",
                      "defaultValue": "{{LITELLM_SALT_KEY}}"
                    },
                    "ANTHROPIC_API_KEY": {
                      "isOptional": true,
                      "description": "Optional. Default Anthropic key.",
                      "defaultValue": ""
                    },
                    "STORE_MODEL_IN_DB": {
                      "isOptional": true,
                      "description": "Lets you add and edit models from the Admin UI (stored encrypted in Postgres).",
                      "defaultValue": "True"
                    },
                    "LITELLM_CACHE_MODE": {
                      "isOptional": true,
                      "description": "Response cache mode: default_off = opt-in per request (cache: {use-cache: true}); default_on = cache every identical request.",
                      "defaultValue": "default_off"
                    },
                    "LITELLM_MASTER_KEY": {
                      "isOptional": true,
                      "description": "Admin API key (must start with sk-). Use it to create virtual keys; keep private.",
                      "defaultValue": "{{LITELLM_MASTER_KEY}}"
                    },
                    "OPENROUTER_API_KEY": {
                      "isOptional": true,
                      "description": "Optional. Default OpenRouter key.",
                      "defaultValue": ""
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": true,
                      "description": "Seconds the old deployment keeps serving in-flight (streaming) requests during a redeploy.",
                      "defaultValue": "120"
                    }
                  },
                  "networking": {
                    "tcpProxies": {},
                    "serviceDomains": {
                      "<hasDomain>:4000": {
                        "port": 4000
                      }
                    }
                  }
                },
                "ab7402c7-2578-5bbd-b942-b867323d8836": {
                  "icon": "https://devicons.railway.app/i/postgresql.svg",
                  "name": "Postgres",
                  "deploy": {
                    "restartPolicyType": "ON_FAILURE",
                    "restartPolicyMaxRetries": 10
                  },
                  "source": {
                    "image": "ghcr.io/railwayapp-templates/postgres-ssl:18"
                  },
                  "variables": {
                    "PGDATA": {
                      "isOptional": true,
                      "description": "Location where the database will be initialized",
                      "defaultValue": "/var/lib/postgresql/data/pgdata"
                    },
                    "PGHOST": {
                      "isOptional": true,
                      "description": "Railway Private Domain Name.",
                      "defaultValue": "${{RAILWAY_PRIVATE_DOMAIN}}"
                    },
                    "PGPORT": {
                      "isOptional": true,
                      "description": "Port to connect to Postgres.",
                      "defaultValue": "5432"
                    },
                    "PGUSER": {
                      "isOptional": true,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{ POSTGRES_USER }}"
                    },
                    "PGDATABASE": {
                      "isOptional": true,
                      "description": "Required variable for the data panel.",
                      "defaultValue": "${{POSTGRES_DB}}"
                    },
                    "PGPASSWORD": {
                      "isOptional": true,
                      "description": "Required variable for Data panel",
                      "defaultValue": "${{POSTGRES_PASSWORD}}"
                    },
                    "POSTGRES_DB": {
                      "isOptional": true,
                      "description": "Default database created when image is started.",
                      "defaultValue": "railway"
                    },
                    "DATABASE_URL": {
                      "isOptional": true,
                      "description": "URL to connect to Postgres database.",
                      "defaultValue": "postgresql://${{PGUSER}}:${{POSTGRES_PASSWORD}}@${{RAILWAY_PRIVATE_DOMAIN}}:5432/${{PGDATABASE}}"
                    },
                    "POSTGRES_USER": {
                      "isOptional": true,
                      "description": "User to connect to Postgres DB",
                      "defaultValue": "postgres"
                    },
                    "SSL_CERT_DAYS": {
                      "isOptional": true,
                      "description": "SSL certificate expiry in days.",
                      "defaultValue": "820"
                    },
                    "POSTGRES_PASSWORD": {
                      "isOptional": true,
                      "description": "Password to connect to DB",
                      "defaultValue": "{{POSTGRES_PASSWORD}}"
                    },
                    "RAILWAY_DEPLOYMENT_DRAINING_SECONDS": {
                      "isOptional": true,
                      "description": "Allow Postgres to cleanly shut down",
                      "defaultValue": "60"
                    }
                  },
                  "networking": {
                    "tcpProxies": {},
                    "serviceDomains": {}
                  },
                  "volumeMounts": {
                    "d1ceccff-a093-53e2-8431-880e7a8f0a4a": {
                      "mountPath": "/var/lib/postgresql/data"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "post_deploy": {
    "healthcheck": {
      "service": "LiteLLM",
      "method": "GET",
      "path": "/health/readiness",
      "expect_status": 200
    }
  },
  "resources": {
    "expected_services": 3,
    "needs_volume": true
  },
  "generated_at": "2026-10-11T16:14:40.554Z",
  "generator_version": "0.1.0",
  "status": "validated",
  "validated_at": "2026-10-11T14:24:45.695Z",
  "success_rate_30d": 1,
  "validation": {
    "last_run_id": "run_5005118502634d9f9e24",
    "checks": [
      {
        "name": "workflow_completed",
        "passed": true
      },
      {
        "name": "all_services_deployed",
        "passed": true
      },
      {
        "name": "healthcheck",
        "passed": true
      },
      {
        "name": "stays_up",
        "passed": true
      }
    ],
    "typical_ready_seconds": 195,
    "typical_build_seconds": 53,
    "typical_start_seconds": 32,
    "slowest_service": "LiteLLM"
  }
}
