AI HUB Docs
English
Console →
Guide

Migrating from OpenAI

AI HUB's chat surface is OpenAI-compatible. Most integrations move over with a two-line change and nothing else.

The base-URL swap

Change the client's api_key and base_url. Everything else, including the request shape, response shape and streaming, stays the same.

Python
client = OpenAI(
    api_key=os.environ["AIHUB_API_KEY"],   # was OPENAI_API_KEY
    base_url="https://console.aimodelhub.ai/v1",             # was https://api.openai.com/v1
)

The same swap applies to the Node SDK and any other OpenAI-compatible client: change the key and the base URL, keep everything else.

What is compatible

FeatureStatusNotes
Chat completionsWorksFull request/response compatibility.
Streaming (SSE)WorksSame server-sent-events shape.
Image generationPartialThe endpoint exists and the request shape matches, but it can return 202 with a job id instead of the image inline. See the gotcha below. OpenAI's SDK does not expect this.
Text-to-speechWorksFull compatibility.
Video generationNot OpenAI-shapedNo OpenAI equivalent exists. AI HUB's video endpoint is a custom submit-then-poll pair. See the media docs.
EmbeddingsNot OpenAI-shapedNot offered on this API.
Fine-tuningNot OpenAI-shapedNot offered on this API.
Assistants / threads APINot OpenAI-shapedNot offered on this API. Chat completions can be used directly.

Two real gotchas

!

OpenAI's official SDKs do not send an Idempotency-Key header on their own. AI HUB synthesizes one from a request fingerprint when none is sent, so retries are still safe. Explicit control over when two calls count as the same request is only available when the header is set.

!

An OpenAI SDK's typed image-generation call expects a 200 with the image inline. AI HUB's image endpoint can instead return 202 with a job id when generation runs long. The SDK's own types do not model that response, so a strict client may raise an error where a looser HTTP call would not. See the endpoint index.