Skip to content

feat: support baseURL config setting (Feat #516) #529

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

nvp159
Copy link

@nvp159 nvp159 commented Apr 22, 2025

Solves #516
### Summary

This PR adds first‐class support for overriding the API base URL used by each provider. You can now:

    * Override the default endpoint via environment variables
        * `OPENAI_BASE_URL` for OpenAI

        * `<PROVIDER>_BASE_URL` (e.g. `OLLAMA_BASE_URL`, `MISTRAL_BASE_URL`, etc.) for other providers
    * Override the endpoint per‐run with the new `--base-url` CLI flag

### Changes

    * **config.ts**
        * Enhanced `getBaseUrl(provider)` to:

            * Respect `OPENAI_BASE_URL` for OpenAI


            * Respect `<PREFIX>_BASE_URL` for all other providers (prefix derived from each provider’s env key)


            * Fall back to the built‑in `providers[provider].baseURL` default
    * **cli.tsx**
        * Introduced a new `--base-url <url>` flag (with help text)

        * When passed, mutate the provider’s `baseURL` in memory before any requests
    * **providers.ts**
        * Defines default `baseURL` and `envKey` for every supported provider

### Usage

    # 1) Environment‐level override (persistent)
    export OPENAI_BASE_URL="https://my-proxy.local/v1"
    codex --provider openai ...

    # 2) One‑off override via CLI
    codex --provider ollama \
          --base-url "http://localhost:11434/v1" \
          "Describe the architecture of …"

@tibo-openai
Copy link
Collaborator

Looks like there are other changes from #528 bundled in this PR, could you look at reverting those changes and keep this PR scoped to only the changes necessary to add _BASE_URL? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants