Skip to main content

Environment Variables

Complete reference for environment variables that influence Strands Base Agent at runtime.

For an overview of how YAML and env vars interact, start with the Configuration guide.

Quick Start (Minimal Setup)​

If you don't already have a .env file, create one first:

cp env.template .env

Most settings live in config.yaml. Env vars are typically only needed for secrets. Set these in .env:

STRANDS_API_KEY=<your-secret-token>

# Required for AWS Bedrock access
AWS_DEFAULT_REGION=us-east-1
AWS_PROFILE=default

Generate a key with:

python -c "import secrets; print(secrets.token_urlsafe(32))"

All other configuration has sensible defaults in config.yaml.

Override Convention​

When configuration is loaded from config.yaml (the recommended path), env vars override YAML values using the STRANDS__ prefix with double-underscore (__) as the nesting delimiter. Single underscores inside field names are preserved.

STRANDS__MODEL__PROVIDER=bedrock # overrides model.provider
STRANDS__MODEL__MODEL_ID=... # overrides model.model_id
STRANDS__SESSION_TYPE=file # overrides session_type (not session.type)

List fields accept comma-separated values:

STRANDS__TOOLS_MODULES=myapp.tools.search,myapp.tools.weather

Server​

VariableDefaultDescription
HOST0.0.0.0Server bind address
PORT8000Server port. Under docker compose, this is the host port only, and the container always listens on 8000
LOG_LEVELDEBUGApplication log level (read directly, not via the config loader)

Authentication​

VariableDefaultDescription
STRANDS_API_KEY— (required)Bearer token for HTTP authentication. All requests except the exempt paths below must include Authorization: Bearer <token>.
STRANDS_CHAT_HISTORY_LIST_ENABLEDfalseWhether GET /api/v1/chat/history (list every session on the instance) is enabled. Disabled by default: because auth here is a single shared bearer token, not per-user identity, any bearer-token holder could otherwise enumerate every session. Set to true only if you've established your own access control in front of this service.
STRANDS_CHAT_HISTORY_DELETE_ENABLEDfalseWhether DELETE /api/v1/chat/history/{session_id} is enabled. Disabled by default (returns 403) for the same reason: any bearer-token holder could otherwise delete any session. Independent of STRANDS_CHAT_HISTORY_LIST_ENABLED. Set to true only if you've established your own access control in front of this service. See HTTP API: Chat History.

Exempt paths (no token required):

  • /api/v1/health
  • /.well-known/agent.json
  • /.well-known/agent-card.json
  • Any OPTIONS request (CORS preflight)

AWS / Bedrock​

VariableDefaultDescription
AWS_PROFILEdefaultAWS profile for Bedrock access
AWS_DEFAULT_REGIONus-east-1AWS region
AWS_READ_TIMEOUT900Bedrock read timeout (seconds)
AWS_CONNECT_TIMEOUT60Bedrock connect timeout (seconds)

Model​

YAML fieldEnv overrideDefault
model.providerSTRANDS__MODEL__PROVIDERbedrock
model.model_idSTRANDS__MODEL__MODEL_IDus.anthropic.claude-haiku-5-5
model.temperatureSTRANDS__MODEL__TEMPERATURE0.3, never sent to Claude 5.x models on the built-in bedrock provider, which reject it
model.streamingSTRANDS__MODEL__STREAMINGtrue
model.max_tokensSTRANDS__MODEL__MAX_TOKENS—
model.top_pSTRANDS__MODEL__TOP_P—
model.ollama_urlSTRANDS__MODEL__OLLAMA_URL—
model.llamacpp_urlSTRANDS__MODEL__LLAMACPP_URL—
model.nims_base_urlSTRANDS__MODEL__NIMS_BASE_URL—
model.nims_api_keySTRANDS__MODEL__NIMS_API_KEY—
model.region_nameSTRANDS__MODEL__REGION_NAME—

