Skip to main content

Overview

Environment variables let you configure your crew without changing code. Use them for:
  • API keys (OpenAI, Anthropic, etc.)
  • External service credentials
  • Configuration that varies between environments

Commands

Set Variables

crewship env set KEY=value
Set multiple variables at once:
crewship env set OPENAI_API_KEY=sk-... ANTHROPIC_API_KEY=sk-ant-...

Options

OptionDescription
--project <name>Target project (defaults to current directory)

List Variables

crewship env list
Output:
Environment variables for my-crew:

  OPENAI_API_KEY     sk-...xxxx (set 2 days ago)
  ANTHROPIC_API_KEY  sk-ant-...xxxx (set 2 days ago)
  DEBUG_MODE         false (set 5 days ago)

3 variables
Values are masked for security. Only the first and last few characters are shown.

Get a Variable

crewship env get OPENAI_API_KEY
Shows the masked value:
OPENAI_API_KEY=sk-...xxxx

Remove Variables

crewship env rm VARIABLE_NAME
Remove multiple:
crewship env rm VAR1 VAR2 VAR3

Examples

Setting API keys

# OpenAI
crewship env set OPENAI_API_KEY=sk-proj-...

# Anthropic
crewship env set ANTHROPIC_API_KEY=sk-ant-...

# Serper (for web search)
crewship env set SERPER_API_KEY=...

Configuration variables

crewship env set LOG_LEVEL=debug
crewship env set MAX_RETRIES=3

Using in your crew

Variables are automatically available as environment variables:
import os

openai_key = os.environ["OPENAI_API_KEY"]
log_level = os.environ.get("LOG_LEVEL", "info")
Or with CrewAI’s built-in support:
from crewai import Agent, LLM

# CrewAI automatically uses OPENAI_API_KEY
agent = Agent(
    role="Researcher",
    llm=LLM(model="gpt-4o")
)

Loading from .env

Load variables from a .env file:
crewship env set --file .env
Never commit .env files to version control. Add .env to your .gitignore.

Variable Scope

Environment variables are scoped to a project, not a deployment. This means:
  • All deployments in a project share the same variables
  • Updating a variable affects all future runs
  • No redeploy is needed after changing variables

Encryption

All environment variables are:
  • Encrypted at rest using AES-256
  • Transmitted over TLS
  • Never logged or exposed in build output

Reserved Variables

These variables are set by Crewship and cannot be overridden:
VariableDescription
CREWSHIP_RUN_IDCurrent run ID
CREWSHIP_DEPLOYMENT_IDCurrent deployment ID
CREWSHIP_PROJECTProject name

Best Practices

Name variables clearly: OPENAI_API_KEY not KEY1
Use different projects for staging and production
Update API keys periodically for security
Fail fast if a required variable is missing instead of using default values for secrets