Integrations
Pydantic AI is a type-safe agent framework for Python from the Pydantic team. Connect it to DEVUP AI through the OpenAI-compatible API.
pip install "pydantic-ai-slim[openai]"Pydantic AI prints a startup banner; set PYDANTIC_AI_NO_BANNER=1 to hide it.
export DEVUP_API_KEY="your-key"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)Output: Salam DEVUP
response = agent.run_stream_sync("Count from 1 to 5, separated by spaces.")
for text in response.stream_text(delta=True):
print(text, end="", flush=True)
print()Output: 1 2 3 4 5
Decorate a function with @agent.tool_plain; the agent calls it and uses the result.
math_agent = Agent(model, instructions="Use the multiply tool for arithmetic. Reply with the number only.")
@math_agent.tool_plain
def multiply(a: int, b: int) -> int:
"""Multiply two integers."""
return a * b
result = math_agent.run_sync("What is 12 multiplied by 34?")
tool_calls = [part.tool_name for message in result.all_messages() for part in message.parts if part.part_kind == "tool-call"]
print(tool_calls, result.output)Output: ['multiply'] 408
Set output_type to a Pydantic model; the agent returns a validated instance.
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)Output: name='Algiers' country='Algeria'
Use the exact catalog ID as the model name. Tool calling and structured output need a model whose catalog entry supports tool calling. See Models and Tool Calling.