Skip to main content
Get started with Hypertic by building an AI agent that demonstrates core features: tools for extending capabilities, memory for maintaining conversation context, and model configuration for consistent behavior. This guide walks you through creating an agent that uses weather and date tools, maintains conversation history with in-memory storage (use PostgreSQL/MongoDB in production), and can handle both synchronous and asynchronous operations with streaming support.
1

Set up environment

Create a virtual environment to isolate your project dependencies.
python -m venv venv
source venv/bin/activate
2

Install dependencies

Install Hypertic and the OpenAI package using pip or uv.
pip install hypertic openai
3

Set API key

Export your OpenAI API key as an environment variable.
export OPENAI_API_KEY=sk-***
4

Create tools

Define tool functions that your agent can use to interact with external systems.
from hypertic.tools import tool
from datetime import datetime

# Define a weather tool
@tool
def get_weather(city: str) -> str:
    """Get weather for a given city."""
    # In production, this would call a real weather API
    return f"Sunny, 72°F in {city}"

# Define a date tool
@tool
def get_current_date() -> str:
    """Get the current date and time."""
    return datetime.now().strftime('%Y-%m-%d %H:%M:%S')
5

Configure model

Initialize your language model with the desired parameters.
from hypertic.models import OpenAI

# Configure the model
model = OpenAI(
  model="gpt-5.2",
  max_tokens=1000,
  temperature=0.5,
)
6

Add memory

Set up memory to store conversation history and maintain context across sessions. For this demo, we’ll use in-memory storage (use PostgreSQL/MongoDB in production).
from hypertic.memory import InMemory

# Create in-memory memory (for demo - use PostgreSQL/MongoDB in production)
memory = InMemory()
7

Configure agent

Create your agent with the model, tools, and memory configuration.
from hypertic.agents import Agent

# Create an agent with memory
agent = Agent(
    model=model,
    instructions="", # If you want you can add instructions also.
    tools=[get_weather, get_current_date],
    memory=memory
)
8

Run the agent

Execute your agent with a query and get a response. You can use synchronous, asynchronous, or streaming methods.
# Synchronous non-streaming
response = agent.run("What is today's date and how's the weather in San Francisco?")
print(response.content)
Today's date is 2024-01-15. The weather in San Francisco is sunny, 72°F.
Congratulations! You’ve built your first AI agent with Hypertic that can use tools and remember context.