Skip to main content
Use OpenAI models (GPT-4, GPT-3.5, and more) with Hypertic agent.

Installation

Install the OpenAI package:
pip install hypertic[openai]

Setup

Set your OpenAI API key as an environment variable:
export OPENAI_API_KEY=sk-...

Initialize Model

Create an OpenAI model instance. You can use either OpenAIChat or OpenAIResponse:
from hypertic.models import OpenAIChat

model = OpenAIChat(
    model="gpt-5.2",
    max_tokens=1000,
    temperature=0.5,
)

Use with Agent

Pass the model to your agent. Both OpenAIChat and OpenAIResponse work the same way:
from hypertic.agents import Agent
from hypertic.models import OpenAIChat

model = OpenAIChat(model="gpt-5.2")
agent = Agent(
    model=model,
    tools=[get_weather],
)

response = agent.run("What's the weather in SF?")
print(response.content)

Configuration Options

Supported parameters for OpenAI models. Both OpenAIChat and OpenAIResponse support the same parameters:
from hypertic.models import OpenAIChat

model = OpenAIChat(
    model="gpt-5.2",
    temperature=0.7,      # Controls randomness (0.0-2.0)
    max_tokens=1000,      # Maximum response length
)
For the full list of available models and parameters, see the OpenAI API documentation.