Frameworks · Python
Pydantic AI
How do I use Pydantic AI with Onrup?
Configure an OpenAI-compatible model with your deployment base URL. Pydantic AI then validates every response against your schema, which pairs well with a model fine-tuned for structured output.
A Python agent framework that uses Pydantic models to type and validate model output.
Minimal working example
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIModel
from pydantic_ai.providers.openai import OpenAIProvider
model = OpenAIModel(
"default",
provider=OpenAIProvider(base_url="https://serve.onrup.com/<tenant>/<deployment>/v1", api_key="onrup_sk_..."),
)
agent = Agent(model, output_type=Invoice)The thing that catches people out
Validation failures are retried by re-prompting, which costs a full extra request. A model fine-tuned on your schema pushes validity high enough that the retry path is rarely taken — that saving is the main reason to fine-tune for this.
Worth knowing
- Report schema validity separately from field accuracy; they are different failures.
- Include malformed inputs in training or the model will invent structure when it meets one.
- Combining a fine-tune with validation is belt and braces, and the braces should almost never be needed.
Other frameworks
LangChain
A framework for composing language-model calls into chains, agents and retrieval pipelines.
LlamaIndex
A framework for connecting language models to your own data, with a focus on indexing and retrieval.
Vercel AI SDK
A TypeScript toolkit for building streaming language-model interfaces in web applications.
Start with the free tier
A magic link creates your account, your tenant and your first API key. No card until you ask for compute.