To point at a local Ollama or llama.cpp instance, set model.ollama_url / model.llamacpp_url in config.yaml (or the STRANDS__MODEL__OLLAMA_URL / STRANDS__MODEL__LLAMACPP_URL overrides for environment-specific values). The bare OLLAMA_URL / LLAMACPP_URL vars shipped in env.template only apply on the from_env() path (defaults http://host.docker.internal:11434 and http://localhost:8080); see How env vars work.

To use an NVIDIA NIM endpoint, set model.nims_base_url in config.yaml and provide the API key via the STRANDS__MODEL__NIMS_API_KEY environment variable (do not store secrets in config.yaml). The bare NIMS_BASE_URL / NIMS_API_KEY vars only apply on the from_env() path; see How env vars work.

model.region_name overrides the AWS region specifically for Bedrock API calls, independent of AWS_DEFAULT_REGION. Use it when the agent runs in one region but needs to reach a model endpoint in another.

Agent Identity​

YAML fieldEnv overrideDefault
agent_nameSTRANDS__AGENT_NAMEstrands-base-agent
agent_descriptionSTRANDS__AGENT_DESCRIPTION(see config.yaml)
agent_versionSTRANDS__AGENT_VERSION1.0
agent_portSTRANDS__AGENT_PORT—
system_promptSTRANDS__SYSTEM_PROMPT(see config.yaml)

Tools​

YAML fieldEnv overrideDefault
tools_modulesSTRANDS__TOOLS_MODULES—
tools_filesSTRANDS__TOOLS_FILES—

Conversation & Memory​

YAML fieldEnv overrideDefault
max_conversation_lengthSTRANDS__MAX_CONVERSATION_LENGTH10
conversation_window_sizeSTRANDS__CONVERSATION_WINDOW_SIZE100
conversation_truncate_resultsSTRANDS__CONVERSATION_TRUNCATE_RESULTSfalse
enable_memorySTRANDS__ENABLE_MEMORYfalse
knowledge_base_idSTRANDS__KNOWLEDGE_BASE_ID—
agent_state_initial_valuesSTRANDS__AGENT_STATE_INITIAL_VALUES{}

Session Management​

YAML fieldEnv overrideDefault
session_idSTRANDS__SESSION_ID—
session_typeSTRANDS__SESSION_TYPE—
session_storage_dirSTRANDS__SESSION_STORAGE_DIR—
session_s3_bucketSTRANDS__SESSION_S3_BUCKET—
session_s3_prefixSTRANDS__SESSION_S3_PREFIX—

Guardrails​

Guardrails live under model.guardrails in config.yaml. Setting guardrail_id enables them.

YAML fieldEnv overrideDefault
model.guardrails.guardrail_idSTRANDS__MODEL__GUARDRAILS__GUARDRAIL_ID—
model.guardrails.guardrail_versionSTRANDS__MODEL__GUARDRAILS__GUARDRAIL_VERSION— (required when guardrail_id is set)
model.guardrails.guardrail_traceSTRANDS__MODEL__GUARDRAILS__GUARDRAIL_TRACEenabled

The single-underscore form (STRANDS_GUARDRAIL_ID, STRANDS_GUARDRAIL_VERSION, STRANDS_GUARDRAIL_TRACE) only applies on the from_env() path — see How env vars work.

See the Guardrails guide for setup steps.

MCP and A2A​

These are structured fields. YAML is strongly recommended over env vars.

# config.yaml
mcp_servers:
- name: github
url: https://api.githubcopilot.com/mcp/
headers:
Authorization: "Bearer ${GITHUB_PAT}"

a2a_servers:
- name: finance-agent
url: https://finance-agent.internal/api/

See the MCP servers guide for details.

Observability​

YAML fieldEnv overrideDefault
observability_enabledSTRANDS__OBSERVABILITY_ENABLEDfalse

The single-underscore form (STRANDS_O11Y_ENABLED) only applies on the from_env() path — see How env vars work.

OTLP exporter settings are read directly by the OpenTelemetry SDK, not by the config loader:

VariableDefaultDescription
OTEL_EXPORTER_OTLP_ENDPOINT—OTLP endpoint URL
OTEL_EXPORTER_OTLP_HEADERS—OTLP auth headers
OTEL_SERVICE_NAMEstrands-base-agentService name

CORS​

Set on the FastAPI middleware via foundry-agent-fastapi:

VariableDefaultDescription
STRANDS_CORS_ORIGINSlocalhost dev portsComma-separated allowed origins
STRANDS_CORS_ALLOW_CREDENTIALSfalseAllow credentials
STRANDS_CORS_ALLOW_METHODSGET,POST,PUT,DELETE,OPTIONS,HEADAllowed HTTP methods
STRANDS_CORS_ALLOW_HEADERSAccept,Content-Type,Authorization,...Allowed headers

Query Processing​

YAML fieldEnv overrideDefault
max_query_lengthSTRANDS__MAX_QUERY_LENGTH2000
default_similarity_thresholdSTRANDS__DEFAULT_SIMILARITY_THRESHOLD0.7
max_response_time_msSTRANDS__MAX_RESPONSE_TIME_MS30000

Miscellaneous​

VariableDefaultDescription
STRANDS_AGENT_PUBLIC_URLhttp://{agent_name}:{port}Public URL for the A2A agent card
STRANDS_A2A_MAX_CONTEXTS1000 (Strands SDK default)A2A conversations kept in memory, each with its own agent. The least recently used one is evicted past this limit. Must be an integer from 1 to 10000. Each kept conversation holds its full message history, so memory grows with this value. With no session_type (the default), an evicted conversation's history is lost; with file or s3 sessions it is reloaded from storage on its next message
STRANDS_IGNORE_DOTENVfalseSkip loading .env at startup

Security Note​

Secrets (API keys, tokens, AWS credentials) should stay in .env files and never in config.yaml.