Skip to content

FallbackModel type annotations does not accept string as model leading to type checking issues #2563

@vikigenius

Description

@vikigenius

Initial Checks

Description

The Agent __init__ function and many other places now accept Model | KnownModelName | str

But the FallbackModel just accepts Model | KnownModelName it should also accept str

Example Code

from pydantic_ai.models.fallback import FallbackModel

model = FallbackModel('gpt-5', 'gpt-4o') # This would cause a type checker error until `gpt-5` was added to KnownModelName

Python, Pydantic AI & LLM client version

python 3.12
pydantic_ai 0.7.1

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions