pydantic-ai API reference
400 public APIs from pydantic-ai (pydantic/pydantic-ai) — 176 classes, 49 functions, 175 methods. Signatures extracted by static analysis of the actual source.
Repository: pydantic/pydantic-ai
| Kind | Count |
|---|---|
| Classes | 176 |
| Functions | 49 |
| Methods | 175 |
API list
func
.claude.skills.testing-skill.parse_cassette.parse_cassette(path:Path, interaction_idx:int | None=None) -> NoneParse and print cassette contents.
func
clai.clai.cli()Run the clai CLI and exit.
class
pydantic_ai_slim.pydantic_ai._agent_graph.AgentNodeThe base class for all agent nodes.
class
pydantic_ai_slim.pydantic_ai._agent_graph.GraphAgentDepsDependencies/config passed to the agent graph.
class
pydantic_ai_slim.pydantic_ai._agent_graph.GraphAgentStateState kept across the execution of the agent graph.
func
pydantic_ai_slim.pydantic_ai._agent_graph.resolve_run_id(explicit:str | None, message_history:Sequence[_messages.ModelMessage] | None) -> strResolve the `run_id` to use for an agent run.
class
pydantic_ai_slim.pydantic_ai._cancel.RunBindingBridge an `AgentRunEvents` handle to the run it starts.
method
pydantic_ai_slim.pydantic_ai._cancel.RunCancellation.bind(task:asyncio.Task[object] | None=None) -> NoneBind the task that is currently driving the run.
method
pydantic_ai_slim.pydantic_ai._cancel.RunCancellation.cancel() -> NoneRequest cancellation of the run from any thread.
class
pydantic_ai_slim.pydantic_ai._cli.SimpleCodeBlockCustomized code blocks in markdown.
func
pydantic_ai_slim.pydantic_ai._cli.cli(args_list:Sequence[str] | None=None, *prog_name:str='clai', *default_model:str='openai:gpt-5') -> intRun the CLI and return the exit code for the process.
func
pydantic_ai_slim.pydantic_ai._cli.cli_exit(prog_name:str='clai')Run the CLI and exit.
func
pydantic_ai_slim.pydantic_ai._cli.load_agent(agent_path:str) -> Agent[Any, Any] | NoneLoad an agent from a module path or a YAML/JSON spec file.
class
pydantic_ai_slim.pydantic_ai._function_schema.FunctionSchemaInternal information about a function schema.
class
pydantic_ai_slim.pydantic_ai._json_schema.InlineDefsJsonSchemaTransformerTransforms the JSON Schema to inline $defs.
class
pydantic_ai_slim.pydantic_ai._run_context.RunContextInformation about the current call.
method
pydantic_ai_slim.pydantic_ai._run_context.RunContext.cancel() -> NoneCancel the agent run this context belongs to.
func
pydantic_ai_slim.pydantic_ai._run_context.set_current_run_context(run_context:RunContext[Any]) -> Generator[None]Context manager to set the current run context.
class
pydantic_ai_slim.pydantic_ai._ssrf.ResolvedUrlResult of URL validation and DNS resolution.
func
pydantic_ai_slim.pydantic_ai._ssrf.is_private_ip(ip_str:str) -> boolCheck if an IP address is in a private/internal range.
func
pydantic_ai_slim.pydantic_ai._ssrf.resolve_hostname(hostname:str) -> list[str]Resolve a hostname to its IP addresses using DNS.
func
pydantic_ai_slim.pydantic_ai._ssrf.resolve_redirect_url(current_url:str, location:str) -> strResolve a redirect location against the current URL.
func
pydantic_ai_slim.pydantic_ai._ssrf.validate_and_resolve_url(url:str, allow_local:bool) -> ResolvedUrlValidate URL and resolve hostname to IP addresses.
class
pydantic_ai_slim.pydantic_ai._tool_search.ToolSearchArgsTyped arguments for a tool-search call.
class
pydantic_ai_slim.pydantic_ai._tool_search.ToolSearchMatchA single match in a tool-search result.
class
pydantic_ai_slim.pydantic_ai._utils.SomeAnalogous to Rust's `Option::Some` type.
class
pydantic_ai_slim.pydantic_ai._utils.UnsetA singleton to represent an unset value.
func
pydantic_ai_slim.pydantic_ai._utils.aclose_if_supported(stream:AsyncIterable[Any]) -> NoneClose an async iterable if it exposes an `aclose` method.
func
pydantic_ai_slim.pydantic_ai._utils.dataclasses_no_defaults_repr(self:Any) -> strExclude fields with values equal to the field default.
func
pydantic_ai_slim.pydantic_ai._utils.generate_tool_call_id() -> strGenerate a tool call id.
func
pydantic_ai_slim.pydantic_ai._utils.is_model_like(type_:Any) -> boolCheck if something is a pydantic model, dataclass or typedict.
func
pydantic_ai_slim.pydantic_ai._utils.is_str_dict(obj:Any) -> TypeGuard[dict[str, Any]]Check if obj is a dict, narrowing the type to `dict[str, Any]`.
func
pydantic_ai_slim.pydantic_ai._utils.is_text_like_media_type(media_type:str) -> boolCheck if a media type represents text-like content.
func
pydantic_ai_slim.pydantic_ai._utils.sanitize_tool_name(name:str) -> strReplace characters outside `[a-zA-Z0-9_-]` with `_`.
func
pydantic_ai_slim.pydantic_ai._uuid.uuid7() -> uuid.UUIDGenerate a UUIDv7 (time-sortable UUID) per RFC 9562.
class
pydantic_ai_slim.pydantic_ai._warnings.CostCalculationFailedWarningWarning raised when cost calculation fails.
class
pydantic_ai_slim.pydantic_ai._warnings.CostNotFoundWarningWarning raised when cost is not found.
method
pydantic_ai_slim.pydantic_ai.agent.Agent.deps_type() -> typeThe type of dependencies used by the agent.
method
pydantic_ai_slim.pydantic_ai.agent.Agent.description() -> str | NoneA human-readable description of the agent.
method
pydantic_ai_slim.pydantic_ai.agent.Agent.name() -> str | NoneThe name of the agent, used for logging.
func
pydantic_ai_slim.pydantic_ai.agent.abstract.AbstractAgent.on_complete() -> NoneCalled when the stream has completed.
method
pydantic_ai_slim.pydantic_ai.agent.spec.AgentSpec.from_dict(data:dict[str, Any]) -> AgentSpecValidate a dictionary into an AgentSpec.
method
pydantic_ai_slim.pydantic_ai.agent.spec.AgentSpec.from_file(path:Path | str, fmt:Literal['yaml', 'json'] | None=None) -> AgentSpecLoad an agent spec from a YAML or JSON file.
method
pydantic_ai_slim.pydantic_ai.agent.spec.AgentSpec.from_text(text:str, fmt:Literal['yaml', 'json']='yaml') -> AgentSpecParse YAML or JSON text into an AgentSpec.
class
pydantic_ai_slim.pydantic_ai.agent.wrapper.WrapperAgentAgent which wraps another agent.
class
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapabilityAbstract base class for agent capabilities.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.after_tool_validate(ctx:RunContext[AgentDepsT], *call:ToolCallPart, *tool_def:ToolDefinition, *args:ValidatedToolArgs) -> ValidatedToolArgsModify validated args.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.before_run(ctx:RunContext[AgentDepsT]) -> NoneCalled before the agent run starts.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.from_spec(*args:Any, **kwargs:Any) -> AbstractCapability[Any]Create from spec arguments.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.wrap_model_request(ctx:RunContext[AgentDepsT], *request_context:ModelRequestContext, *handler:WrapModelRequestHandler) -> ModelResponseWraps the model request.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.wrap_output_process(ctx:RunContext[AgentDepsT], *output_context:OutputContext, *output:Any, *handler:WrapOutputProcessHandler) -> AnyWraps output processing.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.wrap_output_validate(ctx:RunContext[AgentDepsT], *output_context:OutputContext, *output:RawOutput, *handler:WrapOutputValidateHandler) -> AnyWraps output validation.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.wrap_run(ctx:RunContext[AgentDepsT], *handler:WrapRunHandler) -> AgentRunResult[Any]Wraps the entire agent run.
method
pydantic_ai_slim.pydantic_ai.capabilities.abstract.AbstractCapability.wrap_tool_execute(ctx:RunContext[AgentDepsT], *call:ToolCallPart, *tool_def:ToolDefinition, *args:ValidatedToolArgs, *handler:WrapToolExecuteHandler) -> AnyWraps tool execution.
class
pydantic_ai_slim.pydantic_ai.capabilities.image_generation.ImageGenerationImage generation capability.
class
pydantic_ai_slim.pydantic_ai.capabilities.mcp.MCPMCP server capability.
class
pydantic_ai_slim.pydantic_ai.capabilities.thinking.ThinkingEnables and configures model thinking/reasoning.
class
pydantic_ai_slim.pydantic_ai.capabilities.toolset.ToolsetA capability that provides a toolset.
class
pydantic_ai_slim.pydantic_ai.capabilities.web_fetch.WebFetchURL fetching capability.
class
pydantic_ai_slim.pydantic_ai.capabilities.web_search.WebSearchWeb search capability.
class
pydantic_ai_slim.pydantic_ai.capabilities.x_search.XSearchX (Twitter) search capability.
class
pydantic_ai_slim.pydantic_ai.common_tools.duckduckgo.DuckDuckGoResultA DuckDuckGo search result.
class
pydantic_ai_slim.pydantic_ai.common_tools.duckduckgo.DuckDuckGoSearchToolThe DuckDuckGo search tool.
class
pydantic_ai_slim.pydantic_ai.common_tools.exa.ExaAnswerResultAn Exa answer result with citations.
class
pydantic_ai_slim.pydantic_ai.common_tools.exa.ExaAnswerToolThe Exa answer tool.
class
pydantic_ai_slim.pydantic_ai.common_tools.exa.ExaContentResultContent retrieved from a URL.
class
pydantic_ai_slim.pydantic_ai.common_tools.exa.ExaFindSimilarToolThe Exa find similar tool.
class
pydantic_ai_slim.pydantic_ai.common_tools.exa.ExaGetContentsToolThe Exa get contents tool.
class
pydantic_ai_slim.pydantic_ai.common_tools.exa.ExaSearchResultAn Exa search result with content.
class
pydantic_ai_slim.pydantic_ai.common_tools.exa.ExaSearchToolThe Exa search tool.
class
pydantic_ai_slim.pydantic_ai.common_tools.tavily.TavilySearchResultA Tavily search result.
class
pydantic_ai_slim.pydantic_ai.common_tools.tavily.TavilySearchToolThe Tavily search tool.
class
pydantic_ai_slim.pydantic_ai.common_tools.web_fetch.WebFetchResultResult of fetching a web page.
class
pydantic_ai_slim.pydantic_ai.concurrency.AbstractConcurrencyLimiterAbstract base class for concurrency limiters.
method
pydantic_ai_slim.pydantic_ai.concurrency.AbstractConcurrencyLimiter.acquire(source:str) -> NoneAcquire a slot, waiting if necessary.
method
pydantic_ai_slim.pydantic_ai.concurrency.AbstractConcurrencyLimiter.release() -> NoneRelease a slot.
class
pydantic_ai_slim.pydantic_ai.durable_exec.dbos._utils.StepConfigConfiguration for a step in the DBOS workflow.
class
pydantic_ai_slim.pydantic_ai.durable_exec.prefect._types.TaskConfigConfiguration for a task in Prefect.
class
pydantic_ai_slim.pydantic_ai.durable_exec.temporal._logfire.LogfirePluginTemporal client plugin for Logfire.
class
pydantic_ai_slim.pydantic_ai.embeddings.EmbedderHigh-level interface for generating text embeddings.
method
pydantic_ai_slim.pydantic_ai.embeddings.Embedder.count_tokens(text:str) -> intCount the number of tokens in the given text.
method
pydantic_ai_slim.pydantic_ai.embeddings.Embedder.embed_documents(documents:str | Sequence[str], *settings:EmbeddingSettings | None=None) -> EmbeddingResultEmbed one or more document texts.
method
pydantic_ai_slim.pydantic_ai.embeddings.Embedder.embed_query(query:str | Sequence[str], *settings:EmbeddingSettings | None=None) -> EmbeddingResultEmbed one or more query texts.
class
pydantic_ai_slim.pydantic_ai.embeddings.base.EmbeddingModelAbstract base class for embedding models.
method
pydantic_ai_slim.pydantic_ai.embeddings.base.EmbeddingModel.count_tokens(text:str) -> intCount the number of tokens in the given text.
method
pydantic_ai_slim.pydantic_ai.embeddings.base.EmbeddingModel.model_name() -> strThe name of the embedding model.
method
pydantic_ai_slim.pydantic_ai.embeddings.base.EmbeddingModel.settings() -> EmbeddingSettings | NoneGet the default settings for this model.
class
pydantic_ai_slim.pydantic_ai.embeddings.bedrock.BedrockEmbeddingModelBedrock embedding model implementation.
method
pydantic_ai_slim.pydantic_ai.embeddings.bedrock.BedrockEmbeddingModel.base_url() -> strThe base URL for the provider API.
method
pydantic_ai_slim.pydantic_ai.embeddings.bedrock.BedrockEmbeddingModel.model_name() -> BedrockEmbeddingModelNameThe embedding model name.
method
pydantic_ai_slim.pydantic_ai.embeddings.bedrock.BedrockEmbeddingModel.system() -> strThe embedding model provider.
class
pydantic_ai_slim.pydantic_ai.embeddings.cohere.CohereEmbeddingModelCohere embedding model implementation.
method
pydantic_ai_slim.pydantic_ai.embeddings.cohere.CohereEmbeddingModel.model_name() -> CohereEmbeddingModelNameThe embedding model name.
method
pydantic_ai_slim.pydantic_ai.embeddings.cohere.CohereEmbeddingModel.system() -> strThe embedding model provider.
class
pydantic_ai_slim.pydantic_ai.embeddings.google.GoogleEmbeddingModelGoogle embedding model implementation.
method
pydantic_ai_slim.pydantic_ai.embeddings.google.GoogleEmbeddingModel.model_name() -> GoogleEmbeddingModelNameThe embedding model name.
method
pydantic_ai_slim.pydantic_ai.embeddings.google.GoogleEmbeddingModel.system() -> strThe embedding model provider.
func
pydantic_ai_slim.pydantic_ai.embeddings.infer_embedding_model(model:EmbeddingModel | KnownEmbeddingModelName | str, *provider_factory:Callable[[str], Provider[Any]]=infer_provider) -> EmbeddingModelInfer the model from the name.
class
pydantic_ai_slim.pydantic_ai.embeddings.openai.OpenAIEmbeddingModelOpenAI embedding model implementation.
method
pydantic_ai_slim.pydantic_ai.embeddings.openai.OpenAIEmbeddingModel.model_name() -> OpenAIEmbeddingModelNameThe embedding model name.
method
pydantic_ai_slim.pydantic_ai.embeddings.openai.OpenAIEmbeddingModel.system() -> strThe embedding model provider.
class
pydantic_ai_slim.pydantic_ai.embeddings.result.EmbeddingResultThe result of an embedding operation.
class
pydantic_ai_slim.pydantic_ai.embeddings.test.TestEmbeddingModelA mock embedding model for testing.
method
pydantic_ai_slim.pydantic_ai.embeddings.test.TestEmbeddingModel.model_name() -> strThe embedding model name.
method
pydantic_ai_slim.pydantic_ai.embeddings.test.TestEmbeddingModel.system() -> strThe embedding model provider.
class
pydantic_ai_slim.pydantic_ai.embeddings.voyageai.VoyageAIEmbeddingModelVoyageAI embedding model implementation.
method
pydantic_ai_slim.pydantic_ai.embeddings.voyageai.VoyageAIEmbeddingModel.base_url() -> strThe base URL for the provider API.
method
pydantic_ai_slim.pydantic_ai.embeddings.voyageai.VoyageAIEmbeddingModel.model_name() -> VoyageAIEmbeddingModelNameThe embedding model name.
method
pydantic_ai_slim.pydantic_ai.embeddings.voyageai.VoyageAIEmbeddingModel.system() -> strThe embedding model provider.
class
pydantic_ai_slim.pydantic_ai.exceptions.AgentRunErrorBase class for errors occurring during an agent run.
class
pydantic_ai_slim.pydantic_ai.exceptions.ModelAPIErrorRaised when a model provider API request fails.
class
pydantic_ai_slim.pydantic_ai.exceptions.ModelRetryException to raise to request a model retry.
class
pydantic_ai_slim.pydantic_ai.exceptions.UnexpectedModelBehaviorError caused by unexpected Model behavior, e.g.
class
pydantic_ai_slim.pydantic_ai.exceptions.UserErrorError caused by a usage mistake by the application developer — You!
class
pydantic_ai_slim.pydantic_ai.ext.langchain.LangChainToolsetA toolset that wraps LangChain tools.
func
pydantic_ai_slim.pydantic_ai.ext.langchain.tool_from_langchain(langchain_tool:LangChainTool) -> ToolCreates a Pydantic AI tool proxy from a LangChain tool.
func
pydantic_ai_slim.pydantic_ai.format_prompt.format_as_xml(obj:Any, root_tag:str | None=None, item_tag:str='item', none_str:str='null', indent:str | None=' ', include_field_info:Literal['once'] | bool=False) -> strFormat a Python object as XML.
class
pydantic_ai_slim.pydantic_ai.function_signature.FunctionParamA single parameter in a function signature.
class
pydantic_ai_slim.pydantic_ai.mcp.BaseResourceBase class for MCP resources.
class
pydantic_ai_slim.pydantic_ai.mcp.EmbeddedResourceA resource embedded into a prompt or tool call result.
class
pydantic_ai_slim.pydantic_ai.mcp.IconAn icon for display in user interfaces.
class
pydantic_ai_slim.pydantic_ai.mcp.MCPErrorRaised when an MCP server returns an error response.
method
pydantic_ai_slim.pydantic_ai.mcp.MCPError.from_mcp_sdk(error:mcp_exceptions.McpError) -> MCPErrorCreate an MCPError from an MCP SDK McpError.
class
pydantic_ai_slim.pydantic_ai.mcp.MCPToolsetA toolset for connecting to an MCP server.
method
pydantic_ai_slim.pydantic_ai.mcp.MCPToolset.direct_call_tool(name:str, args:dict[str, Any], *metadata:dict[str, Any] | None=None, *use_task:bool=False) -> AnyCall a tool on the server directly.
class
pydantic_ai_slim.pydantic_ai.mcp.PromptA prompt or prompt template that the server offers.
method
pydantic_ai_slim.pydantic_ai.mcp.Prompt.from_mcp_sdk(mcp_prompt:mcp_types.Prompt) -> PromptConvert from MCP SDK Prompt to PydanticAI Prompt.
class
pydantic_ai_slim.pydantic_ai.mcp.PromptArgumentAn argument for a prompt template.
class
pydantic_ai_slim.pydantic_ai.mcp.PromptMessageA message returned as part of a prompt result.
class
pydantic_ai_slim.pydantic_ai.mcp.ResourceA resource that can be read from an MCP server.
method
pydantic_ai_slim.pydantic_ai.mcp.Resource.from_mcp_sdk(mcp_resource:mcp_types.Resource) -> ResourceConvert from MCP SDK Resource to PydanticAI Resource.
class
pydantic_ai_slim.pydantic_ai.mcp.ResourceAnnotationsAdditional properties describing MCP entities.
class
pydantic_ai_slim.pydantic_ai.mcp.ServerCapabilitiesCapabilities that an MCP server supports.
func
pydantic_ai_slim.pydantic_ai.mcp.load_mcp_toolsets(config_path:str | Path) -> list[AbstractToolset[Any]]Load `MCPToolset`s from a configuration file.
class
pydantic_ai_slim.pydantic_ai.messages.AudioUrlA URL to an audio file.
method
pydantic_ai_slim.pydantic_ai.messages.AudioUrl.format() -> AudioFormatThe file format of the audio file.
class
pydantic_ai_slim.pydantic_ai.messages.BaseToolCallPartA tool call from a model.
method
pydantic_ai_slim.pydantic_ai.messages.BaseToolCallPart.args_as_dict(*raise_if_invalid:bool=False) -> dict[str, Any]Return the arguments as a Python dictionary.
method
pydantic_ai_slim.pydantic_ai.messages.BaseToolCallPart.args_as_json_str() -> strReturn the arguments as a JSON string.
method
pydantic_ai_slim.pydantic_ai.messages.BaseToolCallPart.has_content() -> boolReturn `True` if the tool call has content.
class
pydantic_ai_slim.pydantic_ai.messages.BaseToolReturnPartBase class for tool return parts.
method
pydantic_ai_slim.pydantic_ai.messages.BaseToolReturnPart.has_content() -> boolReturn `True` if the tool return has content.
class
pydantic_ai_slim.pydantic_ai.messages.BinaryContentBinary content, e.g.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.base64() -> strReturn the binary data as a base64-encoded string.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.data_uri() -> strConvert the `BinaryContent` to a data URI.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.format() -> strThe file format of the binary content.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.from_data_uri(data_uri:str) -> BinaryContentCreate a `BinaryContent` from a data URI.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.from_path(path:PathLike[str]) -> BinaryContentCreate a `BinaryContent` from a path.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.is_audio() -> boolReturn `True` if the media type is an audio type.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.is_image() -> boolReturn `True` if the media type is an image type.
method
pydantic_ai_slim.pydantic_ai.messages.BinaryContent.is_video() -> boolReturn `True` if the media type is a video type.
class
pydantic_ai_slim.pydantic_ai.messages.BinaryImageBinary content that's guaranteed to be an image.
class
pydantic_ai_slim.pydantic_ai.messages.CachePointA cache point marker for prompt caching.
class
pydantic_ai_slim.pydantic_ai.messages.DocumentUrlThe URL of the document.
method
pydantic_ai_slim.pydantic_ai.messages.DocumentUrl.format() -> DocumentFormatThe file format of the document.
class
pydantic_ai_slim.pydantic_ai.messages.FilePartA file response from a model.
method
pydantic_ai_slim.pydantic_ai.messages.FilePart.has_content() -> boolReturn `True` if the file content is non-empty.
class
pydantic_ai_slim.pydantic_ai.messages.FileUrlAbstract base class for any URL-based file.
method
pydantic_ai_slim.pydantic_ai.messages.FileUrl.format() -> strThe file format.
method
pydantic_ai_slim.pydantic_ai.messages.FileUrl.identifier() -> strThe identifier of the file, such as a unique ID.
class
pydantic_ai_slim.pydantic_ai.messages.ImageUrlA URL to an image.
method
pydantic_ai_slim.pydantic_ai.messages.ImageUrl.format() -> ImageFormatThe file format of the image.
class
pydantic_ai_slim.pydantic_ai.messages.ModelResponseA response from a model, e.g.
method
pydantic_ai_slim.pydantic_ai.messages.ModelResponse.cost() -> genai_types.PriceCalculationCalculate the cost of the usage.
method
pydantic_ai_slim.pydantic_ai.messages.ModelResponse.files() -> list[BinaryContent]Get the files in the response.
method
pydantic_ai_slim.pydantic_ai.messages.ModelResponse.images() -> list[BinaryImage]Get the images in the response.
method
pydantic_ai_slim.pydantic_ai.messages.ModelResponse.text() -> str | NoneGet the text in the response.
method
pydantic_ai_slim.pydantic_ai.messages.ModelResponse.thinking() -> str | NoneGet the thinking in the response.
method
pydantic_ai_slim.pydantic_ai.messages.ModelResponse.tool_calls() -> list[ToolCallPart]Get the tool calls in the response.
class
pydantic_ai_slim.pydantic_ai.messages.NativeToolCallPartA tool call to a native tool.
class
pydantic_ai_slim.pydantic_ai.messages.NativeToolReturnPartA tool return message from a native tool.
class
pydantic_ai_slim.pydantic_ai.messages.PartEndEventAn event indicating that a part is complete.
class
pydantic_ai_slim.pydantic_ai.messages.PartStartEventAn event indicating that a new part has started.
class
pydantic_ai_slim.pydantic_ai.messages.RetryPromptPartA message back to a model asking it to try again.
class
pydantic_ai_slim.pydantic_ai.messages.TextContentString content that is tagged with additional metadata.
class
pydantic_ai_slim.pydantic_ai.messages.TextPartA plain text response from a model.
method
pydantic_ai_slim.pydantic_ai.messages.TextPart.has_content() -> boolReturn `True` if the text content is non-empty.
class
pydantic_ai_slim.pydantic_ai.messages.ThinkingPartA thinking response from a model.
class
pydantic_ai_slim.pydantic_ai.messages.ToolCallPartA tool call from a model.
method
pydantic_ai_slim.pydantic_ai.messages.UploadedFile.format() -> strA general-purpose media-type-to-format mapping.
method
pydantic_ai_slim.pydantic_ai.messages.UploadedFile.identifier() -> strThe identifier of the file, such as a unique ID.
class
pydantic_ai_slim.pydantic_ai.messages.UserPromptPartA user prompt, generally written by the end user.
class
pydantic_ai_slim.pydantic_ai.messages.VideoUrlA URL to a video.
method
pydantic_ai_slim.pydantic_ai.messages.VideoUrl.format() -> VideoFormatThe file format of the video.
method
pydantic_ai_slim.pydantic_ai.messages.VideoUrl.is_youtube() -> boolTrue if the URL has a YouTube domain.
class
pydantic_ai_slim.pydantic_ai.models.DownloadedItemThe downloaded data and its type.
class
pydantic_ai_slim.pydantic_ai.models.ModelAbstract class for a model.
method
pydantic_ai_slim.pydantic_ai.models.Model.base_url() -> str | NoneThe base URL for the provider API, if available.
method
pydantic_ai_slim.pydantic_ai.models.Model.label() -> strHuman-friendly display label for the model.
method
pydantic_ai_slim.pydantic_ai.models.Model.model_name() -> strThe model name.
method
pydantic_ai_slim.pydantic_ai.models.Model.profile() -> ModelProfileThe model profile.
method
pydantic_ai_slim.pydantic_ai.models.Model.provider() -> Provider[InterfaceClient] | NoneThe provider for this model, if any.
method
pydantic_ai_slim.pydantic_ai.models.Model.request(messages:list[ModelMessage], model_settings:ModelSettings | None, model_request_parameters:ModelRequestParameters) -> ModelResponseMake a request to the model.
method
pydantic_ai_slim.pydantic_ai.models.Model.settings() -> ModelSettings | NoneGet the model settings.
method
pydantic_ai_slim.pydantic_ai.models.Model.system() -> strThe model provider, ex: openai.
class
pydantic_ai_slim.pydantic_ai.models.ModelRequestContextContext for model request hooks.
class
pydantic_ai_slim.pydantic_ai.models.StreamedResponseStreamed response from an LLM when calling a tool.
method
pydantic_ai_slim.pydantic_ai.models.StreamedResponse.cancel() -> NoneCancel the stream, stopping token generation.
method
pydantic_ai_slim.pydantic_ai.models.StreamedResponse.close_stream() -> NoneClose the underlying HTTP/gRPC connection.
method
pydantic_ai_slim.pydantic_ai.models.StreamedResponse.model_name() -> strGet the model name of the response.
method
pydantic_ai_slim.pydantic_ai.models.StreamedResponse.provider_name() -> str | NoneGet the provider name.
method
pydantic_ai_slim.pydantic_ai.models.StreamedResponse.provider_url() -> str | NoneGet the provider base URL.
method
pydantic_ai_slim.pydantic_ai.models.StreamedResponse.timestamp() -> datetimeGet the timestamp of the response.
method
pydantic_ai_slim.pydantic_ai.models.StreamedResponse.usage() -> RequestUsageGet the usage of the response so far.
class
pydantic_ai_slim.pydantic_ai.models.anthropic.AnthropicCompactionCompaction capability for Anthropic models.
class
pydantic_ai_slim.pydantic_ai.models.anthropic.AnthropicModelA model that uses the Anthropic API.
method
pydantic_ai_slim.pydantic_ai.models.anthropic.AnthropicModel.model_name() -> AnthropicModelNameThe model name.
method
pydantic_ai_slim.pydantic_ai.models.anthropic.AnthropicModel.profile() -> AnthropicModelProfileThe model profile.
method
pydantic_ai_slim.pydantic_ai.models.anthropic.AnthropicModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.anthropic.AnthropicModelSettingsSettings used for an Anthropic model request.
class
pydantic_ai_slim.pydantic_ai.models.bedrock.BedrockConverseModelA model that uses the Bedrock Converse API.
method
pydantic_ai_slim.pydantic_ai.models.bedrock.BedrockConverseModel.model_name() -> strThe model name.
method
pydantic_ai_slim.pydantic_ai.models.bedrock.BedrockConverseModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.bedrock.BedrockModelSettingsSettings for Bedrock models.
class
pydantic_ai_slim.pydantic_ai.models.cerebras.CerebrasModelA model that uses Cerebras's OpenAI-compatible API.
class
pydantic_ai_slim.pydantic_ai.models.cerebras.CerebrasModelSettingsSettings used for a Cerebras model request.
func
pydantic_ai_slim.pydantic_ai.models.check_allow_model_requests() -> NoneCheck if model requests are allowed.
class
pydantic_ai_slim.pydantic_ai.models.cohere.CohereModelA model that uses the Cohere API.
method
pydantic_ai_slim.pydantic_ai.models.cohere.CohereModel.model_name() -> CohereModelNameThe model name.
method
pydantic_ai_slim.pydantic_ai.models.cohere.CohereModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.cohere.CohereModelSettingsSettings used for a Cohere model request.
func
pydantic_ai_slim.pydantic_ai.models.concurrency.limit_model_concurrency(model:Model | KnownModelName, limiter:AnyConcurrencyLimit) -> ModelWrap a model with concurrency limiting.
func
pydantic_ai_slim.pydantic_ai.models.create_async_http_client(*timeout:int=DEFAULT_HTTP_TIMEOUT, *connect:int=5) -> httpx.AsyncClientCreate an HTTPX async client.
class
pydantic_ai_slim.pydantic_ai.models.function.AgentInfoInformation about an agent.
class
pydantic_ai_slim.pydantic_ai.models.function.DeltaThinkingPartIncremental change to a thinking part.
class
pydantic_ai_slim.pydantic_ai.models.function.DeltaToolCallIncremental change to a tool call.
class
pydantic_ai_slim.pydantic_ai.models.function.FunctionModelA model controlled by a local function.
method
pydantic_ai_slim.pydantic_ai.models.function.FunctionModel.model_name() -> strThe model name.
method
pydantic_ai_slim.pydantic_ai.models.function.FunctionModel.system() -> strThe system / model provider.
func
pydantic_ai_slim.pydantic_ai.models.get_user_agent() -> strGet the user agent string for the HTTP client.
class
pydantic_ai_slim.pydantic_ai.models.google.GoogleModelSettingsSettings used for a Gemini model request.
class
pydantic_ai_slim.pydantic_ai.models.groq.GroqModelA model that uses the Groq API.
method
pydantic_ai_slim.pydantic_ai.models.groq.GroqModel.model_name() -> GroqModelNameThe model name.
method
pydantic_ai_slim.pydantic_ai.models.groq.GroqModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.groq.GroqModelSettingsSettings used for a Groq model request.
method
pydantic_ai_slim.pydantic_ai.models.huggingface.HuggingFaceModel.base_url() -> strThe base URL of the provider.
method
pydantic_ai_slim.pydantic_ai.models.huggingface.HuggingFaceModel.model_name() -> HuggingFaceModelNameThe model name.
method
pydantic_ai_slim.pydantic_ai.models.huggingface.HuggingFaceModel.system() -> strThe system / model provider.
func
pydantic_ai_slim.pydantic_ai.models.infer_model(model:Model | KnownModelName | str, provider_factory:Callable[[str], Provider[Any]]=infer_provider) -> ModelInfer the model from the name.
class
pydantic_ai_slim.pydantic_ai.models.mcp_sampling.MCPSamplingModelA model that uses MCP Sampling.
method
pydantic_ai_slim.pydantic_ai.models.mcp_sampling.MCPSamplingModel.model_name() -> strThe model name.
method
pydantic_ai_slim.pydantic_ai.models.mcp_sampling.MCPSamplingModel.system() -> strThe system / model provider, returns `'MCP'`.
class
pydantic_ai_slim.pydantic_ai.models.mistral.MistralModelA model that uses Mistral.
method
pydantic_ai_slim.pydantic_ai.models.mistral.MistralModel.model_name() -> MistralModelNameThe model name.
method
pydantic_ai_slim.pydantic_ai.models.mistral.MistralModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.mistral.MistralModelSettingsSettings used for a Mistral model request.
class
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIChatModelA model that uses the OpenAI API.
method
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIChatModel.model_name() -> OpenAIModelNameThe model name.
method
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIChatModel.profile() -> OpenAIModelProfileThe model profile.
method
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIChatModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIChatModelSettingsSettings used for an OpenAI model request.
class
pydantic_ai_slim.pydantic_ai.models.openai.OpenAICompactionCompaction capability for OpenAI Responses API.
class
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIResponsesModelA model that uses the OpenAI Responses API.
method
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIResponsesModel.model_name() -> OpenAIModelNameThe model name.
method
pydantic_ai_slim.pydantic_ai.models.openai.OpenAIResponsesModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.openrouter.OpenRouterModelSettingsSettings used for an OpenRouter model request.
class
pydantic_ai_slim.pydantic_ai.models.openrouter.OpenRouterUsageConfigConfiguration for OpenRouter usage.
class
pydantic_ai_slim.pydantic_ai.models.test.TestModelA model specifically for testing purposes.
method
pydantic_ai_slim.pydantic_ai.models.test.TestModel.model_name() -> strThe model name.
method
pydantic_ai_slim.pydantic_ai.models.test.TestModel.system() -> strThe model provider.
class
pydantic_ai_slim.pydantic_ai.models.test.TestStreamedResponseA structured response that streams test data.
method
pydantic_ai_slim.pydantic_ai.models.test.TestStreamedResponse.model_name() -> strGet the model name of the response.
method
pydantic_ai_slim.pydantic_ai.models.test.TestStreamedResponse.provider_name() -> strGet the provider name.
method
pydantic_ai_slim.pydantic_ai.models.test.TestStreamedResponse.provider_url() -> str | NoneGet the provider base URL.
method
pydantic_ai_slim.pydantic_ai.models.test.TestStreamedResponse.timestamp() -> datetimeGet the timestamp of the response.
class
pydantic_ai_slim.pydantic_ai.models.wrapper.WrapperModelModel which wraps another model.
method
pydantic_ai_slim.pydantic_ai.models.wrapper.WrapperModel.settings() -> ModelSettings | NoneGet the settings from the wrapped model.
class
pydantic_ai_slim.pydantic_ai.models.xai.XaiModelSettingsSettings specific to xAI models.
class
pydantic_ai_slim.pydantic_ai.models.xai.XaiStreamedResponseImplementation of `StreamedResponse` for xAI SDK.
method
pydantic_ai_slim.pydantic_ai.models.xai.XaiStreamedResponse.model_name() -> strGet the model name of the response.
method
pydantic_ai_slim.pydantic_ai.models.xai.XaiStreamedResponse.provider_name() -> strThe model provider.
method
pydantic_ai_slim.pydantic_ai.models.xai.XaiStreamedResponse.provider_url() -> strGet the provider base URL.
method
pydantic_ai_slim.pydantic_ai.models.xai.XaiStreamedResponse.system() -> strThe model provider system name.
method
pydantic_ai_slim.pydantic_ai.models.xai.XaiStreamedResponse.timestamp() -> datetimeGet the timestamp of the response.
class
pydantic_ai_slim.pydantic_ai.models.zai.ZaiModelA model that uses Z.AI's OpenAI-compatible API.
class
pydantic_ai_slim.pydantic_ai.models.zai.ZaiModelSettingsSettings used for a Z.AI model request.
class
pydantic_ai_slim.pydantic_ai.native_tools.AbstractNativeToolA native tool that can be used by an agent.
method
pydantic_ai_slim.pydantic_ai.native_tools.AbstractNativeTool.label() -> strHuman-readable label for UI display.
method
pydantic_ai_slim.pydantic_ai.native_tools.AbstractNativeTool.unique_id() -> strA unique identifier for the native tool.
class
pydantic_ai_slim.pydantic_ai.native_tools.MemoryToolA native tool that allows your agent to use memory.
class
pydantic_ai_slim.pydantic_ai.native_tools.WebFetchToolAllows your agent to access contents from URLs.
func
pydantic_ai_slim.pydantic_ai.profiles.amazon.amazon_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for an Amazon model.
class
pydantic_ai_slim.pydantic_ai.profiles.anthropic.AnthropicModelProfileProfile for models used with `AnthropicModel`.
func
pydantic_ai_slim.pydantic_ai.profiles.anthropic.anthropic_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for an Anthropic model.
func
pydantic_ai_slim.pydantic_ai.profiles.cohere.cohere_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a Cohere model.
func
pydantic_ai_slim.pydantic_ai.profiles.deepseek.deepseek_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a DeepSeek model.
class
pydantic_ai_slim.pydantic_ai.profiles.google.GoogleModelProfileProfile for models used with `GoogleModel`.
func
pydantic_ai_slim.pydantic_ai.profiles.google.google_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a Google model.
func
pydantic_ai_slim.pydantic_ai.profiles.grok.grok_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a Grok model.
class
pydantic_ai_slim.pydantic_ai.profiles.groq.GroqModelProfileProfile for models used with GroqModel.
func
pydantic_ai_slim.pydantic_ai.profiles.groq.groq_model_profile(model_name:str) -> ModelProfileGet the model profile for a Groq model.
func
pydantic_ai_slim.pydantic_ai.profiles.merge_profile(base:ModelProfile | None, *overrides:ModelProfile | None) -> ModelProfileMerge profiles via dict-spread.
func
pydantic_ai_slim.pydantic_ai.profiles.meta.meta_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a Meta model.
func
pydantic_ai_slim.pydantic_ai.profiles.mistral.mistral_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a Mistral model.
func
pydantic_ai_slim.pydantic_ai.profiles.moonshotai.moonshotai_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a MoonshotAI model.
class
pydantic_ai_slim.pydantic_ai.profiles.openai.OpenAIModelProfileProfile for models used with `OpenAIChatModel`.
func
pydantic_ai_slim.pydantic_ai.profiles.openai.openai_model_profile(model_name:str) -> ModelProfileGet the model profile for an OpenAI model.
func
pydantic_ai_slim.pydantic_ai.profiles.openai.validate_openai_profile(profile:ModelProfile) -> NoneValidate an OpenAI-compatible profile after resolution.
func
pydantic_ai_slim.pydantic_ai.profiles.qwen.qwen_model_profile(model_name:str) -> ModelProfile | NoneGet the model profile for a Qwen model.
class
pydantic_ai_slim.pydantic_ai.profiles.zai.ZaiModelProfileProfile for Z.AI (Zhipu AI) GLM models.
class
pydantic_ai_slim.pydantic_ai.providers.ProviderAbstract class for a provider.
method
pydantic_ai_slim.pydantic_ai.providers.Provider.base_url() -> strThe base URL for the provider API.
method
pydantic_ai_slim.pydantic_ai.providers.Provider.client() -> InterfaceClientThe client for the provider.
method
pydantic_ai_slim.pydantic_ai.providers.Provider.model_profile(model_name:str) -> ModelProfile | NoneThe model profile for the named model, if available.
method
pydantic_ai_slim.pydantic_ai.providers.Provider.name() -> strThe provider name.
class
pydantic_ai_slim.pydantic_ai.providers.anthropic.AnthropicProviderProvider for Anthropic API.
class
pydantic_ai_slim.pydantic_ai.providers.azure.AzureProviderProvider for Azure OpenAI API.
class
pydantic_ai_slim.pydantic_ai.providers.bedrock.BedrockModelProfileProfile for models used with BedrockModel.
class
pydantic_ai_slim.pydantic_ai.providers.bedrock.BedrockProviderProvider for AWS Bedrock.
class
pydantic_ai_slim.pydantic_ai.providers.cerebras.CerebrasProviderProvider for Cerebras API.
class
pydantic_ai_slim.pydantic_ai.providers.cohere.CohereProviderProvider for Cohere API.
class
pydantic_ai_slim.pydantic_ai.providers.deepseek.DeepSeekProviderProvider for DeepSeek API.
class
pydantic_ai_slim.pydantic_ai.providers.fireworks.FireworksProviderProvider for Fireworks AI API.
class
pydantic_ai_slim.pydantic_ai.providers.github.GitHubProviderProvider for the retired GitHub Models API.
class
pydantic_ai_slim.pydantic_ai.providers.groq.GroqProviderProvider for Groq API.
class
pydantic_ai_slim.pydantic_ai.providers.heroku.HerokuProviderProvider for Heroku API.
class
pydantic_ai_slim.pydantic_ai.providers.huggingface.HuggingFaceProviderProvider for Hugging Face.
func
pydantic_ai_slim.pydantic_ai.providers.infer_provider(provider:str) -> Provider[Any]Infer the provider from the provider name.
func
pydantic_ai_slim.pydantic_ai.providers.infer_provider_class(provider:str) -> type[Provider[Any]]Infers the provider class from the provider name.
class
pydantic_ai_slim.pydantic_ai.providers.litellm.LiteLLMProviderProvider for LiteLLM API.
class
pydantic_ai_slim.pydantic_ai.providers.mistral.MistralProviderProvider for Mistral API.
class
pydantic_ai_slim.pydantic_ai.providers.moonshotai.MoonshotAIProviderProvider for MoonshotAI platform (Kimi models).
class
pydantic_ai_slim.pydantic_ai.providers.nebius.NebiusProviderProvider for Nebius AI Studio API.
class
pydantic_ai_slim.pydantic_ai.providers.ollama.OllamaProviderProvider for local or remote Ollama API.
class
pydantic_ai_slim.pydantic_ai.providers.openai.OpenAIProviderProvider for OpenAI API.
class
pydantic_ai_slim.pydantic_ai.providers.openrouter.OpenRouterModelProfileProfile for models used with OpenRouterModel.
class
pydantic_ai_slim.pydantic_ai.providers.openrouter.OpenRouterProviderProvider for OpenRouter API.
class
pydantic_ai_slim.pydantic_ai.providers.ovhcloud.OVHcloudProviderProvider for OVHcloud AI Endpoints.
class
pydantic_ai_slim.pydantic_ai.providers.sambanova.SambaNovaProviderProvider for SambaNova AI models.
method
pydantic_ai_slim.pydantic_ai.providers.sambanova.SambaNovaProvider.base_url() -> strReturn the base URL.
method
pydantic_ai_slim.pydantic_ai.providers.sambanova.SambaNovaProvider.client() -> AsyncOpenAIReturn the AsyncOpenAI client.
method
pydantic_ai_slim.pydantic_ai.providers.sambanova.SambaNovaProvider.model_profile(model_name:str) -> ModelProfile | NoneGet model profile for SambaNova models.
method
pydantic_ai_slim.pydantic_ai.providers.sambanova.SambaNovaProvider.name() -> strReturn the provider name.
class
pydantic_ai_slim.pydantic_ai.providers.sentence_transformers.SentenceTransformersProviderProvider for Sentence Transformers API.
method
pydantic_ai_slim.pydantic_ai.providers.sentence_transformers.SentenceTransformersProvider.base_url() -> strThe base URL for the provider API.
method
pydantic_ai_slim.pydantic_ai.providers.sentence_transformers.SentenceTransformersProvider.client() -> AnyThe client for the provider.
method
pydantic_ai_slim.pydantic_ai.providers.sentence_transformers.SentenceTransformersProvider.name() -> strThe provider name.
class
pydantic_ai_slim.pydantic_ai.providers.together.TogetherProviderProvider for Together AI API.
class
pydantic_ai_slim.pydantic_ai.providers.vercel.VercelProviderProvider for Vercel AI Gateway API.
class
pydantic_ai_slim.pydantic_ai.providers.voyageai.VoyageAIProviderProvider for VoyageAI API.
class
pydantic_ai_slim.pydantic_ai.providers.xai.XaiProviderProvider for xAI API (native xAI SDK).
class
pydantic_ai_slim.pydantic_ai.providers.zai.ZaiProviderProvider for Z.AI (Zhipu AI) API.
method
pydantic_ai_slim.pydantic_ai.result.AgentStream.response() -> _messages.ModelResponseGet the current state of the response.
method
pydantic_ai_slim.pydantic_ai.result.AgentStream.run_id() -> strThe unique identifier for the agent run.
method
pydantic_ai_slim.pydantic_ai.result.AgentStream.stream_text(*delta:bool=False, *debounce_by:float | None=0.1) -> AsyncIterator[str]Stream the text result as an async iterable.
method
pydantic_ai_slim.pydantic_ai.result.AgentStream.timestamp() -> datetimeGet the timestamp of the response.
method
pydantic_ai_slim.pydantic_ai.result.AgentStream.usage() -> RunUsageReturn the usage of the whole run.
method
pydantic_ai_slim.pydantic_ai.result.AgentStream.validate_response_output(message:_messages.ModelResponse, *allow_partial:bool=False) -> OutputDataTValidate a structured result message.
class
pydantic_ai_slim.pydantic_ai.retries.RetryConfigThe configuration for tenacity-based retrying.
class
pydantic_ai_slim.pydantic_ai.run.AgentRunResultThe final result of an agent run.
method
pydantic_ai_slim.pydantic_ai.run.AgentRunResult.all_messages(*output_tool_return_content:str | None=None) -> list[_messages.ModelMessage]Return the history of _messages.
method
pydantic_ai_slim.pydantic_ai.run.AgentRunResult.new_messages(*output_tool_return_content:str | None=None) -> list[_messages.ModelMessage]Return the messages produced during this run.
method
pydantic_ai_slim.pydantic_ai.run.AgentRunResult.run_id() -> strThe unique identifier for the agent run.
method
pydantic_ai_slim.pydantic_ai.run.AgentRunResult.timestamp() -> datetimeReturn the timestamp of last response.
method
pydantic_ai_slim.pydantic_ai.run.AgentRunResult.usage() -> _usage.RunUsageReturn the usage of the whole run.
class
pydantic_ai_slim.pydantic_ai.settings.ModelSettingsSettings to configure an LLM.
method
pydantic_ai_slim.pydantic_ai.template.TemplateStr.render(deps:AgentDepsT | None=None) -> strRender the template against the given deps object.
class
pydantic_ai_slim.pydantic_ai.tool_manager.ToolManagerManages tools for an agent run step.
class
pydantic_ai_slim.pydantic_ai.tools.ToolA tool function for an agent.
method
pydantic_ai_slim.pydantic_ai.tools.Tool.prepare_tool_def(ctx:RunContext[ToolAgentDepsT]) -> ToolDefinition | NoneGet the tool definition.
class
pydantic_ai_slim.pydantic_ai.tools.ToolDefinitionDefinition of a tool passed to a model.
method
pydantic_ai_slim.pydantic_ai.tools.ToolDefinition.defer() -> boolWhether calls to this tool will be deferred.
class
pydantic_ai_slim.pydantic_ai.toolsets.abstract.ToolsetToolDefinition of a tool available on a toolset.
class
pydantic_ai_slim.pydantic_ai.toolsets.combined.CombinedToolsetA toolset that combines multiple toolsets.
class
pydantic_ai_slim.pydantic_ai.ui._adapter.StateDepsDependency type that holds state.
class
pydantic_ai_slim.pydantic_ai.ui._adapter.StateHandlerProtocol for state handlers in agent runs.
method
pydantic_ai_slim.pydantic_ai.ui._adapter.StateHandler.state() -> AnyGet the current state of the agent run.
class
pydantic_ai_slim.pydantic_ai.ui._adapter.UIAdapterBase class for UI adapters.
class
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStreamBase class for UI event stream transformers.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.encode_event(event:EventT) -> strEncode a protocol-specific event as a string.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_builtin_tool_call_end(part:NativeToolCallPart) -> AsyncIterator[EventT]Handle the end of a `NativeToolCallPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_builtin_tool_call_start(part:NativeToolCallPart) -> AsyncIterator[EventT]Handle a `NativeToolCallPart` at start.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_builtin_tool_return(part:NativeToolReturnPart) -> AsyncIterator[EventT]Handle a `NativeToolReturnPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_compaction(part:CompactionPart) -> AsyncIterator[EventT]Handle a `CompactionPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_file(part:FilePart) -> AsyncIterator[EventT]Handle a `FilePart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_final_result(event:FinalResultEvent) -> AsyncIterator[EventT]Handle a `FinalResultEvent`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_function_tool_call(event:FunctionToolCallEvent) -> AsyncIterator[EventT]Handle a `FunctionToolCallEvent`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_function_tool_result(event:FunctionToolResultEvent) -> AsyncIterator[EventT]Handle a `FunctionToolResultEvent`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_part_delta(event:PartDeltaEvent) -> AsyncIterator[EventT]Handle a PartDeltaEvent.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_part_end(event:PartEndEvent) -> AsyncIterator[EventT]Handle a `PartEndEvent`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_part_start(event:PartStartEvent) -> AsyncIterator[EventT]Handle a `PartStartEvent`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_run_result(event:AgentRunResultEvent) -> AsyncIterator[EventT]Handle an `AgentRunResultEvent`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_text_delta(delta:TextPartDelta) -> AsyncIterator[EventT]Handle a `TextPartDelta`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_text_end(part:TextPart, followed_by_text:bool=False) -> AsyncIterator[EventT]Handle the end of a `TextPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_text_start(part:TextPart, follows_text:bool=False) -> AsyncIterator[EventT]Handle the start of a `TextPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_thinking_delta(delta:ThinkingPartDelta) -> AsyncIterator[EventT]Handle a `ThinkingPartDelta`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_thinking_end(part:ThinkingPart, followed_by_thinking:bool=False) -> AsyncIterator[EventT]Handle the end of a `ThinkingPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_thinking_start(part:ThinkingPart, follows_thinking:bool=False) -> AsyncIterator[EventT]Handle the start of a `ThinkingPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_tool_availability_delta(event:ToolAvailabilityDeltaEvent) -> AsyncIterator[EventT]Handle a `ToolAvailabilityDeltaEvent`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_tool_call_delta(delta:ToolCallPartDelta) -> AsyncIterator[EventT]Handle a `ToolCallPartDelta`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_tool_call_end(part:ToolCallPart) -> AsyncIterator[EventT]Handle the end of a `ToolCallPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.handle_tool_call_start(part:ToolCallPart) -> AsyncIterator[EventT]Handle the start of a `ToolCallPart`.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.new_message_id() -> strGenerate and store a new message ID.
method
pydantic_ai_slim.pydantic_ai.ui._event_stream.UIEventStream.on_error(error:Exception) -> AsyncIterator[EventT]Handle errors that occur during streaming.
class
pydantic_ai_slim.pydantic_ai.ui._web.api.ChatRequestExtraExtra data extracted from chat request.
class
pydantic_ai_slim.pydantic_ai.ui._web.api.ConfigureFrontendResponse model for frontend configuration.
func
pydantic_ai_slim.pydantic_ai.ui._web.api.health(request:Request) -> ResponseHealth check endpoint.
func
pydantic_ai_slim.pydantic_ai.ui._web.api.options_chat(request:Request) -> ResponseHandle CORS preflight requests.
func
pydantic_ai_slim.pydantic_ai.ui._web.api.post_chat(request:Request) -> ResponseHandle chat requests via Vercel AI Adapter.
func
pydantic_ai_slim.pydantic_ai.ui._web.app.index(request:Request) -> ResponseServe the chat UI from filesystem cache or CDN.
About this data
These signatures were extracted from the public source of pydantic/pydantic-ai
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.