Back to prompt library
Build Type-Safe Agent with Pydantic AI
Linked challenge: Type-Safe Debit Processing & Fee Optimization Agent with Pydantic AI
Prompt source
implementation11 lines3 sectionsNo variables0 checklist items
from pydantic import BaseModel, Field
from pydantic_ai import Agent, RunContext
class DebitRoutingResult(BaseModel):
selected_network: str = Field(description="Chosen debit network rail")
calculated_fee: float = Field(ge=0.0, description="Total interchange plus processing fee")
compliance_pass: bool
debit_agent = Agent(
'openai:gpt-4o',
result_type=DebitRoutingResult,
system_prompt="You are a debit network optimization agent. Evaluate network fees and pick the lowest-cost compliant network."
)