Skip to content

Commit 88f6e92

Browse files
authored
Add gateway/...:... to Known Model Names (#3593)
1 parent 0de174f commit 88f6e92

File tree

5 files changed

+234
-32
lines changed

5 files changed

+234
-32
lines changed

pydantic_ai_slim/pydantic_ai/models/__init__.py

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,196 @@
145145
'cohere:command-r7b-12-2024',
146146
'deepseek:deepseek-chat',
147147
'deepseek:deepseek-reasoner',
148+
'gateway/anthropic:claude-3-5-haiku-20241022',
149+
'gateway/anthropic:claude-3-5-haiku-latest',
150+
'gateway/anthropic:claude-3-7-sonnet-20250219',
151+
'gateway/anthropic:claude-3-7-sonnet-latest',
152+
'gateway/anthropic:claude-3-haiku-20240307',
153+
'gateway/anthropic:claude-3-opus-20240229',
154+
'gateway/anthropic:claude-3-opus-latest',
155+
'gateway/anthropic:claude-4-opus-20250514',
156+
'gateway/anthropic:claude-4-sonnet-20250514',
157+
'gateway/anthropic:claude-haiku-4-5',
158+
'gateway/anthropic:claude-haiku-4-5-20251001',
159+
'gateway/anthropic:claude-opus-4-0',
160+
'gateway/anthropic:claude-opus-4-1-20250805',
161+
'gateway/anthropic:claude-opus-4-20250514',
162+
'gateway/anthropic:claude-opus-4-5',
163+
'gateway/anthropic:claude-opus-4-5-20251101',
164+
'gateway/anthropic:claude-sonnet-4-0',
165+
'gateway/anthropic:claude-sonnet-4-20250514',
166+
'gateway/anthropic:claude-sonnet-4-5',
167+
'gateway/anthropic:claude-sonnet-4-5-20250929',
168+
'gateway/bedrock:amazon.titan-text-express-v1',
169+
'gateway/bedrock:amazon.titan-text-lite-v1',
170+
'gateway/bedrock:amazon.titan-tg1-large',
171+
'gateway/bedrock:anthropic.claude-3-5-haiku-20241022-v1:0',
172+
'gateway/bedrock:anthropic.claude-3-5-sonnet-20240620-v1:0',
173+
'gateway/bedrock:anthropic.claude-3-5-sonnet-20241022-v2:0',
174+
'gateway/bedrock:anthropic.claude-3-7-sonnet-20250219-v1:0',
175+
'gateway/bedrock:anthropic.claude-3-haiku-20240307-v1:0',
176+
'gateway/bedrock:anthropic.claude-3-opus-20240229-v1:0',
177+
'gateway/bedrock:anthropic.claude-3-sonnet-20240229-v1:0',
178+
'gateway/bedrock:anthropic.claude-haiku-4-5-20251001-v1:0',
179+
'gateway/bedrock:anthropic.claude-instant-v1',
180+
'gateway/bedrock:anthropic.claude-opus-4-20250514-v1:0',
181+
'gateway/bedrock:anthropic.claude-sonnet-4-20250514-v1:0',
182+
'gateway/bedrock:anthropic.claude-sonnet-4-5-20250929-v1:0',
183+
'gateway/bedrock:anthropic.claude-v2',
184+
'gateway/bedrock:anthropic.claude-v2:1',
185+
'gateway/bedrock:cohere.command-light-text-v14',
186+
'gateway/bedrock:cohere.command-r-plus-v1:0',
187+
'gateway/bedrock:cohere.command-r-v1:0',
188+
'gateway/bedrock:cohere.command-text-v14',
189+
'gateway/bedrock:eu.anthropic.claude-haiku-4-5-20251001-v1:0',
190+
'gateway/bedrock:eu.anthropic.claude-sonnet-4-20250514-v1:0',
191+
'gateway/bedrock:eu.anthropic.claude-sonnet-4-5-20250929-v1:0',
192+
'gateway/bedrock:global.anthropic.claude-opus-4-5-20251101-v1:0',
193+
'gateway/bedrock:meta.llama3-1-405b-instruct-v1:0',
194+
'gateway/bedrock:meta.llama3-1-70b-instruct-v1:0',
195+
'gateway/bedrock:meta.llama3-1-8b-instruct-v1:0',
196+
'gateway/bedrock:meta.llama3-70b-instruct-v1:0',
197+
'gateway/bedrock:meta.llama3-8b-instruct-v1:0',
198+
'gateway/bedrock:mistral.mistral-7b-instruct-v0:2',
199+
'gateway/bedrock:mistral.mistral-large-2402-v1:0',
200+
'gateway/bedrock:mistral.mistral-large-2407-v1:0',
201+
'gateway/bedrock:mistral.mixtral-8x7b-instruct-v0:1',
202+
'gateway/bedrock:us.amazon.nova-lite-v1:0',
203+
'gateway/bedrock:us.amazon.nova-micro-v1:0',
204+
'gateway/bedrock:us.amazon.nova-pro-v1:0',
205+
'gateway/bedrock:us.anthropic.claude-3-5-haiku-20241022-v1:0',
206+
'gateway/bedrock:us.anthropic.claude-3-5-sonnet-20240620-v1:0',
207+
'gateway/bedrock:us.anthropic.claude-3-5-sonnet-20241022-v2:0',
208+
'gateway/bedrock:us.anthropic.claude-3-7-sonnet-20250219-v1:0',
209+
'gateway/bedrock:us.anthropic.claude-3-haiku-20240307-v1:0',
210+
'gateway/bedrock:us.anthropic.claude-3-opus-20240229-v1:0',
211+
'gateway/bedrock:us.anthropic.claude-3-sonnet-20240229-v1:0',
212+
'gateway/bedrock:us.anthropic.claude-haiku-4-5-20251001-v1:0',
213+
'gateway/bedrock:us.anthropic.claude-opus-4-20250514-v1:0',
214+
'gateway/bedrock:us.anthropic.claude-sonnet-4-20250514-v1:0',
215+
'gateway/bedrock:us.anthropic.claude-sonnet-4-5-20250929-v1:0',
216+
'gateway/bedrock:us.meta.llama3-1-70b-instruct-v1:0',
217+
'gateway/bedrock:us.meta.llama3-1-8b-instruct-v1:0',
218+
'gateway/bedrock:us.meta.llama3-2-11b-instruct-v1:0',
219+
'gateway/bedrock:us.meta.llama3-2-1b-instruct-v1:0',
220+
'gateway/bedrock:us.meta.llama3-2-3b-instruct-v1:0',
221+
'gateway/bedrock:us.meta.llama3-2-90b-instruct-v1:0',
222+
'gateway/bedrock:us.meta.llama3-3-70b-instruct-v1:0',
223+
'gateway/google-vertex:gemini-2.0-flash',
224+
'gateway/google-vertex:gemini-2.0-flash-lite',
225+
'gateway/google-vertex:gemini-2.5-flash',
226+
'gateway/google-vertex:gemini-2.5-flash-image',
227+
'gateway/google-vertex:gemini-2.5-flash-lite',
228+
'gateway/google-vertex:gemini-2.5-flash-lite-preview-09-2025',
229+
'gateway/google-vertex:gemini-2.5-flash-preview-09-2025',
230+
'gateway/google-vertex:gemini-2.5-pro',
231+
'gateway/google-vertex:gemini-3-pro-image-preview',
232+
'gateway/google-vertex:gemini-3-pro-preview',
233+
'gateway/google-vertex:gemini-flash-latest',
234+
'gateway/google-vertex:gemini-flash-lite-latest',
235+
'gateway/groq:deepseek-r1-distill-llama-70b',
236+
'gateway/groq:deepseek-r1-distill-qwen-32b',
237+
'gateway/groq:distil-whisper-large-v3-en',
238+
'gateway/groq:gemma2-9b-it',
239+
'gateway/groq:llama-3.1-8b-instant',
240+
'gateway/groq:llama-3.2-11b-vision-preview',
241+
'gateway/groq:llama-3.2-1b-preview',
242+
'gateway/groq:llama-3.2-3b-preview',
243+
'gateway/groq:llama-3.2-90b-vision-preview',
244+
'gateway/groq:llama-3.3-70b-specdec',
245+
'gateway/groq:llama-3.3-70b-versatile',
246+
'gateway/groq:llama-guard-3-8b',
247+
'gateway/groq:llama3-70b-8192',
248+
'gateway/groq:llama3-8b-8192',
249+
'gateway/groq:mistral-saba-24b',
250+
'gateway/groq:moonshotai/kimi-k2-instruct',
251+
'gateway/groq:playai-tts',
252+
'gateway/groq:playai-tts-arabic',
253+
'gateway/groq:qwen-2.5-32b',
254+
'gateway/groq:qwen-2.5-coder-32b',
255+
'gateway/groq:qwen-qwq-32b',
256+
'gateway/groq:whisper-large-v3',
257+
'gateway/groq:whisper-large-v3-turbo',
258+
'gateway/openai:chatgpt-4o-latest',
259+
'gateway/openai:codex-mini-latest',
260+
'gateway/openai:computer-use-preview',
261+
'gateway/openai:computer-use-preview-2025-03-11',
262+
'gateway/openai:gpt-3.5-turbo',
263+
'gateway/openai:gpt-3.5-turbo-0125',
264+
'gateway/openai:gpt-3.5-turbo-0301',
265+
'gateway/openai:gpt-3.5-turbo-0613',
266+
'gateway/openai:gpt-3.5-turbo-1106',
267+
'gateway/openai:gpt-3.5-turbo-16k',
268+
'gateway/openai:gpt-3.5-turbo-16k-0613',
269+
'gateway/openai:gpt-4',
270+
'gateway/openai:gpt-4-0125-preview',
271+
'gateway/openai:gpt-4-0314',
272+
'gateway/openai:gpt-4-0613',
273+
'gateway/openai:gpt-4-1106-preview',
274+
'gateway/openai:gpt-4-32k',
275+
'gateway/openai:gpt-4-32k-0314',
276+
'gateway/openai:gpt-4-32k-0613',
277+
'gateway/openai:gpt-4-turbo',
278+
'gateway/openai:gpt-4-turbo-2024-04-09',
279+
'gateway/openai:gpt-4-turbo-preview',
280+
'gateway/openai:gpt-4-vision-preview',
281+
'gateway/openai:gpt-4.1',
282+
'gateway/openai:gpt-4.1-2025-04-14',
283+
'gateway/openai:gpt-4.1-mini',
284+
'gateway/openai:gpt-4.1-mini-2025-04-14',
285+
'gateway/openai:gpt-4.1-nano',
286+
'gateway/openai:gpt-4.1-nano-2025-04-14',
287+
'gateway/openai:gpt-4o',
288+
'gateway/openai:gpt-4o-2024-05-13',
289+
'gateway/openai:gpt-4o-2024-08-06',
290+
'gateway/openai:gpt-4o-2024-11-20',
291+
'gateway/openai:gpt-4o-audio-preview',
292+
'gateway/openai:gpt-4o-audio-preview-2024-10-01',
293+
'gateway/openai:gpt-4o-audio-preview-2024-12-17',
294+
'gateway/openai:gpt-4o-audio-preview-2025-06-03',
295+
'gateway/openai:gpt-4o-mini',
296+
'gateway/openai:gpt-4o-mini-2024-07-18',
297+
'gateway/openai:gpt-4o-mini-audio-preview',
298+
'gateway/openai:gpt-4o-mini-audio-preview-2024-12-17',
299+
'gateway/openai:gpt-4o-mini-search-preview',
300+
'gateway/openai:gpt-4o-mini-search-preview-2025-03-11',
301+
'gateway/openai:gpt-4o-search-preview',
302+
'gateway/openai:gpt-4o-search-preview-2025-03-11',
303+
'gateway/openai:gpt-5',
304+
'gateway/openai:gpt-5-2025-08-07',
305+
'gateway/openai:gpt-5-chat-latest',
306+
'gateway/openai:gpt-5-codex',
307+
'gateway/openai:gpt-5-mini',
308+
'gateway/openai:gpt-5-mini-2025-08-07',
309+
'gateway/openai:gpt-5-nano',
310+
'gateway/openai:gpt-5-nano-2025-08-07',
311+
'gateway/openai:gpt-5-pro',
312+
'gateway/openai:gpt-5-pro-2025-10-06',
313+
'gateway/openai:gpt-5.1',
314+
'gateway/openai:gpt-5.1-2025-11-13',
315+
'gateway/openai:gpt-5.1-chat-latest',
316+
'gateway/openai:gpt-5.1-codex',
317+
'gateway/openai:gpt-5.1-mini',
318+
'gateway/openai:o1',
319+
'gateway/openai:o1-2024-12-17',
320+
'gateway/openai:o1-mini',
321+
'gateway/openai:o1-mini-2024-09-12',
322+
'gateway/openai:o1-preview',
323+
'gateway/openai:o1-preview-2024-09-12',
324+
'gateway/openai:o1-pro',
325+
'gateway/openai:o1-pro-2025-03-19',
326+
'gateway/openai:o3',
327+
'gateway/openai:o3-2025-04-16',
328+
'gateway/openai:o3-deep-research',
329+
'gateway/openai:o3-deep-research-2025-06-26',
330+
'gateway/openai:o3-mini',
331+
'gateway/openai:o3-mini-2025-01-31',
332+
'gateway/openai:o3-pro',
333+
'gateway/openai:o3-pro-2025-06-10',
334+
'gateway/openai:o4-mini',
335+
'gateway/openai:o4-mini-2025-04-16',
336+
'gateway/openai:o4-mini-deep-research',
337+
'gateway/openai:o4-mini-deep-research-2025-06-26',
148338
'google-gla:gemini-flash-latest',
149339
'google-gla:gemini-flash-lite-latest',
150340
'google-gla:gemini-2.0-flash',

pydantic_ai_slim/pydantic_ai/providers/deepseek.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations as _annotations
22

33
import os
4-
from typing import overload
4+
from typing import Literal, overload
55

66
import httpx
77
from openai import AsyncOpenAI
@@ -22,6 +22,9 @@
2222
) from _import_error
2323

