Support OpenAI-compatible endpoints via OPENAI_BASE_URL - #16
Open
abliteration-ai wants to merge 1 commit into
Open
Support OpenAI-compatible endpoints via OPENAI_BASE_URL#16abliteration-ai wants to merge 1 commit into
abliteration-ai wants to merge 1 commit into
Conversation
get_openai_client() and get_openai_config() now read the optional OPENAI_BASE_URL environment variable and pass it to the OpenAI SDK as base_url, so detectors can be pointed at any OpenAI-compatible API. When unset, behavior is unchanged (default api.openai.com endpoint). Adds unit tests for both helpers and documents the option in the Detection README with a provider example.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this? (check all applicable)
Related issue: N/A
What changed?
Detection/openai_config.py— the single place where OpenAI clients are constructed — now reads the optionalOPENAI_BASE_URLenvironment variable:get_openai_client()passes it to the SDK asbase_urlwhen set, so every consumer (create_chat_completion,create_reasoning_completion, the ADR baseline agent) can be pointed at any OpenAI-compatible API.get_openai_config()includes abase_urlkey when the variable is set.OPENAI_BASE_URLis unset, behavior is byte-for-byte identical to before (defaultapi.openai.comendpoint).Also adds unit tests for both helpers (
Detection/tests/test_openai_config.py) and a short README section documenting the option with a provider example (Abliteration.ai).Why?
The triage model is configurable in
config_detector.yaml, but the client was hardcoded to the hosted OpenAI API. Teams running OpenAI-compatible gateways or alternate providers (self-hosted vLLM, LiteLLM proxies, etc.) had no way to route detector traffic there.OPENAI_BASE_URLfollows the OpenAI SDK's own convention, so it's the least surprising knob.How did you test it?
uv run pytest tests/test_openai_config.py— 8 passed (4 existing + 4 new covering default endpoint, custom base URL, and the config dict with/withoutOPENAI_BASE_URL).black --checkclean on the touched test file;openai_config.pykeeps the file's existing style.Potential risks
None expected: the new code path only activates when
OPENAI_BASE_URLis set; existing deployments without it are unaffected. The Anthropic/Claude path is untouched.