Skip to content

Commit 2d77524

Browse files
committed
fix(models): Add Anthropic pagination and robust Google SDK model resolution for multi-SDK routes.
Signed-off-by: Sébastien Han <seb@redhat.com>
1 parent 752699e commit 2d77524

9 files changed

Lines changed: 449 additions & 31 deletions

File tree

client-sdks/stainless/openapi.yml

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ paths:
11671167
get:
11681168
responses:
11691169
'200':
1170-
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or `x-goog-api-key` header for Google format.
1170+
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) for Google format.
11711171
content:
11721172
application/json:
11731173
schema:
@@ -1193,9 +1193,41 @@ paths:
11931193
tags:
11941194
- Models
11951195
summary: List models.
1196-
description: List models. Returns OpenAI, Anthropic, or Google response format based on SDK headers.
1196+
description: List models. Returns OpenAI, Anthropic, or Google response format based on SDK detection headers.
11971197
operationId: list_models_v1_models_get
11981198
parameters:
1199+
- name: before_id
1200+
in: query
1201+
required: false
1202+
schema:
1203+
anyOf:
1204+
- type: string
1205+
- type: 'null'
1206+
description: Return models before this model ID (Anthropic SDK format only).
1207+
title: Before Id
1208+
description: Return models before this model ID (Anthropic SDK format only).
1209+
- name: after_id
1210+
in: query
1211+
required: false
1212+
schema:
1213+
anyOf:
1214+
- type: string
1215+
- type: 'null'
1216+
description: Return models after this model ID (Anthropic SDK format only).
1217+
title: After Id
1218+
description: Return models after this model ID (Anthropic SDK format only).
1219+
- name: limit
1220+
in: query
1221+
required: false
1222+
schema:
1223+
anyOf:
1224+
- type: integer
1225+
maximum: 1000
1226+
minimum: 1
1227+
- type: 'null'
1228+
description: Maximum number of models to return (Anthropic SDK format only).
1229+
title: Limit
1230+
description: Maximum number of models to return (Anthropic SDK format only).
11991231
- name: anthropic-version
12001232
in: header
12011233
required: false
@@ -1212,6 +1244,22 @@ paths:
12121244
- type: string
12131245
- type: 'null'
12141246
title: X-Goog-Api-Key
1247+
- name: x-goog-user-project
1248+
in: header
1249+
required: false
1250+
schema:
1251+
anyOf:
1252+
- type: string
1253+
- type: 'null'
1254+
title: X-Goog-User-Project
1255+
- name: x-goog-api-client
1256+
in: header
1257+
required: false
1258+
schema:
1259+
anyOf:
1260+
- type: string
1261+
- type: 'null'
1262+
title: X-Goog-Api-Client
12151263
x-codeSamples:
12161264
- lang: Python
12171265
label: OpenAI
@@ -1227,7 +1275,7 @@ paths:
12271275
get:
12281276
responses:
12291277
'200':
1230-
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or `x-goog-api-key` header for Google format.
1278+
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) for Google format.
12311279
content:
12321280
application/json:
12331281
schema:
@@ -1253,7 +1301,7 @@ paths:
12531301
tags:
12541302
- Models
12551303
summary: Get a model by its identifier.
1256-
description: Get a model by its identifier. Returns OpenAI, Anthropic, or Google response format based on SDK headers.
1304+
description: Get a model by its identifier. Returns OpenAI, Anthropic, or Google response format based on SDK detection headers.
12571305
operationId: get_model_v1_models__model_id__get
12581306
parameters:
12591307
- name: model_id
@@ -1280,6 +1328,22 @@ paths:
12801328
- type: string
12811329
- type: 'null'
12821330
title: X-Goog-Api-Key
1331+
- name: x-goog-user-project
1332+
in: header
1333+
required: false
1334+
schema:
1335+
anyOf:
1336+
- type: string
1337+
- type: 'null'
1338+
title: X-Goog-User-Project
1339+
- name: x-goog-api-client
1340+
in: header
1341+
required: false
1342+
schema:
1343+
anyOf:
1344+
- type: string
1345+
- type: 'null'
1346+
title: X-Goog-Api-Client
12831347
x-codeSamples:
12841348
- lang: Python
12851349
label: OpenAI

