Chat Completions

Generate text responses from any supported model using the OpenAI-compatible chat completions endpoint.

Endpoint

POST https://api.aihubspot.app/v1/chat/completions

Fully OpenAI-compatible. Use the OpenAI SDK by setting base_url to https://api.aihubspot.app/v1.

Request body

ParameterTypeRequiredDescription
modelstringYesModel ID (e.g. gpt-4o, claude-3-5-sonnet)
messagesarrayYesArray of message objects
streambooleanNoEnable SSE streaming (default: false)
max_tokensintegerNoMaximum tokens to generate
temperaturenumberNoSampling temperature 0–2

Example

from openai import OpenAI
 
client = OpenAI(
    api_key="AH_SMKRPA_YOUR_KEY",
    base_url="https://api.aihubspot.app/v1",
)
 
response = client.chat.completions.create(
    model="claude-3-5-sonnet",
    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)

Drop-in replacement for the OpenAI API. Any library or framework that works with OpenAI works here — just change base_url.