feat(openai): add configurable base_url support with OPENAI_BASE_URL env var

- Add base_url field to OpenAIConfig with default "https://api.openai.com/v1"
- Update sample_run_config to support OPENAI_BASE_URL environment variable
- Modify get_base_url() to return configured base_url instead of hardcoded value
- Add comprehensive test suite covering:
  - Default base URL behavior
  - Custom base URL from config
  - Environment variable override
  - Config precedence over environment variables
  - Client initialization with configured URL
  - Model availability checks using configured URL

This enables users to configure custom OpenAI-compatible API endpoints
via environment variables or configuration files.
This commit is contained in:
Matthew Farrellee 2025-07-26 06:04:00 -04:00
parent 09abdb0a37
commit 79c9e46582
7 changed files with 143 additions and 3 deletions

View file

@ -56,6 +56,7 @@ providers:
provider_type: remote::openai
config:
api_key: ${env.OPENAI_API_KEY:=}
base_url: ${env.OPENAI_BASE_URL:=https://api.openai.com/v1}
- provider_id: anthropic
provider_type: remote::anthropic
config:

View file

@ -16,6 +16,7 @@ providers:
provider_type: remote::openai
config:
api_key: ${env.OPENAI_API_KEY:=}
base_url: ${env.OPENAI_BASE_URL:=https://api.openai.com/v1}
- provider_id: anthropic
provider_type: remote::anthropic
config:

View file

@ -56,6 +56,7 @@ providers:
provider_type: remote::openai
config:
api_key: ${env.OPENAI_API_KEY:=}
base_url: ${env.OPENAI_BASE_URL:=https://api.openai.com/v1}
- provider_id: anthropic
provider_type: remote::anthropic
config: