Pydantic AI logoFramework

Pydantic AI with DEVUP AI

Build type-safe agents with Pydantic AI on DEVUP AI models. Connect OpenAIChatModel to DEVUP AI with OpenAIProvider, and get validated, typed answers.

System Architecture

How Pydantic AI Connects to DEVUP AI

1. Client
Pydantic AI
Your Python agent
2. Gateway
DEVUP OpenAI-compatible API
POST /v1/chat/completions
3. Inference
Model
DeepSeek-V4-Pro
4. Response
Response
Text, tool calls and validated objects

Configuration

Quick Setup

bash
pip install "pydantic-ai-slim[openai]"
python
import os

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider

model = OpenAIChatModel(
    "deepseek-ai/DeepSeek-V4-Pro",
    provider=OpenAIProvider(
        base_url="https://api.devupai.com/v1",
        api_key=os.environ["DEVUP_API_KEY"],
    ),
)

agent = Agent(model, instructions="Be concise.")
result = agent.run_sync("Reply with exactly: Salam DEVUP")
print(result.output)

Structured Output

Typed Answers with Pydantic

python
from pydantic import BaseModel


class City(BaseModel):
    name: str
    country: str


city_agent = Agent(model, output_type=City)
result = city_agent.run_sync("Which city is the capital of Algeria?")
print(result.output)

Capabilities

Supported Capabilities

Agents and streaming

Run agents synchronously, or stream text as it is generated with run_stream_sync.

Tool calling

Decorate a Python function with @agent.tool_plain and the model calls it when needed.

Structured output

Set output_type to a Pydantic model and the agent returns validated, typed data.

Local DZD billing

Metered billing in Algerian Dinar with BaridiMob, Edahabia, and CIB local payment support.

Ready to Build with Pydantic AI on DEVUP AI?