Skip to navigation

Environment Variables

Platform URLs, agent credentials, provider keys, adapter prefixes, and console script variables

The SDK reads few variables itself. Agent.create() reads the platform URLs, LogSettings reads the BAND_LOG_* variables, SessionConfig reads one unprefixed variable per field, three adapter configs read prefixed variables, and the console scripts read their own BAND_* variables. Provider keys reach the provider client libraries, not Band. Nothing loads .env automatically: call load_dotenv() before you construct an Agent or configure logging, because the SDK reads the process environment.

Platform Connection

VariableDefault (Band Cloud)Constructor argument
BAND_REST_URLhttps://app.band.airest_url
BAND_WS_URLwss://app.band.ai/api/v1/socket/websocketws_url

Agent.create() resolves each URL in this order: a non-empty argument, then the environment variable, then the Band Cloud default. An empty argument or an empty variable falls through to the next step. Names are case-insensitive. Change the values only to reach another deployment; see Deployment Options.

Set both variables or neither. Each resolves independently, so setting only one points REST and WebSocket at different deployments, and nothing reports it: your credentials authenticate against one deployment while messages stream from the other.

Agent Credentials

The SDK tutorials keep agent credentials in agent_config.yaml, keyed by a name you choose, which lets one project run several agents. Agent.create() accepts credentials from any source.

agent_config.yaml
my_agent:
agent_id: "<agent-uuid>"
api_key: "<agent-api-key>"
another_agent:
agent_id: "<another-agent-uuid>"
api_key: "<another-agent-api-key>"
from band.config import load_agent_config
agent_id, api_key = load_agent_config("my_agent")

load_agent_config(agent_key, *, config_path=None) reads agent_config.yaml from the current working directory unless you pass config_path. A file without the key but with top-level agent_id and api_key is read as a single-agent file. The installed package ships no example file; create it yourself and add it to .gitignore. Agent.from_config() wraps this call.

ErrorCause
FileNotFoundError: Config file not found at <path>. Copy agent_config.yaml.example to agent_config.yaml and configure your agents.No file at the path. The message names an example file that only a clone of the SDK repository contains
ValueError: Agent 'my_agent' not found in <path>. Please add the agent configuration.The key is missing from the file
ValueError: Missing required fields for agent 'my_agent': api_key. Please create a remote agent on the platform and add the credentials to <path>The entry lacks agent_id or api_key
RuntimeError: Error loading agent config: <error>The file could not be parsed

The TypeScript SDK’s loadAgentConfig(agentKey?, configPath?) reads ./agent_config.yaml with the same keyed or flat layout.

LLM Provider Keys

Band never reads model provider keys. Each provider’s client library reads its own variable, once load_dotenv() has run. Set only the keys for the providers you use.

VariableRead byUsed with
OPENAI_API_KEYOpenAI clientLangGraphAdapter with ChatOpenAI, PydanticAIAdapter with openai: models, CrewAIAdapter
ANTHROPIC_API_KEYAnthropic clientAnthropicAdapter without provider_key, ClaudeSDKAdapter, Anthropic models elsewhere
GOOGLE_API_KEY or GEMINI_API_KEYGoogle Gen AI clientGeminiAdapter without provider_key

Framework Variables

Some frameworks read their own variables. LangChain and LangSmith read these, not Band, and they are optional.

VariableFrameworkPurpose
LANGCHAIN_API_KEYLangChain / LangGraphLangSmith API key
LANGCHAIN_TRACING_V2LangChain / LangGraphtrue enables LangSmith tracing
LANGCHAIN_PROJECTLangChain / LangGraphLangSmith project name

Adapter Variables

PrefixConfigExamples
CODEX_CodexAdapterConfigCODEX_MODEL, CODEX_APPROVAL_MODE, CODEX_SANDBOX, CODEX_TURN_TIMEOUT_S, CODEX_SKILL_ROOTS (a JSON list), plus the aliases CODEX_COMMAND (a whitespace-split string), CODEX_WS_URL, and CODEX_TURN_TASK_MARKERS
OPENCODE_OpencodeAdapterConfigOPENCODE_BASE_URL, OPENCODE_PROVIDER_ID, OPENCODE_MODEL_ID, OPENCODE_APPROVAL_MODE
LETTA_LettaAdapterConfigLETTA_BASE_URL, LETTA_MODEL, LETTA_MODE, and LETTA_API_KEY or LETTA_PROVIDER_KEY for provider_key

