SDKS · TYPESCRIPT
TypeScript SDK
Use the official openai npm package. Set baseURL to https://api.hoonify.ai/v1 and pass your Hoonify key. Same client, same generated types, same streaming primitives.
No separate package
Hoonify doesn't publish a separate npm SDK. The OpenAI SDK already covers chat and streaming. Hoonify-only fields are passed inline (with a single
@ts-expect-error) or via headers.Install
shell
npm install openaiSetup
typescript
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.hoonify.ai/v1",
apiKey: process.env.HOONIFY_API_KEY!,
});Streaming
typescript
const stream = await client.chat.completions.create({
model: "deepseek-v4-pro",
messages: [{ role: "user", content: "Tell me a fun fact about octopi." }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}Errors
typescript
import OpenAI from "openai";
try {
await client.chat.completions.create({...});
} catch (e) {
if (e instanceof OpenAI.APIError) {
if (e.status === 429) {
// rate-limited — SDK already retried; surface to caller
} else if (e.status === 409 && (e.error as any)?.type === "no_capacity") {
// no replica available — retry with backoff
}
}
throw e;
}Edge runtimes
The OpenAI SDK supports Cloudflare Workers, Deno, Bun, and Vercel Edge. Hoonify works the same way — global anycast on the API, fetch-based transport, no Node APIs in the request path.
typescript
// Vercel Edge / Cloudflare Workers
export const runtime = "edge";
import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.hoonify.ai/v1",
apiKey: env.HOONIFY_API_KEY, // platform-provided env binding
});Related: Python SDK · OpenAI compatibility