pydantic_ai.models.openai
OpenAIModel
dataclass
Bases: Model
A model that uses the OpenAI API.
Internally, this uses the OpenAI Python client to interact with the API.
Apart from __init__
, all methods are private or match those of the base class.
__init__
__init__(
model_name: ChatModel,
*,
api_key: str | None = None,
openai_client: AsyncOpenAI | None = None,
http_client: AsyncClient | None = None
)
Initialize an OpenAI model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model_name
|
ChatModel
|
The name of the OpenAI model to use. List of model names available
here
(Unfortunately, despite being ask to do so, OpenAI do not provide |
required |
api_key
|
str | None
|
The API key to use for authentication, if not provided, the |
None
|
openai_client
|
AsyncOpenAI | None
|
An existing
|
None
|
http_client
|
AsyncClient | None
|
An existing |
None
|