Skip to main content
Pydantic AI reaches Mesh through its OpenAI model class and OpenAIProvider, which takes a base_url. Typed tools, validated structured output, and dependency injection all work unchanged.

Install

The full pydantic-ai package works too; pydantic-ai-slim[openai] pulls only the OpenAI-compatible provider, which is all Mesh needs.

Connect

The class was named OpenAIModel in earlier releases and OpenAIChatModel in current ones. If an import fails, try the other name:

Tool calling

Decorate a function and Pydantic AI derives the schema from its type hints:
result.all_messages() carries the full exchange, including the tool-call and tool-return parts, if you need to inspect what the model did.

Structured output

An output_type makes Mesh’s response validate into your model:

Caveats

Everything in Caveats that apply to every framework applies here. Pydantic AI prints a one-time observability banner on startup. Set PYDANTIC_AI_NO_BANNER=1 to silence it; it is unrelated to Mesh.