docs/static/ogx-spec.yaml

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1165,7 +1165,7 @@ paths:
11651165
get:
11661166
responses:
11671167
'200':
1168-
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or `x-goog-api-key` header for Google format.
1168+
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) for Google format.
11691169
content:
11701170
application/json:
11711171
schema:
@@ -1191,9 +1191,41 @@ paths:
11911191
tags:
11921192
- Models
11931193
summary: List models.
1194-
description: List models. Returns OpenAI, Anthropic, or Google response format based on SDK headers.
1194+
description: List models. Returns OpenAI, Anthropic, or Google response format based on SDK detection headers.
11951195
operationId: list_models_v1_models_get
11961196
parameters:
1197+
- name: before_id
1198+
in: query
1199+
required: false
1200+
schema:
1201+
anyOf:
1202+
- type: string
1203+
- type: 'null'
1204+
description: Return models before this model ID (Anthropic SDK format only).
1205+
title: Before Id
1206+
description: Return models before this model ID (Anthropic SDK format only).
1207+
- name: after_id
1208+
in: query
1209+
required: false
1210+
schema:
1211+
anyOf:
1212+
- type: string
1213+
- type: 'null'
1214+
description: Return models after this model ID (Anthropic SDK format only).
1215+
title: After Id
1216+
description: Return models after this model ID (Anthropic SDK format only).
1217+
- name: limit
1218+
in: query
1219+
required: false
1220+
schema:
1221+
anyOf:
1222+
- type: integer
1223+
maximum: 1000
1224+
minimum: 1
1225+
- type: 'null'
1226+
description: Maximum number of models to return (Anthropic SDK format only).
1227+
title: Limit
1228+
description: Maximum number of models to return (Anthropic SDK format only).
11971229
- name: anthropic-version
11981230
in: header
11991231
required: false
@@ -1210,6 +1242,22 @@ paths:
12101242
- type: string
12111243
- type: 'null'
12121244
title: X-Goog-Api-Key
1245+
- name: x-goog-user-project
1246+
in: header
1247+
required: false
1248+
schema:
1249+
anyOf:
1250+
- type: string
1251+
- type: 'null'
1252+
title: X-Goog-User-Project
1253+
- name: x-goog-api-client
1254+
in: header
1255+
required: false
1256+
schema:
1257+
anyOf:
1258+
- type: string
1259+
- type: 'null'
1260+
title: X-Goog-Api-Client
12131261
x-codeSamples:
12141262
- lang: Python
12151263
label: OpenAI
@@ -1225,7 +1273,7 @@ paths:
12251273
get:
12261274
responses:
12271275
'200':
1228-
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or `x-goog-api-key` header for Google format.
1276+
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) for Google format.
12291277
content:
12301278
application/json:
12311279
schema:
@@ -1251,7 +1299,7 @@ paths:
12511299
tags:
12521300
- Models
12531301
summary: Get a model by its identifier.
1254-
description: Get a model by its identifier. Returns OpenAI, Anthropic, or Google response format based on SDK headers.
1302+
description: Get a model by its identifier. Returns OpenAI, Anthropic, or Google response format based on SDK detection headers.
12551303
operationId: get_model_v1_models__model_id__get
12561304
parameters:
12571305
- name: model_id
@@ -1278,6 +1326,22 @@ paths:
12781326
- type: string
12791327
- type: 'null'
12801328
title: X-Goog-Api-Key
1329+
- name: x-goog-user-project
1330+
in: header
1331+
required: false
1332+
schema:
1333+
anyOf:
1334+
- type: string
1335+
- type: 'null'
1336+
title: X-Goog-User-Project
1337+
- name: x-goog-api-client
1338+
in: header
1339+
required: false
1340+
schema:
1341+
anyOf:
1342+
- type: string
1343+
- type: 'null'
1344+
title: X-Goog-Api-Client
12811345
x-codeSamples:
12821346
- lang: Python
12831347
label: OpenAI

