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_RESOURCEis the resource name only: no URL, no protocol. The SDK buildshttps://<name>.services.ai.azure.com/anthropic/itself.- Set
ANTHROPIC_API_KEYto the same value asANTHROPIC_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'sapi-key.
Every variable
| Variable | Default | What it does |
|---|---|---|
ANTHROPIC_API_KEY | none | Required on both paths. |
CLAUDE_CODE_USE_FOUNDRY | unset | 1 switches to Microsoft Foundry. |
ANTHROPIC_FOUNDRY_RESOURCE | none | Foundry resource name (Path B). |
ANTHROPIC_FOUNDRY_API_KEY | none | Foundry resource key (Path B). |
AGENT_HOST | 0.0.0.0 | Bind address (plain-HTTP surface). |
AGENT_PORT | {{PORT}} | Listen port (plain-HTTP surface). |
AGENT_MAX_CONCURRENCY | 3 | Concurrent /execute streams per process. |
CLAUDE_AGENT_CWD | /app | Working directory; the SDK looks for .claude/skills/ here. |
CLAUDE_AGENT_MODEL | claude-sonnet-4-6 | Model id. |
CLAUDE_AGENT_MAX_TURNS | 50 | Tool-call turns per run. Raise it if you see approaching cap warnings; lower it for stricter cost control. |
CLAUDE_AGENT_MAX_BUDGET_USD | unset (no ceiling) | Hard per-run cost ceiling, passed as max_budget_usd. |
CLAUDE_AGENT_EFFORT | unset (SDK default) | low, medium, high, xhigh, or max. Other values are ignored. |
CLAUDE_AGENT_MAX_BUFFER_BYTES | unset (SDK's 1 MiB) | Raise for file-heavy skills, for example 67108864. See below. |
CLAUDE_CODE_MAX_RETRIES | 5 | Bounded CLI retries. |
<SKILL>_OUTPUTS_DIR | /outputs | Only if the skill writes files; named by you, for example REPORT_OUTPUTS_DIR. |
EMIT_STEP_ACTIVITY_LOG | your choice | AMC 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 in | Values |
|---|---|
Dockerfile ENV | HOME, 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. |
Related
Last updated 2026-10-21