pydantic-ai-model-integration

pydantic-ai-model-integration is a skill for Claude Code from existential-birds/beagle. It costs 43 tokens per session (1,534 once invoked), scanned A, original, Apache-2.0.

A guide to connecting PydanticAI, a Python framework for AI agents, to language-model providers and configuring how those models respond. It covers provider names, model settings, streaming, and backup models.

In plain words
What is it for?
Use it when choosing an AI model, setting options such as timeouts or token limits, streaming responses, or configuring fallback models.
Why use it?
It removes the need to work out provider-specific setup and resilience patterns from scratch. It helps an agent continue working when a preferred model or request fails.

Skill for Claude Code

Written for Claude Code: shipped in a Claude Code plugin.

Part of the beagle-ai plugin — 13 skills shipped together

Good fit Use it when choosing an AI model, setting options such as timeouts or token limits, streaming responses, or configuring fallback models.

Compare 6 skills from other repositories ↓
Install with agentmods
npx agentmods add skills/existential-birds/beagle/pydantic-ai-model-integration
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Any agent
npx skills add existential-birds/beagle --skill pydantic-ai-model-integration
Clone the repo
git clone --depth 1 https://github.com/existential-birds/beagle

Made for: Claude Code.

Or install beagle-ai, the plugin that ships this one along with the rest of its 13 skills.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for pydantic-ai-model-integration

README.md
[![agentmods](https://agentmods.dev/badge/skills/existential-birds/beagle/pydantic-ai-model-integration/github.svg)](https://agentmods.dev/skills/existential-birds/beagle/pydantic-ai-model-integration)
Your own site
<a href="https://agentmods.dev/skills/existential-birds/beagle/pydantic-ai-model-integration"><img src="https://agentmods.dev/badge/skills/existential-birds/beagle/pydantic-ai-model-integration/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for pydantic-ai-model-integration

Your own site · 80×15
<a href="https://agentmods.dev/skills/existential-birds/beagle/pydantic-ai-model-integration"><img src="https://agentmods.dev/badge/skills/existential-birds/beagle/pydantic-ai-model-integration.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 43 Skills are progressive disclosure: only the name and description are preloaded; the body loads when the skill is used.
When invoked 1,534 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe. Third-party audits
  • NVIDIA SkillSpector pass 7 Sept 2026
How audits are shown
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00043 $0.01534
Opus 5 $0.00022 $0.00767
Sonnet 5 $0.00009 $0.00307
Haiku 4.5 $0.00004 $0.00153

Measured 9d ago against content hash 3ab855c02c86, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-09, from the pricing page.

Security

Grade A, and why

pydantic-ai-model-integration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 9d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

plugins/beagle-ai/skills/pydantic-ai-model-integration/SKILL.md · 242 lines

How it starts

The opening of the file, as written. The whole thing — 242 lines — stays where its author put it; the contents beside it link to each section on GitHub.

PydanticAI Model Integration

Provider Model Strings

Format: provider:model-name

from pydantic_ai import Agent

# OpenAI
Agent('openai:gpt-4o')
Agent('openai:gpt-4o-mini')
Agent('openai:o1-preview')

# Anthropic
Agent('anthropic:claude-sonnet-4-5')
Agent('anthropic:claude-haiku-4-5')

# Google (API Key)
Agent('google-gla:gemini-2.0-flash')
Agent('google-gla:gemini-2.0-pro')

# Google (Vertex AI)
Agent('google-vertex:gemini-2.0-flash')

# Groq
Agent('groq:llama-3.3-70b-versatile')
Agent('groq:mixtral-8x7b-32768')

# Mistral
Agent('mistral:mistral-large-latest')

# Other providers
Agent('cohere:command-r-plus')
Agent('bedrock:anthropic.claude-3-sonnet')

Model Settings

from pydantic_ai import Agent
from pydantic_ai.settings import ModelSettings

agent = Agent(
    'openai:gpt-4o',
    model_settings=ModelSettings(
        temperature=0.7,
        max_tokens=1000,
        top_p=0.9,
        timeout=30.0,  # Request timeout
    )
)

# Override per-run
result = await agent.run(
    'Generate creative text',
    model_settings=ModelSettings(temperature=1.0)
)

Fallback Models

Chain models for resilience:

from pydantic_ai.models.fallback import FallbackModel

# Try models in order until one succeeds
fallback = FallbackModel(
    'openai:gpt-4o',
    'anthropic:claude-sonnet-4-5',
    'google-gla:gemini-2.0-flash'
)

agent = Agent(fallback)
result = await agent.run('Hello')

# Custom fallback conditions
from pydantic_ai.exceptions import ModelAPIError

def should_fallback(error: Exception) -> bool:
    """Only fallback on rate limits or server errors."""
    if isinstance(error, ModelAPIError):
        return error.status_code in (429, 500, 502, 503)
    return False

fallback = FallbackModel(
    'openai:gpt-4o',
    'anthropic:claude-sonnet-4-5',
    fallback_on=should_fallback
)

Streaming Responses

async def stream_response():
    async with agent.run_stream('Tell me a story') as response:
        # Stream text output
        async for chunk in response.stream_output():
            print(chunk, end='', flush=True)

    # Access final result after streaming
    print(f"\nTokens used: {response.usage().total_tokens}")

Read the full file on GitHub · 242 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 9d ago First seen · 242 lines · 43 tokens per session scan A 3ab855c02c86

Subscribe to this mod's changes

pydantic-ai-model-integration is a skill published in the GitHub repository existential-birds/beagle (80 stars, last pushed 1mo ago), licensed Apache-2.0. It adds 43 tokens to every session and 1,534 once invoked, about $0.0002 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.

Related

Other skills, from other repositories

anthropic-python

Anthropic Python SDK for Claude API integration. Covers messages API, streaming, tool use, vision, error handling, and best practices. Use when building Python applications that call the Claude API. USE WHEN: user mentions "anthropic", "claude api", "anthropic sdk", "anthropic.Anthropic()", "client.messages.create"…

claude-dev-suite/claude-dev-suite · 124 tokens

pytorch-training

PyTorch model-building conventions and a neural-net training debug checklist. Use this skill whenever writing or reviewing PyTorch code that defines a model (nn.Linear, nn.Conv2d, BatchNorm) or trains one (training loop, optimizer, LR schedule), and ESPECIALLY when debugging training problems — loss not converging…

congmnguyen/claude-code-wsl2-setup · 118 tokens

sap-cloud-sdk-ai-python

Integrates the SAP Cloud SDK for AI for Python (sap-ai-sdk-gen, formerly generative-ai-hub-sdk) into Python applications. Use when building Python apps with SAP AI Core, Generative AI Hub, or the Orchestration Service: chat completion, embeddings, streaming, LangChain integration, templating, content filtering, data…

secondsky/sap-skills · 103 tokens

pytorch-training

Train and optimize deep learning models with PyTorch. Use when building neural networks, implementing training loops, or optimizing model performance.

ihatesea69/kiro-kit · 29 tokens

scikit-learn

Classical machine learning with scikit-learn. Use when building classification, regression, clustering models, or implementing feature engineering pipelines.

ihatesea69/kiro-kit · 31 tokens

tensorflow-keras

Build and train models with TensorFlow and Keras. Use when implementing production ML models, using tf.data pipelines, or deploying with TF Serving.

ihatesea69/kiro-kit · 33 tokens