OpenAIProvider, which takes a base_url. Typed tools, validated structured output, and dependency injection all work unchanged.
Install
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
Anoutput_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. SetPYDANTIC_AI_NO_BANNER=1 to silence it; it is unrelated to Mesh.
Related
- Agent frameworks — the shared pattern and compatibility matrix
- Auto-routing — how
autopicks a model - Structured outputs — the tool and schema format Mesh accepts