Add team billing headers to JudgeRubric default client#1033
Open
shayonj wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
Open
Add team billing headers to JudgeRubric default client#1033shayonj wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
shayonj wants to merge 1 commit intoPrimeIntellect-ai:mainfrom
Conversation
Judge clients created without an explicit AsyncOpenAI instance were missing the X-Prime-Team-ID header, causing API calls to bill the personal account instead of the team — even when PRIME_TEAM_ID was set in the environment. Extracts `build_prime_headers()` from the existing `_build_headers_and_api_key()` so it can be used without a ClientConfig. JudgeRubric's default client now picks up team context the same way generation clients already do via `setup_openai_client`.
8a04d91 to
cd4eae9
Compare
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.
Judge clients were missing the
X-Prime-Team-IDheader when created without an explicitAsyncOpenAIinstance — this caused judge API calls (e.g., toapi.pinference.ai) to bill the user's personal account instead of the team, even whenPRIME_TEAM_IDwas set in the environment.Generation clients already handle this correctly via
_build_headers_and_api_keyinclient_utils.py— this PR extracts that logic into a reusablebuild_prime_headers()helper and wires it intoJudgeRubric's default client.Note
Environments that create their own judge
AsyncOpenAIclients directly still need to pass the header themselves, this PR only fixes the default path inJudgeRubric. Those environments could switch to passing nojudge_clientand letting the default handle it, or usebuild_prime_headers()directly.Note
Medium Risk
Changes how
JudgeRubricconstructs its defaultAsyncOpenAIclient by injecting Prime API key resolution andX-Prime-Team-IDheaders, which can affect request routing/billing and potentially authentication if misconfigured.Overview
Fixes missing Prime team billing context for judge calls by extracting Prime API key/header resolution into reusable
build_prime_headers()and reusing it across clients.When
JudgeRubriccreates its own defaultAsyncOpenAIclient (no explicitjudge_clientprovided), it now setsdefault_headersto includeX-Prime-Team-ID(fromPRIME_TEAM_IDor~/.prime/config.json) and resolvesPRIME_API_KEYconsistently. Adds tests coveringbuild_prime_headers()behavior and verifyingJudgeRubricheader propagation and non-overriding of explicitly provided clients.Written by Cursor Bugbot for commit cd4eae9. This will update automatically on new commits. Configure here.