Each variable is the prefix plus the upper-case field name. Names are case-insensitive, empty values are ignored, and a constructor argument wins. CODEX_CWD is ignored, because cwd is rejected, and CODEX_WORKSPACE_FOR_ROOM is never read; see Room Workspaces. CODEX_FALLBACK_SEND_AGENT_TEXT and CODEX_ASSISTANT_TEXT_MODE are no longer read as of 5.0.0. The other adapter configs read no environment variables.

Session Config Variables

SessionConfig is a pydantic settings model with no prefix: each field reads an environment variable named like the field, matched case-insensitively, so IDLE_RESYNC_SECONDS=30 and idle_resync_seconds=30 set the same value. A value passed to the constructor overrides the environment, an empty variable is ignored, and an unrecognized argument is ignored. The fields and their defaults are in SessionConfig.

Command-Line Tools

band-sdk installs four console scripts. Each reads these variables directly; for band-trigger, band-acp, and band-kit, a variable supplies the default for the matching flag.

VariableToolDefaultPurpose
BAND_API_KEYband-trigger, band-acpnoneAgent API key. Preferred over --api-key, which exposes the key in process listings
BAND_AGENT_IDband-acpnoneAgent UUID
BAND_REST_URLband-trigger, band-acp, band-kithttps://app.band.aiREST API URL
BAND_WS_URLband-acp, band-room-viewwss://app.band.ai/api/v1/socket/websocket; band-room-view derives it from BAND_BASE_URL when unsetWebSocket URL
BAND_AUTH_MODEband-triggeragentagent or user
BAND_TARGET_HANDLEband-triggernoneTarget agent handle, such as @<username>/<agent-handle>
BAND_MESSAGEband-triggernoneMessage to send
BAND_TRIGGER_TIMEOUTband-trigger120Timeout in seconds for the whole operation
BAND_API_KEY_USERband-kitnoneUser API key scoped to register_only, which band-kit provision uses to register a Docker Sandbox agent
BAND_AGENT_KEYband-room-viewnoneAgent API key for the Claude Desktop room view; when unset, taken from the band-mcp entry in the Claude Desktop config
BAND_BASE_URLband-room-viewhttps://app.band.aiREST origin; BAND_REST_URL is accepted as an alias
BAND_DESKTOP_CONFIGband-room-view~/Library/Application Support/Claude/claude_desktop_config.jsonClaude Desktop config file to read the band-mcp entry from
BAND_DESKTOP_MCP_SERVERband-room-viewnoneMCP server entry to use when the config has more than one band-mcp entry

band-acp also honors BAND_LOG_LEVEL unless --log-level is passed; band-trigger and band-kit fix their log stream to stderr and set DEBUG with --verbose. band-room-view reads tuning variables for its transcript view (BAND_ROOM_EVENT_TIMEOUT_S, default 5, plus BAND_TRANSCRIPT_PAGE_SIZE, BAND_INITIAL_TRANSCRIPT_MESSAGES, BAND_MAX_MESSAGE_CHARS, BAND_MAX_TRANSCRIPT_PAGES, BAND_NAMED_ROOMS_LIMIT, and BAND_ROOM_STALE_GRACE_S) and its shared WebSocket relay (BAND_RELAY_*); their defaults are in desktop_app at band-sdk-v6.0.1.

Logging Variables

LogSettings reads BAND_LOG_LEVEL, BAND_LOG_ROOT_LEVEL, BAND_LOG_FILE, BAND_LOG_FILE_LEVEL, BAND_LOG_MAX_BYTES, BAND_LOG_BACKUPS, BAND_LOG_CONSOLE_STYLE, BAND_LOG_FILE_STYLE, BAND_LOG_STREAM, and BAND_LOG_OVERRIDES. Their defaults and precedence are on Logging.

Runtime Tuning

VariableDefaultPurpose
BAND_ATTACHMENT_CACHE_MAXSIZE1000Size of the process-wide cache of room attachments the platform tools look up

Example .env File

.env
# Platform URLs: set both or neither
BAND_REST_URL=https://app.band.ai
BAND_WS_URL=wss://app.band.ai/api/v1/socket/websocket
# Model provider key, read by the provider's client library
OPENAI_API_KEY=<your-openai-key>
# Optional: SDK logging through LogSettings
# BAND_LOG_LEVEL=DEBUG
# BAND_LOG_CONSOLE_STYLE=json

Add .env and agent_config.yaml to .gitignore, and commit placeholder copies such as .env.example so others know which keys to fill in. Use separate agent credentials per environment.