system_gpt_router

Owner-quota GPT routing for internal Stargazer jobs.

The ChatGPT-authenticated Codex adapter is deliberately owned by the inference service. Internal jobs running in that process call it directly; jobs in the agents service cross a small Redis request/reply boundary. Callers retain their existing Gemini-proxy code as the fallback, so this module never silently changes an internal job into a user-visible reply path.

exception system_gpt_router.SystemGptUnavailable

Bases: RuntimeError

The owner-quota GPT route could not safely complete the request.

class system_gpt_router.OwnerQuotaGptRoute(model, effort, chat_url, service_tier, beneficiary_subject, account_id)

Bases: object

One resolved route against the configured owner’s current login.

Parameters:
  • model (str)

  • effort (str)

  • chat_url (str)

  • service_tier (str)

  • beneficiary_subject (str)

  • account_id (str)

model: str
effort: str
chat_url: str
service_tier: str
beneficiary_subject: str
account_id: str
class system_gpt_router.OwnerQuotaGptRouter(redis_client, openrouter=None, *, owner_discord_id='829047047633764402', request_timeout_seconds=60.0)

Bases: object

Route one tool-free internal completion through the owner’s Codex quota.

Parameters:
  • redis_client (Any)

  • openrouter (Any | None)

  • owner_discord_id (str)

  • request_timeout_seconds (float)

property can_call_direct: bool
async complete(*, messages=None, prompt=None, effort='low', job='internal', timeout_seconds=None)
Return type:

str

Parameters:
async generate_image(*, prompt, image_urls=None, effort='low', job='image', timeout_seconds=240.0)

Generate one GPT image against the configured owner’s Codex quota.

Return type:

bytes

Parameters:
async resolve_route(*, effort='low')

Resolve the owner’s current account without starting a generation.

Return type:

OwnerQuotaGptRoute

Parameters:

effort (str)

class system_gpt_router.OwnerQuotaGptBroker(redis_client, router, *, consumer_name)

Bases: object

Inference-owned Redis consumer for agents-service GPT requests.

Parameters:
async start()
Return type:

None

async stop()
Return type:

None