API reference

modelhaus speaks the OpenAI API. Point your existing client at our base URL, use your modelhaus key, and every sovereign and aggregated model is one call away.

Quickstart

The base URL for all API calls is:

BASE https://modelhaus.ai/v1

Grab a key from your dashboard (create one at sign up), then make your first call:

# Your first completion
curl https://modelhaus.ai/v1/chat/completions \
  -H "Authorization: Bearer $MODELHAUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "glm-5-2",
    "messages": [{"role":"user","content":"Say hello in one line."}]
  }'
Already using OpenAI? You only change two things: the base_url to https://modelhaus.ai/v1 and the api_key to your modelhaus key. Everything else - messages, streaming, tools - works the same.

Authentication

Authenticate every request with a bearer token in the Authorization header:

Authorization: Bearer $MODELHAUS_KEY

Keys are created and revoked in your dashboard. Each key draws down your prepaid balance; usage is metered per request. Keep keys server-side - never ship them in client code.

OpenAI compatibility

modelhaus implements the OpenAI Chat Completions and Models endpoints. Any OpenAI-compatible SDK, framework, or tool works by overriding the base URL:

EndpointMethodPurpose
/v1/chat/completionsPOSTChat & text completion, streaming or not, with tool-calling.
/v1/modelsGETList the models available to your key.
/v1/images/generationsPOSTGenerate images with our sovereign image models.

Chat completions

POST /v1/chat/completions

Create a model response for a conversation. Core parameters:

FieldTypeDescription
modelstringModel id, e.g. glm-5-2. See the catalog.
messagesarrayList of {role, content} - roles system, user, assistant, tool.
streamboolIf true, tokens stream back as SSE. Default false.
temperaturenumberSampling temperature, 0-2. Default 1.
max_tokensintMax tokens to generate.
toolsarray(optional) OpenAI-format tool/function definitions for tool-calling.

Example response (non-streamed):

{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "glm-5-2",
  "choices": [{
    "index": 0,
    "message": {"role":"assistant","content":"Hello!"},
    "finish_reason": "stop"
  }],
  "usage": {"prompt_tokens":12,"completion_tokens":3,"total_tokens":15}
}

Streaming

Set "stream": true to receive Server-Sent Events. Each event is a chat.completion.chunk with a token delta; the stream ends with data: [DONE].

curl -N https://modelhaus.ai/v1/chat/completions \
  -H "Authorization: Bearer $MODELHAUS_KEY" \
  -d '{"model":"glm-5-2","stream":true,"messages":[{"role":"user","content":"Count to 3"}]}'

# data: {"choices":[{"delta":{"content":"1"}}]}
# data: {"choices":[{"delta":{"content":", 2"}}]}
# data: [DONE]

List models

GET /v1/models

Returns the models available to your key in OpenAI list format. Use it to discover ids at runtime.

curl https://modelhaus.ai/v1/models \
  -H "Authorization: Bearer $MODELHAUS_KEY"

Image generation

POST /v1/images/generations

Generate images with our sovereign image models - flux-schnell and sdxl - hosted in Canada and billed per image. OpenAI images format.

FieldTypeDescription
modelstringflux-schnell or sdxl. See the catalog.
promptstringText description of the image to generate.
nint(optional) Number of images, 1-4. Default 1.
sizestring(optional) e.g. 1024x1024.
curl https://modelhaus.ai/v1/images/generations \
  -H "Authorization: Bearer $MODELHAUS_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"flux-schnell","prompt":"a red fox in snow","n":1,"size":"1024x1024"}'

The response is OpenAI-compatible, returning base64-encoded images:

{
  "created": 1789132146,
  "model": "flux-schnell",
  "data": [{ "b64_json": "iVBORw0KGgo..." }]
}
Bill per image at the model's listed rate (e.g. flux-schnell $0.01, sdxl $0.015). Use the Python or JavaScript OpenAI SDK's images.generate() the same way - just point it at the modelhaus base URL.

SDKs & frameworks

Because modelhaus is OpenAI-compatible, the official SDKs and popular frameworks work unchanged - just set the base URL.

Python
JavaScript
LangChain
from openai import OpenAI

client = OpenAI(
    base_url="https://modelhaus.ai/v1",
    api_key="$MODELHAUS_KEY",
)
resp = client.chat.completions.create(
    model="glm-5-2",
    messages=[{"role":"user","content":"Hello!"}],
)
print(resp.choices[0].message.content)

Errors

Errors use the OpenAI error shape with standard HTTP status codes:

{ "error": { "message": "...", "type": "invalid_request_error" } }
StatusMeaning
401Missing or invalid API key.
402Insufficient balance - top up in your dashboard.
400Malformed request (e.g. calling a chat endpoint on an image model).
429Rate limited - slow down and retry with backoff.
5xxUpstream/model error - safe to retry.

Rate limits

Default limits scale with your balance and usage history and are generous for normal development. If you hit 429, back off and retry. For dedicated throughput, reserved capacity, or a private deployment, reach out.

Ready to build? Get an API key, then browse the catalog and check pricing.