ZenML
PydanticAI
All integrations

PydanticAI

PydanticAI type-safe agents integrated with ZenML

Add to ZenML

PydanticAI type-safe agents integrated with ZenML

PydanticAI extends the Pydantic ecosystem with type-safe AI agents that validate structured outputs and integrate tools. Running them with ZenML puts these agents into production-ready pipelines, ensuring reproducibility, artifact lineage, and deployment flexibility.

Features with ZenML

  • Type-safe orchestration. Run PydanticAI agents inside ZenML pipelines with guaranteed structured outputs.
  • Artifact tracking. Store queries, validated responses, and error cases as ZenML artifacts.
  • Error handling. Integrate post-run checks or evaluation steps to catch invalid responses.
  • Composable workflows. Combine PydanticAI with retrieval, evals, and deployment steps in a single pipeline.
  • Portable execution. Move seamlessly from local runs to scalable orchestrators like Kubernetes or Airflow.
PydanticAI integration screenshot

Main Features

  • Type-safe agents. Ensure AI outputs conform to strict schemas defined with Pydantic.
  • Simple run_sync API. Call agents with a straightforward synchronous interface.
  • Tool integration. Extend agents with callable Python functions as tools.

How to use ZenML with PydanticAI

from zenml import ExternalArtifact, pipeline, step
from pydanticai_agent import agent

@step
def run_pydanticai(query: str) -> str:
   result = agent.run_sync(query)
   return str(result.output)

@pipeline
def pydanticai_agent_pipeline() -> str:
   q = ExternalArtifact(value="What is the secret data?")
   return run_pydanticai(q.value)

if __name__ == "__main__":
   print(pydanticai_agent_pipeline())

Additional Resources

Connect Your ML Pipelines to a World of Tools

Expand your ML pipelines with more than 50 ZenML Integrations

  • Amazon S3
  • Apache Airflow
  • Argilla
  • AutoGen
  • AWS
  • AWS Strands
  • Azure Blob Storage
  • Azure Container Registry
  • AzureML Pipelines
  • BentoML
  • Comet