The official JavaScript/TypeScript client for inference.sh.
Installation
bash
1npm install @inferencesh/sdk2# or3yarn add @inferencesh/sdk4# or5pnpm add @inferencesh/sdkQuick Start
typescript
1import { inference } from '@inferencesh/sdk';23const client = inference({ apiKey: 'inf_your_key' });45const result = await client.run({6 app: 'infsh/flux',7 input: { prompt: 'A sunset over mountains' }8});910console.log(result.output);What's in the SDK?
Running Apps
Execute AI apps on inference.sh infrastructure.
- Running Apps — Basic task execution
- Sync & Async — Patterns
- Streaming — Real-time updates
- Files — File uploads
Agent SDK
Build and interact with AI agents programmatically.
- Overview — Agent SDK introduction
- Template Agents — Use existing agents
- Ad-hoc Agents — Create agents on-the-fly
- Building Tools — Define custom tools
- Streaming — Handle real-time responses
TypeScript Support
Full type definitions included:
typescript
1import type { Task, ApiTaskRequest, InferenceConfig } from '@inferencesh/sdk';Browser & Node.js
Works in both environments:
typescript
1// Node.js (CommonJS)2const { inference } = require('@inferencesh/sdk');34// ES Modules / TypeScript5import { inference } from '@inferencesh/sdk';67// Browser (ESM CDN)8import { inference } from 'https://esm.sh/@inferencesh/sdk';Note: Never expose API keys in client-side code. Use a backend proxy in production.
Requirements
- Node.js 18.0.0+
- Modern browsers with
fetchsupport