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.
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
| Feature | Status | Notes |
|---|---|---|
| Chat completions | Works | Full request/response compatibility. |
| Streaming (SSE) | Works | Same server-sent-events shape. |
| Image generation | Partial | The 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-speech | Works | Full compatibility. |
| Video generation | Not OpenAI-shaped | No OpenAI equivalent exists. AI HUB's video endpoint is a custom submit-then-poll pair. See the media docs. |
| Embeddings | Not OpenAI-shaped | Not offered on this API. |
| Fine-tuning | Not OpenAI-shaped | Not offered on this API. |
| Assistants / threads API | Not OpenAI-shaped | Not 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.