Skip to content

Openai

pip install datapizza-ai-clients-openai

datapizza.clients.openai.OpenAIClient

Bases: Client

A client for interacting with the OpenAI API.

This class provides methods for invoking the OpenAI API to generate responses based on given input data. It extends the Client class.

__init__

__init__(
    api_key,
    model="gpt-4o-mini",
    system_prompt="",
    temperature=None,
    cache=None,
    base_url=None,
)

Parameters:

Name Type Description Default
api_key str

The API key for the OpenAI API.

required
model str

The model to use for the OpenAI API.

'gpt-4o-mini'
system_prompt str

The system prompt to use for the OpenAI API.

''
temperature float | None

The temperature to use for the OpenAI API.

None
cache Cache | None

The cache to use for the OpenAI API.

None
base_url str | URL | None

The base URL for the OpenAI API.

None

Usage example

from datapizza.clients.openai import OpenAIClient

client = OpenAIClient(
    api_key="YOUR_API_KEY"
    model="gpt-4o-mini",
)
response = client.invoke("Hello!")
print(response.text)

Include thinking

from datapizza.clients.openai import OpenAIClient

client = OpenAIClient(
    model= "gpt-5",
    api_key="YOUR_API_KEY",
)

response = client.invoke("Hi",reasoning={
        "effort": "low",
        "summary": "auto"
    }
)
print(response)