Skip to content

Commit f78d2b0

Browse files
committed
test custom provider
1 parent 703c9b4 commit f78d2b0

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/models/test_model.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,17 @@ def test_infer_model(
251251
assert m2 is m
252252

253253

254+
def test_infer_model_with_provider():
255+
from pydantic_ai.providers import openai
256+
257+
provider_class = openai.OpenAIProvider(api_key='1234', base_url='http://test')
258+
m = infer_model('openai:gpt-5', lambda x: provider_class)
259+
260+
assert isinstance(m, OpenAIChatModel)
261+
assert m._provider is provider_class # type: ignore
262+
assert m._provider.base_url == 'http://test' # type: ignore
263+
264+
254265
def test_infer_str_unknown():
255266
with pytest.raises(UserError, match='Unknown model: foobar'):
256267
infer_model('foobar')

0 commit comments

Comments
 (0)