Skip to main content

/responses

haimaker provides an endpoint in the spec of OpenAI's /responses API.

FeatureSupportedNotes
Cost TrackingWorks with all supported models
LoggingWorks across all integrations
Streaming
Image Generation StreamingProgressive image generation with partial images
FallbacksWorks between supported models
LoadbalancingWorks between supported models
Supported operationsCreate, Get, Delete a response
Supported ProvidersAll providers: openai, anthropic, bedrock, vertex_ai, gemini, azure, azure_ai etc.

Quick Start

Python

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

# Non-streaming response
response = client.responses.create(
model="openai/o1-pro",
input="Tell me a three sentence bedtime story about a unicorn.",
max_output_tokens=100
)

print(response)

cURL

curl https://api.haimaker.ai/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_API_KEY" \
-d '{
"model": "openai/o1-pro",
"input": "Tell me a three sentence bedtime story about a unicorn."
}'

Streaming

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.responses.create(
model="openai/o1-pro",
input="Tell me a three sentence bedtime story about a unicorn.",
stream=True
)

for event in response:
print(event)

Response Format

{
"id": "resp_abc123",
"object": "response",
"created_at": 1734366691,
"status": "completed",
"model": "o1-pro-2025-01-30",
"output": [
{
"type": "message",
"id": "msg_abc123",
"status": "completed",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "Once upon a time, a little unicorn named Stardust lived in a magical meadow...",
"annotations": []
}
]
}
],
"usage": {
"input_tokens": 18,
"output_tokens": 98,
"total_tokens": 116
}
}

Using Different Models

OpenAI

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.responses.create(
model="openai/o1-pro",
input="What is the capital of France?"
)

Anthropic Claude

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.responses.create(
model="anthropic/claude-3-5-sonnet-20240620",
input="Tell me a three sentence bedtime story about a unicorn.",
max_output_tokens=100
)

Google Gemini

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

response = client.responses.create(
model="gemini/gemini-1.5-flash",
input="Tell me a three sentence bedtime story about a unicorn.",
max_output_tokens=100
)

Get a Response

Retrieve a response by its ID:

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

# Create a response
response = client.responses.create(
model="openai/o1-pro",
input="Tell me a story."
)

# Retrieve it by ID
retrieved_response = client.responses.retrieve(response.id)
print(retrieved_response)

Delete a Response

Delete a response by its ID:

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

# Create a response
response = client.responses.create(
model="openai/o1-pro",
input="Tell me a story."
)

# Delete it
delete_response = client.responses.delete(response.id)
print(delete_response)

Image Generation

Generate images with the responses API:

import base64
from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

# OpenAI models require tools parameter for image generation
response = client.responses.create(
model="openai/gpt-4o",
input="Generate a futuristic city at sunset",
tools=[{"type": "image_generation"}]
)

# Access generated images from output
for item in response.output:
if item.type == "image_generation_call":
image_bytes = base64.b64decode(item.result)
with open(f"generated_{item.id}.png", "wb") as f:
f.write(image_bytes)

Image Generation with Streaming

import base64
from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

stream = client.responses.create(
model="openai/gpt-4.1",
input="Draw a gorgeous image of a river made of white owl feathers",
stream=True,
tools=[{"type": "image_generation", "partial_images": 2}],
)

for event in stream:
if event.type == "response.image_generation_call.partial_image":
idx = event.partial_image_index
image_base64 = event.partial_image_b64
image_bytes = base64.b64decode(image_base64)
with open(f"river{idx}.png", "wb") as f:
f.write(image_bytes)

Session Management with Previous Response

Continue conversations by referencing previous responses:

from openai import OpenAI

client = OpenAI(
api_key="YOUR_API_KEY",
base_url="https://api.haimaker.ai/v1"
)

# Initial request
response = client.responses.create(
model="anthropic/claude-3-5-sonnet-latest",
input="Who is Michael Jordan?"
)

print(f"Response ID: {response.id}")

# Follow-up request referencing the previous response
follow_up = client.responses.create(
model="anthropic/claude-3-5-sonnet-latest",
input="Can you tell me more about him?",
previous_response_id=response.id
)

print(follow_up.output[0].content[0].text)

Supported Providers

ProviderNotes
openaiAll Responses API parameters are supported
azureAll Responses API parameters are supported
anthropicSee provider documentation for supported parameters
bedrockSee provider documentation for supported parameters
geminiSee provider documentation for supported parameters
vertex_aiSee provider documentation for supported parameters
All other providersSee provider documentation for supported parameters