Node.js SDK
HiAPI is fully compatible with the OpenAI Node.js SDK. Just change the baseURL.
Installation
Section titled “Installation”npm install openaiimport OpenAI from "openai";
const client = new OpenAI({ apiKey: "YOUR_API_KEY", baseURL: "https://api.hiapi.ai/v1"});Image Generation
Section titled “Image Generation”const response = await client.images.generate({ model: "qwen-image-2.0", prompt: "a futuristic city at sunset", size: "1024x1024"});
console.log(response.data[0].url);Chat-Compatible Image Generation
Section titled “Chat-Compatible Image Generation”const response = await client.chat.completions.create({ model: "Nano-Banana", stream: false, messages: [{ role: "user", content: "draw a cute cat" }]});
console.log(response.choices[0].message.content);Video (fetch)
Section titled “Video (fetch)”For video endpoints not covered by the OpenAI SDK, use fetch:
const response = await fetch("https://api.hiapi.ai/v1/videos", { method: "POST", headers: { "Authorization": "Bearer YOUR_API_KEY", "Content-Type": "application/json" }, body: JSON.stringify({ model: "wan2.7-t2v", prompt: "sunset timelapse over mountains", seconds: "5" })});
const data = await response.json();console.log(data);