ChatGPT CLI v1.8.11
New Features:
- Support for custom HTTP headers on all API requests:
• You can now define a custom_headers map in your configuration to send additional headers (e.g., for proxies or API gateways).
• These headers are applied to both GET and POST requests and are also shown in debug curl output.
• Standard headers (Authorization, Content-Type, User-Agent) are preserved and not overridden.
• Code reference: config/config.go, api/http/http.go, api/client/client.go, README.md - Load API key from a file:
• New api_key_file configuration option and corresponding CLI setting (set-api-key-file).
• If the in-memory/explicit API key is empty, the CLI can read the key from a file.
• Precedence: environment variable API key > file (api_key_file) > error if neither is set.
• Code reference: cmd/chatgpt/main.go, config/config.go, README.md
Improvements:
- Enhanced debug output:
• When debug is enabled, custom headers are included in the printed curl command for easier troubleshooting.
• Code reference: api/client/client.go - Documentation updates:
• README now documents custom_headers usage with examples.
• README clarifies api_key default and introduces api_key_file. - Dependency updates:
• golang.org/x/text v0.30.0 (was v0.29.0)
• golang.org/x/net v0.46.0 (was v0.44.0)
• golang.org/x/sys v0.37.0 (was v0.36.0)
• github.com/sagikazarmark/locafero v0.12.0 (was v0.11.0)
• go/tools and other indirect deps updated/cleaned
Bug Fixes:
- Header handling correctness:
• Ensured custom headers do not override standard headers like Authorization and User-Agent.
• Verified behavior across GET/POST and nil/empty header maps through new tests.
• Code reference: api/http/http_test.go
Other Changes:
- Testing improvements:
• Added unit tests verifying custom headers behavior for GET/POST and safety with standard headers.
• Added integration tests for API key resolution order (env var over file, file fallback, error when missing).
• Code reference: api/http/http_test.go, test/integration/integration_test.go - Minor refactors:
• Import cleanups and internal code organization updates. - README tweaks:
• Added configuration table entries: custom_headers and api_key_file.
Upgrade Notes:
- How to update:
• Homebrew: brew upgrade chatgpt-cli
• Direct download: Fetch the latest binaries for your operating system from the releases page and replace your existing binary. - New configuration options:
• To add custom headers, include a block like:
custom_headers:
X-Custom-Header: "custom-value"
X-API-Version: "v2"
X-Client-ID: "my-client-id"
• To load the API key from a file, set api_key_file in your config or export OPENAI_API_KEY_FILE. The CLI will:- Prefer the API key from the environment variable (e.g., OPENAI_API_KEY) if present.
- Otherwise, read the key from the file specified by api_key_file or OPENAI_API_KEY_FILE.
- Error if neither is available.
- No breaking changes are expected. Existing configurations continue to work; you may optionally adopt custom_headers and/or api_key_file for improved flexibility.