Skip to main content
Pydantic AI is a Python agent framework Pydantic docs
Pydantic + Nebius AI docs

Prerequisites

  1. Create an API key to authorize requests to Nebius Token Factory.
  2. Save the API key into a NEBIUS_API_KEY environment variable:
    export NEBIUS_API_KEY="<API_key>"
    
  3. Install the pydantic package:
    pip install pydantic_ai
    

Create an Agent Application

Simplest application. NEBIUS_API_KEY will be inferred from env variables.
from pydantic_ai import Agent

agent = Agent('nebius:Qwen/Qwen3-32B-fast')
result = agent.run_sync('What is the capital of France?')
print(result.output)
#> The capital of France is Paris.
You can use also use the NebiusProvider class:
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.nebius import NebiusProvider

model = OpenAIChatModel(
    'Qwen/Qwen3-32B-fast',
    provider=NebiusProvider(api_key='your-nebius-api-key'),
)
agent = Agent(model)
result = agent.run_sync('What is the capital of France?')
print(result.output)
#> The capital of France is Paris.

More Examples

View more examples in our cookbook