Inference Logoinference.sh

JavaScript SDK

The official JavaScript/TypeScript client for inference.sh.


Installation

bash
1npm install @inferencesh/sdk2# or3yarn add @inferencesh/sdk4# or5pnpm add @inferencesh/sdk

Quick 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.

Agent SDK

Build and interact with AI agents programmatically.


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 fetch support

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.