InferHoodInferHood

SDKs

Libraries to connect your application to InferHood.

Official InferHood SDK

@inferhood/sdk is the official TypeScript and JavaScript client. It ships full type definitions, typed error classes, and async-iterable streaming, and is published on npm under the @inferhood scope.

bash
npm install @inferhood/sdk
# or
pnpm add @inferhood/sdk
# or
yarn add @inferhood/sdk

Chat completions

typescript
import { InferHood } from '@inferhood/sdk';

const client = new InferHood({
  apiKey: process.env.INFERHOOD_API_KEY!,
});

const response = await client.chat.completions.create({
  model: 'openai/gpt-4o',
  messages: [{ role: 'user', content: 'What is InferHood?' }],
});

console.log(response.choices[0].message.content);

Streaming

Pass stream: true to receive an async iterable of chunks.

typescript
const stream = await client.chat.completions.create({
  model: 'anthropic/claude-sonnet-4',
  messages: [{ role: 'user', content: 'Tell me a story' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}

// Or collect the whole response at once
const text = await stream.text();

Error handling

Failures are thrown as typed errors carrying the HTTP status and the request ID from the response.

typescript
import { InferHood, InferHoodError, InferHoodTimeoutError } from '@inferhood/sdk';

try {
  const response = await client.chat.completions.create({ /* ... */ });
} catch (err) {
  if (err instanceof InferHoodError) {
    // status, type, code, requestId — requestId matches the
    // x-inferhood-request-id response header for support lookups
    console.error(err.status, err.type, err.code, err.requestId);
  } else if (err instanceof InferHoodTimeoutError) {
    console.error('Request timed out');
  }
}

Configuration

Only apiKey is required. Override baseURL to point at a self-hosted gateway, and timeout to change the 60-second default.

typescript
const client = new InferHood({
  apiKey: process.env.INFERHOOD_API_KEY!,
  baseURL: 'https://api.inferhood.xyz/v1',
  timeout: 60_000,
  defaultHeaders: { 'X-My-App': 'my-agent' },
});

OpenAI SDK compatibility

Because InferHood conforms to the OpenAI API standard, the official OpenAI SDKs work as-is — useful when you are migrating an existing codebase or working in a language the InferHood SDK does not cover yet. You only need to change the baseURL.

JavaScript / TypeScript

bash
npm install openai

Python

bash
pip install openai

cURL Examples

You can always interact directly via standard HTTP requests. Useful for testing or environments where installing an SDK is not possible.

bash
curl https://api.inferhood.xyz/v1/models \
  -H "Authorization: Bearer $INFERHOOD_API_KEY"

Other languages

Python and Go clients are on the roadmap. Until then, use the OpenAI SDK for your language against the InferHood baseURL, or call the REST API directly.