pydantic_ai.models.huggingface
For details on how to set up authentication with this model, see model configuration for Hugging Face.
Bases: ModelSettings
Settings used for a Hugging Face model request.
Bases: Model
A model that uses Hugging Face Inference Providers.
Internally, this uses the HF Python client to interact with the API.
Apart from __init__, all methods are private or match those of the base class.
The base URL of the provider.
Type: str
The model name.
Type: HuggingFaceModelName
The system / model provider.
Type: str
def __init__(
model_name: str,
provider: Literal['huggingface'] | Provider[AsyncInferenceClient] = 'huggingface',
profile: ModelProfileSpec | None = None,
settings: ModelSettings | None = None,
)
Initialize a Hugging Face model.
model_name : str
The name of the Model to use. You can browse available models here.
provider : Literal[‘huggingface’] | Provider[AsyncInferenceClient] Default: 'huggingface'
The provider to use for Hugging Face Inference Providers. Can be either the string ‘huggingface’ or an
instance of Provider[AsyncInferenceClient]. If not provided, the other parameters will be used.
profile : ModelProfileSpec | None Default: None
The model profile to use. Defaults to a profile picked by the provider based on the model name.
settings : ModelSettings | None Default: None
Model-specific settings that will be used as defaults for this model.
Bases: StreamedResponse
Implementation of StreamedResponse for Hugging Face models.
Get the model name of the response.
Type: str
Get the provider name.
Type: str
Get the provider base URL.
Type: str
Get the timestamp of the response.
Type: datetime
Latest Hugging Face models.
Default: Literal['deepseek-ai/DeepSeek-R1', 'meta-llama/Llama-3.3-70B-Instruct', 'meta-llama/Llama-4-Maverick-17B-128E-Instruct', 'meta-llama/Llama-4-Scout-17B-16E-Instruct', 'Qwen/QwQ-32B', 'Qwen/Qwen2.5-72B-Instruct', 'Qwen/Qwen3-235B-A22B', 'Qwen/Qwen3-32B']
Possible Hugging Face model names.
You can browse available models here.
Default: str | LatestHuggingFaceModelNames