docs: clarify auth_header is optional with default behavior in README

Move auth_header out of the main config example to avoid implying it is
required. Add a dedicated section explaining it is optional, its default
value, and when users need to set it explicitly.
This commit is contained in:
kite 2026-06-08 20:38:47 +08:00
parent fa6c7d8e04
commit b97382c727
4 changed files with 36 additions and 12 deletions

View file

@ -117,21 +117,27 @@ sudo cp dist/opencodereview /usr/local/bin/ocr
# オプションA: 対話的な設定
ocr config set llm.url https://api.anthropic.com/v1/messages
ocr config set llm.auth_token your-api-key-here
ocr config set llm.auth_header x-api-key
ocr config set llm.model claude-opus-4-6
ocr config set llm.use_anthropic true
# オプションB: 環境変数(最優先)
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
export OCR_LLM_TOKEN=your-api-key-here
export OCR_LLM_AUTH_HEADER=x-api-key
export OCR_LLM_MODEL=claude-opus-4-6
export OCR_USE_ANTHROPIC=true
```
設定は`~/.opencodereview/config.json`に保存されます。
Anthropicでは、標準の`sk-ant-*` APIキーは`x-api-key`を使用し、OAuthトークンは`authorization`を使用します。`llm.auth_header` / `OCR_LLM_AUTH_HEADER`を省略した場合、OCRは既存の`authorization` bearer-token動作を維持します。
**`auth_header`(オプション):** Anthropic使用時にAPIキーを送信するHTTPヘッダーを制御します。省略時のデフォルトは`authorization`Bearerトークンです。標準の`sk-ant-*` APIキーを使用する場合は、`x-api-key`に設定する必要があります:
```bash
ocr config set llm.auth_header x-api-key
# または
export OCR_LLM_AUTH_HEADER=x-api-key
```
サポートされる値:`x-api-key``authorization`(エイリアス:`bearer`)。それ以外の値はエラーになります。
また、Claude Codeの環境変数`ANTHROPIC_BASE_URL``ANTHROPIC_AUTH_TOKEN``ANTHROPIC_MODEL`)とも互換性があり、`~/.zshrc` / `~/.bashrc`からこれらのexportをパースします。

View file

@ -117,21 +117,27 @@ sudo cp dist/opencodereview /usr/local/bin/ocr
# Option A: 대화형 config
ocr config set llm.url https://api.anthropic.com/v1/messages
ocr config set llm.auth_token your-api-key-here
ocr config set llm.auth_header x-api-key
ocr config set llm.model claude-opus-4-6
ocr config set llm.use_anthropic true
# Option B: 환경 변수(가장 높은 우선순위)
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
export OCR_LLM_TOKEN=your-api-key-here
export OCR_LLM_AUTH_HEADER=x-api-key
export OCR_LLM_MODEL=claude-opus-4-6
export OCR_USE_ANTHROPIC=true
```
config는 `~/.opencodereview/config.json`에 저장됩니다.
Anthropic에서는 표준 `sk-ant-*` API key는 `x-api-key`를 사용하고, OAuth token은 `authorization`을 사용합니다. `llm.auth_header` / `OCR_LLM_AUTH_HEADER`를 생략하면 OCR은 기존 `authorization` bearer-token 동작을 유지합니다.
**`auth_header` (선택사항):** Anthropic 사용 시 API key를 전송할 HTTP header를 제어합니다. 생략하면 기본값은 `authorization` (Bearer token)입니다. 표준 `sk-ant-*` API key를 사용하는 경우 `x-api-key`로 설정해야 합니다:
```bash
ocr config set llm.auth_header x-api-key
# 또는
export OCR_LLM_AUTH_HEADER=x-api-key
```
지원되는 값: `x-api-key`, `authorization` (별칭: `bearer`). 그 외 값은 오류로 처리됩니다.
Claude Code 환경 변수(`ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_MODEL`)와도 호환되며, `~/.zshrc` / `~/.bashrc`의 export도 파싱합니다.

View file

@ -117,21 +117,27 @@ sudo cp dist/opencodereview /usr/local/bin/ocr
# Option A: Interactive config
ocr config set llm.url https://api.anthropic.com/v1/messages
ocr config set llm.auth_token your-api-key-here
ocr config set llm.auth_header x-api-key
ocr config set llm.model claude-opus-4-6
ocr config set llm.use_anthropic true
# Option B: Environment variables (highest priority)
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
export OCR_LLM_TOKEN=your-api-key-here
export OCR_LLM_AUTH_HEADER=x-api-key
export OCR_LLM_MODEL=claude-opus-4-6
export OCR_USE_ANTHROPIC=true
```
Config is stored in `~/.opencodereview/config.json`.
For Anthropic, standard `sk-ant-*` API keys use `x-api-key`; OAuth tokens use `authorization`. If `llm.auth_header` / `OCR_LLM_AUTH_HEADER` is omitted, OCR keeps the existing `authorization` bearer-token behavior.
**`auth_header` (optional):** Controls which HTTP header carries the API key when using Anthropic. Defaults to `authorization` (Bearer token) if omitted. If you use a standard `sk-ant-*` API key, you must set it to `x-api-key`:
```bash
ocr config set llm.auth_header x-api-key
# or
export OCR_LLM_AUTH_HEADER=x-api-key
```
Supported values: `x-api-key`, `authorization` (alias: `bearer`). Other values are rejected with an error.
It is also compatible with Claude Code environment variables (`ANTHROPIC_BASE_URL`, `ANTHROPIC_AUTH_TOKEN`, `ANTHROPIC_MODEL`) and parses `~/.zshrc` / `~/.bashrc` for those exports.

View file

@ -117,21 +117,27 @@ sudo cp dist/opencodereview /usr/local/bin/ocr
# 方式 A交互式配置
ocr config set llm.url https://api.anthropic.com/v1/messages
ocr config set llm.auth_token your-api-key-here
ocr config set llm.auth_header x-api-key
ocr config set llm.model claude-opus-4-6
ocr config set llm.use_anthropic true
# 方式 B环境变量优先级最高
export OCR_LLM_URL=https://api.anthropic.com/v1/messages
export OCR_LLM_TOKEN=your-api-key-here
export OCR_LLM_AUTH_HEADER=x-api-key
export OCR_LLM_MODEL=claude-opus-4-6
export OCR_USE_ANTHROPIC=true
```
配置存储于 `~/.opencodereview/config.json`
对于 Anthropic标准 `sk-ant-*` API key 使用 `x-api-key`OAuth token 使用 `authorization`。如果未配置 `llm.auth_header` / `OCR_LLM_AUTH_HEADER`OCR 会保留现有的 `authorization` bearer-token 行为。
**`auth_header`(可选):** 控制使用 Anthropic 时通过哪个 HTTP header 传递 API key。省略时默认为 `authorization`Bearer token。如果你使用标准 `sk-ant-*` API key需要将其设为 `x-api-key`
```bash
ocr config set llm.auth_header x-api-key
# 或
export OCR_LLM_AUTH_HEADER=x-api-key
```
支持的值:`x-api-key``authorization`(别名:`bearer`)。其他值会直接报错。
同时兼容了 Claude Code 环境变量(`ANTHROPIC_BASE_URL``ANTHROPIC_AUTH_TOKEN``ANTHROPIC_MODEL`),并解析 `~/.zshrc` / `~/.bashrc` 中的相关导出。