# PydanticAI > Run a PydanticAI agent on Kiln: install, a verified run_sync call, OpenAIChatModel in place of the renamed OpenAIModel, and where max_tokens belongs. Source: https://kiln.bricksum.com/docs/en/sdks/pydantic-ai PydanticAI builds an agent on a model object, and its OpenAI model takes a provider you construct with the base URL and the key. Nothing else in an agent definition changes. ## Install **Python** ```bash pip install pydantic-ai ``` ## Connect **Python** ```python import os from pydantic_ai import Agent from pydantic_ai.models.openai import OpenAIChatModel from pydantic_ai.providers.openai import OpenAIProvider model = OpenAIChatModel( "qwen3-32b", provider=OpenAIProvider( base_url="https://api.bricksum.com/v1", api_key=os.environ["KILN_API_KEY"], # sk-bk-... ), ) agent = Agent(model, system_prompt="Answer briefly.", model_settings={"max_tokens": 800}) print(agent.run_sync("Write a haiku about kilns.").output) ``` ## What differs on Kiln - **OpenAIChatModel, not OpenAIModel** PydanticAI renamed the class, and older guides still import OpenAIModel. On the version in the note below the import fails, so use OpenAIChatModel with an OpenAIProvider. - **max_tokens goes in model_settings** The agent, not the model, carries the request settings. Reasoning tokens are counted inside that budget, and when it runs out before any answer text PydanticAI raises UnexpectedModelBehavior rather than returning an empty result — so leave room; the example sends 800, a starting value not measured on this model — if the run raises UnexpectedModelBehavior, raise it. The base URL, authentication, the request parameters every endpoint shares, the response envelope, streaming and the error codes are the same whichever SDK you use. They are documented once on the [API Reference](https://kiln.bricksum.com/docs/en/api-reference). The calls above land on [Chat completions](https://kiln.bricksum.com/docs/en/api-reference/chat-completions). The model ID has to be one the API is serving right now; how to list those, and what to do when an ID is not among them, is on [Models](https://kiln.bricksum.com/docs/en/models). What this model does not support, whatever SDK sends it, is listed under [Migrating from OpenAI](https://kiln.bricksum.com/docs/en/migrating-from-openai). Note Snippets on this page were run against the Kiln API on 2026-09-21 with pydantic-ai 2.46.0. Not verified: That run was on gpt-oss-120b; the page now names qwen3-32b, which it has not yet been re-run against. The agent run above was run. Typed output, tools and streaming were not exercised against Kiln.