File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -66,13 +66,15 @@ export const buildOpenAIChatCompletionsEndpoint = (baseUrl: string): string => {
6666export const buildCodexResponsesEndpoint = ( baseUrl : string ) : string => {
6767 const trimmed = normalizeUpstreamBaseUrl ( baseUrl ) ;
6868 if ( ! trimmed ) return '' ;
69- if ( / \/ v 1 \/ r e s p o n s e s $ / i. test ( trimmed ) ) {
69+ // Codex 兼容供应商可能把 Responses API 暴露在 /v3 下。
70+ // 已明确携带 v1/v3 版本的地址必须沿用该版本,不能再拼成 /v3/v1/responses。
71+ if ( / \/ v (?: 1 | 3 ) \/ r e s p o n s e s $ / i. test ( trimmed ) ) {
7072 return trimmed ;
7173 }
72- if ( / \/ v 1 \/ m o d e l s $ / i. test ( trimmed ) ) {
74+ if ( / \/ v (?: 1 | 3 ) \/ m o d e l s $ / i. test ( trimmed ) ) {
7375 return trimmed . replace ( / \/ m o d e l s $ / i, '/responses' ) ;
7476 }
75- if ( / \/ v 1 $ / i. test ( trimmed ) ) {
77+ if ( / \/ v (?: 1 | 3 ) $ / i. test ( trimmed ) ) {
7678 return `${ trimmed } /responses` ;
7779 }
7880 return `${ trimmed } /v1/responses` ;
Original file line number Diff line number Diff line change @@ -38,8 +38,10 @@ const buildV1ModelsEndpoint = (baseUrl: string): string => {
3838 const normalized = normalizeApiBase ( baseUrl ) ;
3939 if ( ! normalized ) return '' ;
4040 const trimmed = normalized . replace ( / \/ + $ / g, '' ) ;
41- if ( / \/ v 1 \/ m o d e l s $ / i. test ( trimmed ) ) return trimmed ;
42- if ( / \/ v 1 $ / i. test ( trimmed ) ) return `${ trimmed } /models` ;
41+ // Codex 的部分兼容供应商使用 /v3。若调用方已经给出 v3 版本前缀,
42+ // 模型发现必须继续请求 /v3/models,不能降回或追加成 /v3/v1/models。
43+ if ( / \/ v (?: 1 | 3 ) \/ m o d e l s $ / i. test ( trimmed ) ) return trimmed ;
44+ if ( / \/ v (?: 1 | 3 ) $ / i. test ( trimmed ) ) return `${ trimmed } /models` ;
4345 return `${ trimmed } /v1/models` ;
4446} ;
4547
You can’t perform that action at this time.
0 commit comments