adding-a-provider-api-feature

Guides adding provider API capabilities to Pydantic AI using existing cross-provider abstractions.

19.6k|2.6k|Updated Jun 21, 2024
One-click install
npx skills add https://github.com/pydantic/pydantic-ai --skill adding-a-provider-api-feature
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: adding-a-provider-api-feature
Source: https://github.com/pydantic/pydantic-ai/tree/main/.agents/skills/adding-a-provider-api-feature
Command: npx skills add https://github.com/pydantic/pydantic-ai --skill adding-a-provider-api-feature

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Adding a new provider API capability (prompt caching, strict tool calling, thinking effort, service tier) to Pydantic AI often leads to rejected PRs when contributors invent provider-specific knobs that duplicate existing cross-provider abstractions. This Skill enforces the maintainer-approved design process so the change is consistent with sibling providers, defaults deliberately, and gates support correctly.

Core Features & Use Cases

  • Abstraction-first design: Enumerates sibling provider precedent and routes the feature through existing abstractions like ToolDefinition.strict, shared ModelSettings fields, CachePoint markers, or ModelProfile capability flags before designing anything new.
  • Default and gating decisions: Provides rules for choosing default-on vs opt-in behavior, and for capability gating via profile flags, schema compatibility signals, or SDK version probes.
  • Tests, docs, and precedent map: Prescribes wire-contract cassette tests, docstring support lists enforced by test_model_settings_support.py, and includes a precedent table of past PRs (service tier, strict, thinking, prompt caching).
  • Use Case: When wiring Anthropic prompt caching or Groq reasoning effort into Pydantic AI, follow the steps to reuse the shared abstraction, pick the right default, and add the profile flag so the PR matches maintainer expectations.

Quick Start

Use this skill to add a new provider API capability such as prompt caching or reasoning effort to Pydantic AI, following the existing cross-provider abstraction and capability-gating conventions.

Frequently Asked Questions about adding-a-provider-api-feature

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add a new provider API feature to Pydantic AI?

First enumerate how sibling providers expose the same capability and identify the governing cross-provider abstraction, such as a ModelSettings field, ToolDefinition.strict, or a CachePoint marker. Reuse that abstraction rather than adding a provider-specific knob, then gate support with a ModelProfile flag.

When should a provider feature be default-on versus opt-in?

Default a feature on only when enabling it cannot change observable behavior or raise cost, such as caching that only lowers cost. Keep it opt-in when it changes wire behavior, is a preview feature, can raise cost, hits provider limits at scale, or applies lossy schema rewrites.

How does Pydantic AI handle unsupported provider settings?

Unsupported settings are silently ignored on a best-effort basis so as many requests as possible succeed, and this is documented in the docstring. Conflicting user settings produce a UserWarning rather than a hard error, and unknowable support is deferred to the runtime API error.

What is a ModelProfile capability flag in Pydantic AI?

A ModelProfile flag is a provider-prefixed boolean like bedrock_supports_prompt_caching set in Provider.model_profile() that declares whether a model family supports a capability. Profiles are layered as a developer-keyed base plus a thin provider overlay resolved per family, replacing inline isinstance or model-name checks.

When should I not use this provider feature workflow?

Do not use it for adding a new model id, which follows a separate add-new-model flow, or for bug fixes and refactors. It applies only when exposing a genuinely new provider API capability through the library's settings and profile layers.