2424

25+
DeepSeekModelName = Literal['deepseek-chat', 'deepseek-reasoner']
26+
27+
2528
class DeepSeekProvider(Provider[AsyncOpenAI]):
2629
"""Provider for DeepSeek API."""
2730

pydantic_ai_slim/pydantic_ai/providers/gateway.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,17 @@ def gateway_provider(
9393
) -> Provider[Any]: ...
9494

9595

96-
UpstreamProvider = Literal[
96+
ModelProvider = Literal[
9797
'openai',
9898
'groq',
9999
'anthropic',
100100
'bedrock',
101101
'google-vertex',
102-
# Those are only API formats, but we still support them for convenience.
102+
]
103+
104+
105+
# These are only API flavors, we support them for convenience.
106+
APIFlavor = Literal[
103107
'openai-chat',
104108
'openai-responses',
105109
'chat',
@@ -108,6 +112,8 @@ def gateway_provider(
108112
'gemini',
109113
]
110114

115+
UpstreamProvider = ModelProvider | APIFlavor
116+
111117

112118
def gateway_provider(
113119
upstream_provider: UpstreamProvider | str,

tests/models/test_model_names.py

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from typing_extensions import TypedDict
99

1010
from pydantic_ai.models import KnownModelName
11+
from pydantic_ai.providers.gateway import ModelProvider as GatewayModelProvider
1112

1213
from ..conftest import try_import
1314

@@ -20,6 +21,7 @@
2021
from pydantic_ai.models.huggingface import HuggingFaceModelName
2122
from pydantic_ai.models.mistral import MistralModelName
2223
from pydantic_ai.models.openai import OpenAIModelName
24+
from pydantic_ai.providers.deepseek import DeepSeekModelName
2325
from pydantic_ai.providers.grok import GrokModelName
2426
from pydantic_ai.providers.moonshotai import MoonshotAIModelName
2527

@@ -49,6 +51,22 @@ def vcr_config(): # pragma: lax no cover
4951
}
5052

5153

54+
_PROVIDER_TO_MODEL_NAMES = {
55+
'anthropic': AnthropicModelName,
56+
'bedrock': BedrockModelName,
57+
'cohere': CohereModelName,
58+
'deepseek': DeepSeekModelName,
59+
'google-gla': GoogleModelName,
60+
'google-vertex': GoogleModelName,
61+
'grok': GrokModelName,
62+
'groq': GroqModelName,
63+
'huggingface': HuggingFaceModelName,
64+
'mistral': MistralModelName,
65+
'moonshotai': MoonshotAIModelName,
66+
'openai': OpenAIModelName,
67+
}
68+
69+
5270
def test_known_model_names(): # pragma: lax no cover
5371
# Coverage seems to be misbehaving..?
5472
def get_model_names(model_name_type: Any) -> Iterator[str]:
@@ -58,39 +76,23 @@ def get_model_names(model_name_type: Any) -> Iterator[str]:
5876
else:
5977
yield from get_model_names(arg)
6078

61-
anthropic_names = [f'anthropic:{n}' for n in get_model_names(AnthropicModelName)]
62-
cohere_names = [f'cohere:{n}' for n in get_model_names(CohereModelName)]
63-
google_names = [f'google-gla:{n}' for n in get_model_names(GoogleModelName)] + [
64-
f'google-vertex:{n}' for n in get_model_names(GoogleModelName)
79+
all_generated_names = [
80+
f'{provider}:{n}'
81+
for provider, model_names in _PROVIDER_TO_MODEL_NAMES.items()
82+
for n in get_model_names(model_names)
6583
]
66-
grok_names = [f'grok:{n}' for n in get_model_names(GrokModelName)]
67-
groq_names = [f'groq:{n}' for n in get_model_names(GroqModelName)]
68-
moonshotai_names = [f'moonshotai:{n}' for n in get_model_names(MoonshotAIModelName)]
69-
mistral_names = [f'mistral:{n}' for n in get_model_names(MistralModelName)]
70-
openai_names = [f'openai:{n}' for n in get_model_names(OpenAIModelName)]
71-
bedrock_names = [f'bedrock:{n}' for n in get_model_names(BedrockModelName)]
72-
deepseek_names = ['deepseek:deepseek-chat', 'deepseek:deepseek-reasoner']
73-
huggingface_names = [f'huggingface:{n}' for n in get_model_names(HuggingFaceModelName)]
74-
heroku_names = get_heroku_model_names()
84+
7585
cerebras_names = get_cerebras_model_names()
86+
heroku_names = get_heroku_model_names()
87+
gateway_names = [
88+
f'gateway/{provider}:{model_name}'
89+
for provider in GatewayModelProvider.__args__
90+
for model_name in get_model_names(_PROVIDER_TO_MODEL_NAMES[provider])
91+
]
92+
7693
extra_names = ['test']
7794

78-
generated_names = sorted(
79-
anthropic_names
80-
+ cohere_names
81-
+ google_names
82-
+ grok_names
83-
+ groq_names
84-
+ mistral_names
85-
+ moonshotai_names
86-
+ openai_names
87-
+ bedrock_names
88-
+ deepseek_names
89-
+ huggingface_names
90-
+ heroku_names
91-
+ cerebras_names
92-
+ extra_names
93-
)
95+
generated_names = sorted(all_generated_names + gateway_names + heroku_names + cerebras_names + extra_names)
9496

9597
known_model_names = sorted(get_args(KnownModelName.__value__))
9698
assert generated_names == known_model_names

tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ def test_list_models(capfd: CaptureFixture[str]):
144144
'mistral',
145145
'cohere',
146146
'deepseek',
147+
'gateway/',
147148
'heroku',
148149
'moonshotai',
149150
'grok',

0 commit comments

Comments
 (0)