Python

Use the standard OpenAI Python SDK with aihubspot — just point base_url at our endpoint.

Installation

aihubspot is fully OpenAI-compatible. Use the official OpenAI SDK — no new package needed.

pip install openai

Setup

from openai import OpenAI
 
client = OpenAI(
    api_key="AH_SMKRPA_YOUR_KEY",
    base_url="https://api.aihubspot.app/v1",
)

Store your key in an environment variable and load it at runtime:

import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.environ["AH_API_KEY"],
    base_url="https://api.aihubspot.app/v1",
)

Quick start

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)

Streaming

with client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Tell me a story"}],
    stream=True,
) as stream:
    for chunk in stream:
        print(chunk.choices[0].delta.content or "", end="", flush=True)

Any code that works with openai.OpenAI() works here — just add base_url="https://api.aihubspot.app/v1" and swap the key.