Docs
Sign inJoin the waitlist

Use a Model with Pydantic AI

A Model is an OpenAI-compatible chat model, so Pydantic AI’s OpenAI model class calls it through a provider with your serving URL. Set FACET_BASE_URL and FACET_API_KEY as in Call a Model.

pip install pydantic-ai-slim[openai]
import os
from pydantic_ai import Agent
from pydantic_ai.models.openai import OpenAIChatModel
from pydantic_ai.providers.openai import OpenAIProvider

model = OpenAIChatModel(
    "support-triage",
    provider=OpenAIProvider(base_url=os.environ["FACET_BASE_URL"], api_key=os.environ["FACET_API_KEY"]),
)
agent = Agent(model)
print(agent.run_sync("My card was charged twice").output)

Give the agent no instructions or system prompt: Facet adds the Model’s Instructions to every call. A Model does one task, so use it for that step, not as the agent that plans and calls tools.

Next steps

Esc