Repository navigation
Description
Area
Provider adapters
What are you trying to accomplish?
I want to route a model exposed through the vercel-ai-gateway provider to a specific underlying inference provider.
For example, zai/glm-5.2 is available through multiple upstream providers. I need to pin it to one provider, define an ordered preference list, or select providers by cost/latency/throughput while continuing to use Vercel AI Gateway for authentication, billing, observability, and fallback.
OpenCodex already supports the equivalent workflow for OpenRouter through provider-wide openRouterRouting and model-specific modelOpenRouterRouting.
What prevents this today?
Vercel AI Gateway supports request-scoped provider filtering and ordering, but OpenCodex does not currently expose or forward those options for a vercel-ai-gateway configuration.
Vercel documents:
order: preferred provider orderonly: restrict routing to an allowed provider setsort: rank providers bycost,ttft, ortpsproviderOptionsin the REST / OpenAI-compatible API- a top-level
providershorthand in the Chat Completions API
The existing OpenRouter routing configuration cannot be reused as a workaround because OpenCodex intentionally validates it against the canonical https://openrouter.ai/api/v1 endpoint and only emits the OpenRouter request payload for that target.
The Vercel dashboard also does not provide an equivalent persistent per-model routing choice for this OpenCodex workflow.
What should OpenCodex do?
OpenCodex should allow provider-wide and exact model-specific Vercel AI Gateway routing preferences.
Observable behavior:
- A user can restrict a Vercel-routed model to one or more underlying provider slugs.
- A user can define the order in which eligible providers are attempted.
- A user can optionally sort eligible providers by
cost,ttft, ortps. - Model-specific settings override provider-wide defaults.
- Requests without these settings preserve Vercel's current dynamic routing behavior.
- The preferences are forwarded using Vercel's documented OpenAI-compatible request shape.
Example usage or interface
The exact configuration names are only illustrative, but a configuration parallel to the existing OpenRouter fields would make the behavior clear:
{
"providers": {
"vercel-ai-gateway": {
"adapter": "openai-chat",
"baseUrl": "https://ai-gateway.vercel.sh/v1",
"vercelGatewayRouting": {
"sort": "ttft"
},
"modelVercelGatewayRouting": {
"zai/glm-5.2": {
"only": ["novita"],
"order": ["novita"]
}
}
}
}
}A preference list with restricted fallback could look like:
{
"modelVercelGatewayRouting": {
"zai/glm-5.2": {
"only": ["novita", "deepinfra"],
"order": ["deepinfra", "novita"]
}
}
}For the OpenAI-compatible Chat Completions wire, the resulting request could use Vercel's documented shorthand:
{
"model": "zai/glm-5.2",
"provider": {
"only": ["novita"],
"order": ["novita"]
}
}Alternatives or workarounds
- Accept Vercel's dynamic provider selection.
- Configure the upstream provider directly in OpenCodex, which loses Vercel AI Gateway billing, observability, and centralized credentials.
- Patch the
openai-chatadapter locally to add aproviderorproviderOptionsrequest field. - Use OpenRouter instead, where OpenCodex already supports provider-level routing preferences.
None provides the requested Vercel AI Gateway workflow without giving up gateway functionality or maintaining a local patch.
Additional context
- OpenCodex version observed:
2.11.1 - Vercel Provider Options: https://vercel.com/docs/ai-gateway/models-and-providers/provider-options
- Vercel Provider Filtering, Ordering & Sorting: https://vercel.com/docs/ai-gateway/models-and-providers/provider-filtering-and-ordering
- Vercel documents that REST/OpenAI-compatible requests accept
providerOptions, and Chat Completions also accepts the top-levelprovidershorthand. - Existing OpenRouter implementation:
src/providers/openrouter-routing.tsand theopenai-chatadapter's OpenRouter request-body injection.
Checks
- I searched existing issues and documentation.
- This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
- I removed secrets and personal data.
Activity
Ingwannu commentedon Aug 10, 2026
Confirmed as a real missing capability on current
dev. OpenCodex only validates and emitsopenRouterRouting/modelOpenRouterRouting; the canonical Vercel AI Gateway preset has no equivalent path, even though Vercel documents provider filtering, ordering, andcost/ttft/tpssorting.This direction is valuable, with these implementation boundaries:
openai-chat;A focused PR following that contract would be reviewable. Keeping the issue open for implementation.
lidge-jun commentedon Aug 19, 2026
리뷰 · 우선순위 40 / 80
vercel-ai-gateway로 노출된 모델을 특정 업스트림 추론 프로바이더에 고정하거나 순서/정렬하고 싶다는 요청입니다. 인증과 빌링은 Vercel에 두고, OpenRouter의 openRouterRouting과 같은 운영 경험을 원합니다.
현재 dev의 src/providers/registry.ts에 vercel-ai-gateway가 openai-chat, https://ai-gateway.vercel.sh/v1 로 있습니다. 라우팅 설정은 src/types.ts의 openRouterRouting과 modelOpenRouterRouting, src/providers/openrouter-routing.ts 검증뿐입니다. src/adapters/openai-chat.ts는 resolveOpenRouterRouting이 있을 때만 body.provider를 넣습니다. vercelGatewayRouting 필드는 없습니다. OpenRouter 설정은 캐논 openrouter.ai에만 쓰이도록 막혀 있어 우회가 아닙니다.
원하는 동작은 only, order, sort(cost/ttft/tps), 모델별 오버라이드, 설정 없으면 Vercel 기본 동적 라우팅 유지입니다. Chat Completions의 provider 단축 형태는 이슈가 인용한 Vercel 문서와, 이미 OpenRouter에 쓰는 body.provider 주입과 비슷합니다.
해결방안: OpenRouter와 나란히 프로바이더/모델 설정을 추가하고, 유효 와이어가 Vercel 게이트웨이일 때만 provider 페이로드를 넣으면 됩니다. 기본 동작은 바꾸지 말아야 합니다. 필드 이름을 이슈 예시와 똑같이 할지는 제품 결정입니다. 게이트웨이 호스트 핀은 OpenRouter와 같게 유지해야 합니다.
이 댓글은 grok-bot이 작성했습니다
lidge-jun commentedon Aug 19, 2026
리뷰 · 우선순위 40 / 80 · 유지
Vercel AI Gateway에서 같은 모델을 novita/deepinfra 중 어디 탈지 고르자는 요청. OpenRouter는 이미
openRouterRouting/modelOpenRouterRouting이 있는데, Vercel은 그 필드를 안 받음.order/only/sort(cost, ttft, tps) 받아서 업스트림provider샤트핸드로 넘기면 됨.유지함. OpenRouter 경로를 그대로 검증하거나 다시 쓰지 말 것. 설정 없으면 지금처럼 Vercel 동적 라우팅 그대로.
해결방안:
vercelGatewayRouting+modelVercelGatewayRouting을 OpenRouter랑 같은 모양으로 넣고,openai-chat에서 Vercel 문서 페이로드로 전송. 모델 설정이 프로바이더 기본보다 우선.이 댓글은 grok-bot이 작성했습니다
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): wire vercelGatewayRouting management validation, saf…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): wire vercelGatewayRouting management validation, saf…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): wire vercelGatewayRouting management validation, saf…
feat(providers): add model-specific provider routing for Vercel AI Ga…
6 remaining items
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): wire vercelGatewayRouting management validation, saf…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): wire vercelGatewayRouting management validation, saf…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): wire vercelGatewayRouting management validation, saf…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): wire vercelGatewayRouting management validation, saf…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…
feat(providers): add model-specific provider routing for Vercel AI Ga…