amika auth extract discovers local credentials and prints shell assignments.
Quick start
# Print detected assignments
amika auth extract
# Export into current shell
eval "$(amika auth extract --export)"
# Skip OAuth sources
amika auth extract --no-oauth
Supported sources
Amika reads sources in priority order.
| Priority | Source | Files | Providers |
|---|
| 500 | Claude API key | ~/.claude.json.api, ~/.claude.json | Anthropic |
| 400 | Claude OAuth | ~/.claude/.credentials.json, ~/.claude-oauth-credentials.json | Anthropic |
| 300 | Codex | ~/.codex/auth.json | OpenAI |
| 290 | Amika env cache | ${XDG_CACHE_HOME}/amika/env-cache.json | Any |
| 280 | Amika keychain | ${XDG_DATA_HOME}/amika/keychain.json | Any |
| 270 | Amika OAuth | ${XDG_STATE_HOME}/amika/oauth.json | Any |
| 200 | OpenCode | ~/.local/share/opencode/auth.json | Any |
| 100 | Amp | ~/.amp/config.json | Anthropic |
Higher-priority sources win when multiple files provide the same provider key.
Output mapping
Amika normalizes provider names and exports common aliases:
- Anthropic keys output as both
ANTHROPIC_API_KEY and CLAUDE_API_KEY.
- OpenAI keys output as both
OPENAI_API_KEY and CODEX_API_KEY.
Example output:
ANTHROPIC_API_KEY='sk-ant-...'
CLAUDE_API_KEY='sk-ant-...'
OPENAI_API_KEY='sk-...'
CODEX_API_KEY='sk-...'
Flags
| Flag | Default | Description |
|---|
--export | false | Prefix lines with export |
--homedir <path> | $HOME | Override home directory for discovery |
--no-oauth | false | Skip OAuth credential sources |
Use --homedir in CI or test environments when you need deterministic credential fixtures.