docs/static/stainless-ogx-spec.yaml

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,7 +1167,7 @@ paths:
11671167
get:
11681168
responses:
11691169
'200':
1170-
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or `x-goog-api-key` header for Google format.
1170+
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) for Google format.
11711171
content:
11721172
application/json:
11731173
schema:
@@ -1193,9 +1193,41 @@ paths:
11931193
tags:
11941194
- Models
11951195
summary: List models.
1196-
description: List models. Returns OpenAI, Anthropic, or Google response format based on SDK headers.
1196+
description: List models. Returns OpenAI, Anthropic, or Google response format based on SDK detection headers.
11971197
operationId: list_models_v1_models_get
11981198
parameters:
1199+
- name: before_id
1200+
in: query
1201+
required: false
1202+
schema:
1203+
anyOf:
1204+
- type: string
1205+
- type: 'null'
1206+
description: Return models before this model ID (Anthropic SDK format only).
1207+
title: Before Id
1208+
description: Return models before this model ID (Anthropic SDK format only).
1209+
- name: after_id
1210+
in: query
1211+
required: false
1212+
schema:
1213+
anyOf:
1214+
- type: string
1215+
- type: 'null'
1216+
description: Return models after this model ID (Anthropic SDK format only).
1217+
title: After Id
1218+
description: Return models after this model ID (Anthropic SDK format only).
1219+
- name: limit
1220+
in: query
1221+
required: false
1222+
schema:
1223+
anyOf:
1224+
- type: integer
1225+
maximum: 1000
1226+
minimum: 1
1227+
- type: 'null'
1228+
description: Maximum number of models to return (Anthropic SDK format only).
1229+
title: Limit
1230+
description: Maximum number of models to return (Anthropic SDK format only).
11991231
- name: anthropic-version
12001232
in: header
12011233
required: false
@@ -1212,6 +1244,22 @@ paths:
12121244
- type: string
12131245
- type: 'null'
12141246
title: X-Goog-Api-Key
1247+
- name: x-goog-user-project
1248+
in: header
1249+
required: false
1250+
schema:
1251+
anyOf:
1252+
- type: string
1253+
- type: 'null'
1254+
title: X-Goog-User-Project
1255+
- name: x-goog-api-client
1256+
in: header
1257+
required: false
1258+
schema:
1259+
anyOf:
1260+
- type: string
1261+
- type: 'null'
1262+
title: X-Goog-Api-Client
12151263
x-codeSamples:
12161264
- lang: Python
12171265
label: OpenAI
@@ -1227,7 +1275,7 @@ paths:
12271275
get:
12281276
responses:
12291277
'200':
1230-
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or `x-goog-api-key` header for Google format.
1278+
description: Returns OpenAI format by default. Send `anthropic-version` header for Anthropic format, or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) for Google format.
12311279
content:
12321280
application/json:
12331281
schema:
@@ -1253,7 +1301,7 @@ paths:
12531301
tags:
12541302
- Models
12551303
summary: Get a model by its identifier.
1256-
description: Get a model by its identifier. Returns OpenAI, Anthropic, or Google response format based on SDK headers.
1304+
description: Get a model by its identifier. Returns OpenAI, Anthropic, or Google response format based on SDK detection headers.
12571305
operationId: get_model_v1_models__model_id__get
12581306
parameters:
12591307
- name: model_id
@@ -1280,6 +1328,22 @@ paths:
12801328
- type: string
12811329
- type: 'null'
12821330
title: X-Goog-Api-Key
1331+
- name: x-goog-user-project
1332+
in: header
1333+
required: false
1334+
schema:
1335+
anyOf:
1336+
- type: string
1337+
- type: 'null'
1338+
title: X-Goog-User-Project
1339+
- name: x-goog-api-client
1340+
in: header
1341+
required: false
1342+
schema:
1343+
anyOf:
1344+
- type: string
1345+
- type: 'null'
1346+
title: X-Goog-Api-Client
12831347
x-codeSamples:
12841348
- lang: Python
12851349
label: OpenAI

scripts/openapi_generator/multi_sdk.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
"description": (
3232
"Returns OpenAI format by default. "
3333
"Send `anthropic-version` header for Anthropic format, "
34-
"or `x-goog-api-key` header for Google format."
34+
"or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) "
35+
"for Google format."
3536
),
3637
},
3738
"/v1/models/{model_id}": {
@@ -43,7 +44,8 @@
4344
"description": (
4445
"Returns OpenAI format by default. "
4546
"Send `anthropic-version` header for Anthropic format, "
46-
"or `x-goog-api-key` header for Google format."
47+
"or any Google SDK header (`x-goog-api-key`, `x-goog-user-project`, `x-goog-api-client`) "
48+
"for Google format."
4749
),
4850
},
4951
}
@@ -69,6 +71,26 @@
6971
"The Google AI SDK sends this header automatically."
7072
),
7173
},
74+
{
75+
"name": "x-goog-user-project",
76+
"in": "header",
77+
"required": False,
78+
"schema": {"type": "string"},
79+
"description": (
80+
"When present, the response uses the Google Models API format. "
81+
"Google OAuth/ADC clients may send this header automatically."
82+
),
83+
},
84+
{
85+
"name": "x-goog-api-client",
86+
"in": "header",
87+
"required": False,
88+
"schema": {"type": "string"},
89+
"description": (
90+
"When present, the response uses the Google Models API format. "
91+
"Google SDKs may send this header automatically."
92+
),
93+
},
7294
]
7395

7496

0 commit comments

Comments
 (0)