Skip to content
vastai-multi-env-setup logo

Vast.ai Multi-Environment Setup

vastai-multi-env-setup

Configure Vast.ai across development, staging, and production environments. Use when setting up multi-environment deployments, configuring per-environment secrets, or implementing environment-specific Vast.ai configurations. Trigger with phrases like "vastai environments", "vastai staging", "vast...

SKILL.md

Full skill instructions

Vast.ai Multi-Environment Setup

Overview

Configure Vast.ai across development, staging, and production environments.

Prerequisites

  • Separate Vast.ai accounts or API keys per environment
  • Secret management solution (Vault, AWS Secrets Manager, etc.)
  • CI/​CD pipeline with environment variables
  • Environment detection in application

Environment Strategy

EnvironmentPurposeAPI KeysData
DevelopmentLocal devTest keysSandbox
StagingPre-prod validationStaging keysTest data
ProductionLive trafficProduction keysReal data

Configuration Structure

config/
├── vastai/
│   ├── base.json           # Shared config
│   ├── development.json    # Dev overrides
│   ├── staging.json        # Staging overrides
│   └── production.json     # Prod overrides

base.json

{
  "timeout": 30000,
  "retries": 3,
  "cache": {
    "enabled": true,
    "ttlSeconds": 60
  }
}

development.json

{
  "apiKey": "${VASTAI_API_KEY}",
  "baseUrl": "https://api-sandbox.vastai.com",
  "debug": true,
  "cache": {
    "enabled": false
  }
}

staging.json

{
  "apiKey": "${VASTAI_API_KEY_STAGING}",
  "baseUrl": "https://api-staging.vastai.com",
  "debug": false
}

production.json

{
  "apiKey": "${VASTAI_API_KEY_PROD}",
  "baseUrl": "https://api.vastai.com",
  "debug": false,
  "retries": 5
}

Environment Detection

// src/​vastai/​config.ts
import baseConfig from '../​../​config/​vastai/​base.json';

type Environment = 'development' | 'staging' | 'production';

function detectEnvironment(): Environment {
  const env = process.env.NODE_ENV || 'development';
  const validEnvs: Environment[] = ['development', 'staging', 'production'];
  return validEnvs.includes(env as Environment)
    ? (env as Environment)
    : 'development';
}

export function getVast.aiConfig() {
  const env = detectEnvironment();
  const envConfig = require(`../​../​config/​vastai/​${env}.json`);

  return {
    ...baseConfig,
    ...envConfig,
    environment: env,
  };
}

Secret Management by Environment

Local Development

# .env.local (git-ignored)
VASTAI_API_KEY=sk_test_dev_***

CI/​CD (GitHub Actions)

env:
  VASTAI_API_KEY: ${{ secrets.VASTAI_API_KEY_${{ matrix.environment }} }}

Production (Vault/​Secrets Manager)

# AWS Secrets Manager
aws secretsmanager get-secret-value --secret-id vastai/​production/​api-key

# GCP Secret Manager
gcloud secrets versions access latest --secret=vastai-api-key

# HashiCorp Vault
vault kv get -field=api_key secret/​vastai/​production

Environment Isolation

// Prevent production operations in non-prod
function guardProductionOperation(operation: string): void {
  const config = getVast.aiConfig();

  if (config.environment !== 'production') {
    console.warn(`[vastai] ${operation} blocked in ${config.environment}`);
    throw new Error(`${operation} only allowed in production`);
  }
}

// Usage
async function deleteAllData() {
  guardProductionOperation('deleteAllData');
  // Dangerous operation here
}

Feature Flags by Environment

const featureFlags: Record<Environment, Record<string, boolean>> = {
  development: {
    newFeature: true,
    betaApi: true,
  },
  staging: {
    newFeature: true,
    betaApi: false,
  },
  production: {
    newFeature: false,
    betaApi: false,
  },
};

Instructions

Step 1: Create Config Structure

Set up the base and per-environment configuration files.

Step 2: Implement Environment Detection

Add logic to detect and load environment-specific config.

Step 3: Configure Secrets

Store API keys securely using your secret management solution.

Step 4: Add Environment Guards

Implement safeguards for production-only operations.

Output

  • Multi-environment config structure
  • Environment detection logic
  • Secure secret management
  • Production safeguards enabled

Error Handling

IssueCauseSolution
Wrong environmentMissing NODE_ENVSet environment variable
Secret not foundWrong secret pathVerify secret manager config
Config merge failsInvalid JSONValidate config files
Production guard triggeredWrong environmentCheck NODE_ENV value

Examples

Quick Environment Check

const env = getVast.aiConfig();
console.log(`Running in ${env.environment} with ${env.baseUrl}`);

Resources

Next Steps

For observability setup, see vastai-observability.

More DevOps & CI/CD skills

Project scaffolding, deployment configuration, and CI/CD setup for Google ADK agents.

6K 472.6K
View

Set up tracing, logging, and monitoring for deployed ADK agents across Cloud Trace, BigQuery, and third-party platforms.

6K 472.6K
View

Enterprise Azure infrastructure architect generating Bicep or Terraform from workload descriptions.

1.5K 454.3K
View
azure-kubernetes logo
DevOps & CI/CD

azure-kubernetes

Plan and configure production-ready Azure Kubernetes Service clusters with Day-0 and Day-1 best practices.

1.5K 447.1K
View

Raw mechanical interfaces fusing Swiss typographic print with military terminal aesthetics. Rigid grids, extreme type scale contrast, utilitarian color, analog degradation effects. For data-heavy dashboards, portfolios, or editorial sites that need to feel like declassified blueprints.

92.7K 354.9K
View
just-scrape logo
DevOps & CI/CD

just-scrape

Web search, scraping, extraction, crawling, and monitoring via ScrapeGraph AI CLI.

69 245K
View

Skill for working with Firebase Hosting (Classic). Use this when you want to deploy static web apps, Single Page Apps (SPAs), or simple microservices. Do NOT use for Firebase App Hosting.

462 159.7K
View

Deploy and manage web apps with Firebase App Hosting. Use this skill when deploying Next.js/Angular apps with backends.

462 159.1K
View
deploy-to-vercel logo
DevOps & CI/CD

deploy-to-vercel

Deploy applications and websites to Vercel. Use when the user requests deployment actions like "deploy my app", "deploy and give me the link", "push this live", or "create a preview deployment".

31.9K 146.6K
View
programmatic-seo logo
DevOps & CI/CD

programmatic-seo

Build SEO-optimized pages at scale using templates, data, and proven playbook patterns.

53.3K 140.1K
View

Design and build isolated, reusable Convex backend components with clear boundaries and app-facing wrappers.

63 123.5K
View

Deploy and manage projects on Vercel using token-based authentication. Use when working with Vercel CLI using access tokens rather than interactive login — e.g. "deploy to vercel", "set up vercel", "add environment variables to vercel".

31.9K 116.1K
View

Coding & apps AI tools

Opus Clip logo
Coding & apps

Opus Clip

Opus.ai: Revolutionize Your Web Experience

Free
View
I
Coding & apps

Imagica

Build a no-code AI app in minutes.

Freemium
View
E
Coding & apps

Emergent.sh

An IDE for code migration from legacy to modern frameworks through coding agents.

Freemium
View
Wonder Dynamics logo
Coding & apps

Wonder Dynamics

Automate CGI animation in live-action scenes

Paid
View
M
Coding & apps

Mixo

Launch a website in seconds with AI.

Paid
View
AI Code Convert logo
Coding & apps

AI Code Convert

Streamline Your Coding Experience with AI Code Helper

Free
View