onrup

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

Other frameworks

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.