Skip to content

Find the complete code on Github

You can find the code used on this integration directly on OVHcloud's Github.

Pydantic AI

Pydantic AI

Pydantic AI is a Python agent framework designed to build production-grade applications with Generative AI. It leverages Pydantic for data validation and type safety, ensuring structured and reliable interactions with LLMs.

Installation

Getting started

You can have more information on how to get started with Pydantic AI on their documentation.

First, install the pydantic-ai package.

pip install pydantic-ai
uv add pydantic-ai

You can then set the OVHCLOUD_API_KEY environment variable with our AI Endpoints API key.

Usage

Create a new file such as main.py and paste this code. You are ready in less than 5 lines of code!

from pydantic_ai import Agent

agent = Agent('ovhcloud:gpt-oss-120b')
result = agent.run_sync('What is the capital of France?')
print(result.output)

You get the following output: The capital of France is Paris..

If you need to configure the provider, you can use the OVHcloudProvider class:

from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.ovhcloud import OVHcloudProvider

model = OpenAIChatModel(
    'gpt-oss-120b',
    provider=OVHcloudProvider(api_key='your-api-key'),
)
agent = Agent(model)
result = agent.run_sync('What is the capital of France?')
print(result.output)

Going further

You can explore the Pydantic AI documentation to dive deeper into advanced features.

  • Check out our Getting Started guide to learn more about OVHcloud AI Endpoints capabilities.
  • Need support or want to chat? Join our community on Discord.
  • Found a mistake or want to improve this guide? Feel free to open a Pull Request or Issue on GitHub.