Integrations / Pydantic AI
P

Pydantic AI

Pydantic · Verified setup guide

A typed agent framework from the Pydantic team. Use its OpenAI-compatible provider.

Setup steps

  1. 1
    Installpip install pydantic-ai
  2. 2
    Create the modelOpenAIChatModel with OpenAICompatibleProvider below.
  3. 3
    Use itGive the model to an Agent.

Configuration example

python
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai_compatible import OpenAICompatibleProvider

model = OpenAIChatModel(
    "YOUR_MODEL_ID",                       # any model id from the /models page
    provider=OpenAICompatibleProvider(
        "luxechain", base_url="https://api.luxechain.si/v1", api_key="lxc_live_YOUR_KEY"),
)

agent = Agent(model)

Replace YOUR_MODEL_ID with any model from the catalogue. Never paste a real API key into a shared document.

Troubleshooting

Prefer OpenAICompatibleProvider over OpenAIProvider for a third-party gateway, and pick OpenAIChatModel vs OpenAIResponsesModel to match the endpoint.

If the tool rejects the endpoint, confirm the base URL exactly matches the value on the right, and that the key is active in your account.