feat: add custom base URL configuration support #7
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR adds support for configuring custom API base URLs, allowing users to use alternative Groq-compatible endpoints for proxies, local development, or alternative services.
Changes
Core Features
--base-url
CLI argument to set custom API endpointsgroqBaseUrl
field support in~/.groq/local-settings.json
config fileGROQ_BASE_URL
environment variable supportImplementation Details
The implementation leverages the Groq SDK's native support for
GROQ_BASE_URL
environment variable while adding convenient config file support as a fallback, exactly mirroring how API keys are handled.Priority order (same as API key):
GROQ_BASE_URL
) - handled natively by SDKgroqBaseUrl
) - our fallback when env var not set--base-url
) - sets the environment variableFiles Changed
src/core/agent.ts
- Check config file for base URL when creating Groq clientsrc/core/cli.ts
- Add--base-url
CLI optionsrc/utils/local-settings.ts
- AddgroqBaseUrl
field and getter/setter methodssrc/tests/base-url.test.ts
- Comprehensive test coverageREADME.md
- Documentation for the new featureTesting
All tests pass ✅
8 test cases covering:
Usage Examples
Benefits