output_type and works with any OpenAI-compatible endpoint.
For dottxt, output_type is the important integration point: Pydantic AI derives JSON Schema from your output model, sends that schema through the OpenAI-compatible API, and parses the result back into a typed object.
Install
Configure
Create anOpenAIProvider pointed at dottxt, then wrap it in an OpenAIChatModel:
Basic usage
Pass a Pydantic model asoutput_type to get typed structured output:
output_type and parses the response back into result.output. Under the hood, this still uses the same dottxt structured generation flow described in API Overview and Pydantic Authoring.
Agent with dependencies and tools
Usedeps_type to inject runtime context, and @agent.tool to give the agent callable functions:
Notes
- Use
output_type, notresult_type; the latter was removed in Pydantic AI v0.6.0. agent.run()is async,agent.run_sync()is synchronous,agent.run_stream()is async streaming.- The result is accessed via
result.output, typed according tooutput_type. ConfigDict(extra="forbid")is useful when you wantadditionalProperties: falsein the generated schema.- See the Pydantic authoring guide for how to write effective schemas.