Browse the docs

Configuration and environment

The two credential paths and every environment variable the generated agent reads.

Before you startA generated agent directory with `.env.example`.View as Markdown

Copy .env.example to .env for local runs. __main__.py and every test script load it. In a deployed container, set the same variables as Container Apps secrets and env vars, or pass --env-file to docker run.

Claude credentials: pick one path

Path A: Anthropic API direct

.env
ANTHROPIC_API_KEY=<your-anthropic-api-key>

Path B: Claude on Microsoft Foundry

.env
CLAUDE_CODE_USE_FOUNDRY=1
ANTHROPIC_FOUNDRY_RESOURCE=<your-foundry-resource-name>
ANTHROPIC_FOUNDRY_API_KEY=<your-foundry-resource-key>
ANTHROPIC_API_KEY=<the-same-foundry-resource-key>
  • ANTHROPIC_FOUNDRY_RESOURCE is the resource name only: no URL, no protocol. The SDK builds https://<name>.services.ai.azure.com/anthropic/ itself.
  • Set ANTHROPIC_API_KEY to the same value as ANTHROPIC_FOUNDRY_API_KEY. The bundled Claude Code CLI reads that name even in Foundry mode, and the health probe requires it.
  • The auth header on the wire is Anthropic-style x-api-key, not Azure's api-key.

Every variable

VariableDefaultWhat it does
ANTHROPIC_API_KEYnoneRequired on both paths.
CLAUDE_CODE_USE_FOUNDRYunset1 switches to Microsoft Foundry.
ANTHROPIC_FOUNDRY_RESOURCEnoneFoundry resource name (Path B).
ANTHROPIC_FOUNDRY_API_KEYnoneFoundry resource key (Path B).
AGENT_HOST0.0.0.0Bind address (plain-HTTP surface).
AGENT_PORT{{PORT}}Listen port (plain-HTTP surface).
AGENT_MAX_CONCURRENCY3Concurrent /execute streams per process.
CLAUDE_AGENT_CWD/appWorking directory; the SDK looks for .claude/skills/ here.
CLAUDE_AGENT_MODELclaude-sonnet-4-6Model id.
CLAUDE_AGENT_MAX_TURNS50Tool-call turns per run. Raise it if you see approaching cap warnings; lower it for stricter cost control.
CLAUDE_AGENT_MAX_BUDGET_USDunset (no ceiling)Hard per-run cost ceiling, passed as max_budget_usd.
CLAUDE_AGENT_EFFORTunset (SDK default)low, medium, high, xhigh, or max. Other values are ignored.
CLAUDE_AGENT_MAX_BUFFER_BYTESunset (SDK's 1 MiB)Raise for file-heavy skills, for example 67108864. See below.
CLAUDE_CODE_MAX_RETRIES5Bounded CLI retries.
<SKILL>_OUTPUTS_DIR/outputsOnly if the skill writes files; named by you, for example REPORT_OUTPUTS_DIR.
EMIT_STEP_ACTIVITY_LOGyour choiceAMC variant only: turns the thinking and tool detail rows on or off.

Env vars for the skill's own scripts

The CLI runs the skill's scripts with the env= dict from ClaudeAgentOptions. Put anything the scripts read there through {{SKILL_ENV_VARS}}, for example "REPORT_OUTPUTS_DIR": OUTPUTS_DIR for a skill that writes files or "REPORT_DIR": "/mnt/report" for one that reads tokens from a mounted share.

Where each value is set

Set inValues
Dockerfile ENVHOME, AGENT_PORT, AGENT_HOST, CLAUDE_AGENT_CWD, CLAUDE_AGENT_MODEL, and the outputs or token directory variables. Never secrets.
Runtime (secrets)ANTHROPIC_API_KEY, ANTHROPIC_FOUNDRY_API_KEY.
Runtime (plain env)CLAUDE_CODE_USE_FOUNDRY, ANTHROPIC_FOUNDRY_RESOURCE, and any tuning knob you want to change without a rebuild.

Last updated 2026-10-21