#2838·pr-agent

feat: first-class prefixes for OpenAI-compatible gateways (generalize the OpenRouter wiring)

Author: nissrin2020ali-uxCreated Aug 27, 2026Updated Sep 25, 2026
Labelsfeature

Summary

Support first-class model prefixes for OpenAI-compatible AI gateways, instead of wiring each gateway one vendor at a time.

PR-Agent already gives OpenRouter a first-class prefix: a [openrouter] key/base section in configuration.toml and an openrouter/... model prefix handled in LiteLLMAIHandler (pr_agent/algo/ai_handlers/litellm_ai_handler.py). Other OpenAI-compatible gateways that expose a provider/model namespace (e.g. OrcaRouter) currently have to be configured through the generic [openai] api_base + openai/ prefix, which redirects all openai/-prefixed models to that endpoint.

Proposal

Generalize the OpenRouter wiring so any OpenAI-compatible gateway can be configured with its own prefix, key and api_base — e.g. a generic gateway_prefix -> {key, api_base} mapping — rather than adding one hardcoded provider block per vendor (openrouter, then orcarouter, ...). With such a mapping, a config like:

toml
[orcarouter]
key = "..."
api_base = "https://api.orcarouter.ai/v1"

would route orcarouter/<vendor>/<model> (or orcarouter/auto) requests to that api_base through the OpenAI-compatible path (custom_llm_provider="openai"), without hijacking the shared [openai] endpoint.

Design note

The current per-provider init blocks (the OpenRouter one, and the OrcaRouter variant proposed in #2834) set handler-wide litellm.api_base / litellm.api_key / openai.api_key at __init__ with no reference to the requested model, so a multi-provider config misroutes sibling providers and fallback models. The Databricks block already works around this per-call. A generic design should select endpoint and credential from the model prefix per call in chat_completion, not at init time.

Context

Original discussion in #2834: the OrcaRouter provider PR was reshaped to documentation only; the maintainer suggested deciding gateway-prefix support generically for all gateways at once.