5.9 KiB
Environment Variables
Claude Code Haha has two configuration paths:
- Desktop users should select, test, and activate a provider under Settings → Providers. The app manages authentication, model mappings, and protocol translation.
- When running the CLI from source, use a repository
.env, shell variables, or Claude Codesettings.json.
Do not store the same API key in several places. When troubleshooting, first check whether a Desktop provider is active.
Common variables
Anthropic-compatible endpoints
| Variable | Required | Description |
|---|---|---|
ANTHROPIC_API_KEY |
Choose one authentication variable | Sent in the x-api-key request header |
ANTHROPIC_AUTH_TOKEN |
Choose one authentication variable | Sent as Authorization: Bearer |
ANTHROPIC_BASE_URL |
No | Base URL of an Anthropic Messages-compatible endpoint |
ANTHROPIC_MODEL |
No | Default model for the session |
ANTHROPIC_DEFAULT_FABLE_MODEL |
No | Fable model slot; configure it only when the provider supports it |
ANTHROPIC_DEFAULT_HAIKU_MODEL |
No | Haiku model slot |
ANTHROPIC_DEFAULT_SONNET_MODEL |
No | Sonnet model slot |
ANTHROPIC_DEFAULT_OPUS_MODEL |
No | Opus model slot |
API_TIMEOUT_MS |
No | API request timeout in milliseconds; defaults to 600000 |
The correct authentication variable depends on the header required by the service. Do not infer it from the provider name alone. For a 401 response, check the provider documentation and the authentication strategy selected in Desktop.
Azure OpenAI
Azure OpenAI uses a dedicated Responses API path:
| Variable | Required | Description |
|---|---|---|
CLAUDE_CODE_USE_AZURE_OPENAI |
Yes | Set to 1 to enable Azure OpenAI |
AZURE_OPENAI_BASE_URL |
Yes | Azure resource base URL; AZURE_OPENAI_ENDPOINT is also accepted |
AZURE_OPENAI_API_VERSION |
No | API version; defaults to 2025-04-01-preview |
AZURE_OPENAI_API_KEY |
Yes | Azure OpenAI API key |
AZURE_OPENAI_CODEX_DEPLOYMENT |
Model-dependent | Azure deployment name for Codex models |
Example:
CLAUDE_CODE_USE_AZURE_OPENAI=1
AZURE_OPENAI_BASE_URL=https://your-resource.cognitiveservices.azure.com
AZURE_OPENAI_API_VERSION=2025-04-01-preview
AZURE_OPENAI_API_KEY=your_azure_openai_key
AZURE_OPENAI_CODEX_DEPLOYMENT=your_codex_deployment
Local runtime and privacy
| Variable | Description |
|---|---|
CLAUDE_CONFIG_DIR |
Use a specific configuration directory instead of ~/.claude; useful for portable mode and isolated tests |
CLAUDE_CODE_FORCE_RECOVERY_CLI |
Set to 1 to use the simplified Recovery CLI |
CLAUDE_CODE_SHELL_PREFIX |
Prefix Bash tool commands, for example wsl -e bash -lc on Windows |
DISABLE_TELEMETRY |
Set to 1 to disable telemetry |
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC |
Set to 1 to disable non-essential network requests |
See Local Server for SERVER_HOST, SERVER_PORT, SERVER_AUTH_REQUIRED, and related variables.
Configuration methods
Desktop providers
Desktop stores the provider index at:
~/.claude/cc-haha/providers.json
Provider-managed environment data is written to an isolated Haha configuration. You do not need to copy it into ~/.claude/settings.json. When the CLI finds an active provider, it reuses its credentials, models, and protocol settings. Providers using openai_chat or openai_responses automatically use a loopback proxy.
See Third-Party Models for the setup flow.
Repository .env
The source bin/claude-haha launcher loads a .env file from the repository root when it exists:
cp .env.example .env
Minimal example for an Anthropic-compatible endpoint:
ANTHROPIC_AUTH_TOKEN=sk-example
ANTHROPIC_BASE_URL=https://provider.example.com/anthropic
ANTHROPIC_MODEL=provider-model
ANTHROPIC_DEFAULT_HAIKU_MODEL=provider-model
ANTHROPIC_DEFAULT_SONNET_MODEL=provider-model
ANTHROPIC_DEFAULT_OPUS_MODEL=provider-model
The repository .env is only for source launches. CLI processes created by Desktop skip it so a stale key cannot replace the active provider.
settings.json
User settings live at ~/.claude/settings.json:
{
"env": {
"ANTHROPIC_AUTH_TOKEN": "sk-example",
"ANTHROPIC_BASE_URL": "https://provider.example.com/anthropic",
"ANTHROPIC_MODEL": "provider-model"
}
}
A project can also contain .claude/settings.json or .claude/settings.local.json. These files are workspace input. Use them only in trusted projects, especially when they define PATH, LD_PRELOAD, proxy endpoints, or authentication variables.
Effective precedence
There is no reliable three-step rule such as “shell > .env > settings”:
bin/claude-hahafirst lets Bun load the repository.env.- CLI initialization merges enabled user, project, local, command-line, and managed setting sources.
- An active Haha provider overrides provider-routing values from ordinary Claude settings so the two clients do not contaminate each other.
- Runtime values injected by the Desktop host are protected from same-name fields in
settings.json. - Enterprise policy and
--setting-sourcescan also change the effective result.
Keep one primary provider configuration source. Desktop users should use the Providers page; CLI-only users should choose either .env or user-level settings.json.
Security guidance
- Never commit
.env, provider configuration, or asettings.jsoncontaining secrets. - Do not expose full tokens in screenshots, issues, logs, or diagnostic archives.
- Use
CLAUDE_CONFIG_DIRto isolate tests from real user configuration. --printskips the workspace trust dialog and must only run in trusted directories. See CLI Reference.- Do not treat CORS as authentication when exposing the local server. Enable an H5 token or explicit authentication.