Skip to main content
javascript-sdk JavaScript/TypeScript SDK for inference.sh - run AI apps, build agents, integrate 150+ models. Package: @inferencesh/sdk (npm install). Full TypeScript support, streaming, file uploads. Build agents with template or ad-hoc patterns, tool builder API, skills, human approval. Use for: JavaScript integration, TypeScript, Node.js, React, Next.js, frontend apps. Triggers: javascript sdk, typescript sdk, npm install, node.js api, js client, react ai, next.js ai, frontend sdk, @inferencesh/sdk, typescript agent, browser sdk, js integration
Jump to install Skills Marketplace Discover and explore AI skills built by the community.
Install with Codex or Claude Copy this prompt, paste it into Codex, Claude, or another assistant, and let it review the skill page and install it for you.
Copy promptShow prompt details A direct command skips the review prompt. Inspect the source before running it.
npx skills add https://github.com/Sheshiyer/brandmint-oracle-aleph --skill javascript-sdkThe command stays on one line. Scroll horizontally to inspect it before copying.
Prefer a local copy? Download the files currently available to SkillsMP.
Download Zip Downloading... name javascript-sdk description JavaScript/TypeScript SDK for inference.sh - run AI apps, build agents, integrate 150+ models. Package: @inferencesh/sdk (npm install). Full TypeScript support, streaming, file uploads. Build agents with template or ad-hoc patterns, tool builder API, skills, human approval. Use for: JavaScript integration, TypeScript, Node.js, React, Next.js, frontend apps. Triggers: javascript sdk, typescript sdk, npm install, node.js api, js client, react ai, next.js ai, frontend sdk, @inferencesh/sdk, typescript agent, browser sdk, js integration allowed-tools Bash(npm *), Bash(npx *), Bash(node *), Bash(pnpm *), Bash(yarn *)
JavaScript SDK
Build AI applications with the inference.sh JavaScript/TypeScript SDK.
Quick Start
npm install @inferencesh/sdk
import { inference } from '@inferencesh/sdk' ;
const client = inference ({ apiKey : 'inf_your_key' });
const result = await client.run ({
app : 'infsh/flux-schnell' ,
input : { : }
});
. (result. );
prompt
'A sunset over mountains'
console
log
output
Installation npm install @inferencesh/sdk
yarn add @inferencesh/sdk
pnpm add @inferencesh/sdk
Requirements: Node.js 18.0.0+ (or modern browser with fetch)
Authentication import { inference } from '@inferencesh/sdk' ;
const client = inference ({ apiKey : 'inf_your_key' });
const client = inference ({ apiKey : process.env .INFERENCE_API_KEY });
const client = inference ({ proxyUrl : '/api/inference/proxy' });
Get your API key: Settings → API Keys → Create API Key
Running Apps
Basic Execution const result = await client.run ({
app : 'infsh/flux-schnell' ,
input : { prompt : 'A cat astronaut' }
});
console .log (result.status );
console .log (result.output );
Fire and Forget const task = await client.run ({
app : 'google/veo-3-1-fast' ,
input : { prompt : 'Drone flying over mountains' }
}, { wait : false });
console .log (`Task ID: ${task.id} ` );
Streaming Progress const stream = await client.run ({
app : 'google/veo-3-1-fast' ,
input : { prompt : 'Ocean waves at sunset' }
}, { stream : true });
for await (const update of stream) {
console .log (`Status: ${update.status} ` );
if (update.logs ?.length ) {
console .log (update.logs .at (-1 ));
}
}
Run Parameters Parameter Type Description appstring App ID (namespace/name@version) inputobject Input matching app schema setupobject Hidden setup configuration infrastring 'cloud' or 'private' sessionstring Session ID for stateful execution session_timeoutnumber Idle timeout (1-3600 seconds)
File Handling
Automatic Upload const result = await client.run ({
app : 'image-processor' ,
input : {
image : '/path/to/image.png'
}
});
Manual Upload
const file = await client.uploadFile ('/path/to/image.png' );
const file = await client.uploadFile ('/path/to/image.png' , {
filename : 'custom_name.png' ,
contentType : 'image/png' ,
public : true
});
const result = await client.run ({
app : 'image-processor' ,
input : { image : file.uri }
});
Browser File Upload const input = document .querySelector ('input[type="file"]' );
const file = await client.uploadFile (input.files [0 ]);
Sessions (Stateful Execution) Keep workers warm across multiple calls:
const result = await client.run ({
app : 'my-app' ,
input : { action : 'init' },
session : 'new' ,
session_timeout : 300
});
const sessionId = result.session_id ;
const result2 = await client.run ({
app : 'my-app' ,
input : { action : 'process' },
session : sessionId
});
Agent SDK
Template Agents Use pre-built agents from your workspace:
const agent = client.agent ('my-team/support-agent@latest' );
const response = await agent.sendMessage ('Hello!' );
console .log (response.text );
const response2 = await agent.sendMessage ('Tell me more' );
agent.reset ();
const chat = await agent.getChat ();
Ad-hoc Agents Create custom agents programmatically:
import { tool, string , number , appTool } from '@inferencesh/sdk' ;
const calculator = tool ('calculate' )
.describe ('Perform a calculation' )
.param ('expression' , string ('Math expression' ))
.build ();
const imageGen = appTool ('generate_image' , 'infsh/flux-schnell@latest' )
.describe ('Generate an image' )
.param ('prompt' , string ('Image description' ))
.build ();
const agent = client.agent ({
core_app : { ref : 'infsh/claude-sonnet-4@latest' },
system_prompt : 'You are a helpful assistant.' ,
tools : [calculator, imageGen],
temperature : 0.7 ,
max_tokens : 4096
});
const response = await agent.sendMessage ('What is 25 * 4?' );
Available Core Apps Model App Reference Claude Sonnet 4 infsh/claude-sonnet-4@latestClaude 3.5 Haiku infsh/claude-haiku-35@latestGPT-4o infsh/gpt-4o@latestGPT-4o Mini infsh/gpt-4o-mini@latest
Tool Builder API
Parameter Types import {
string , number , integer, boolean ,
enumOf, array, obj, optional
} from '@inferencesh/sdk' ;
const name = string ('User\'s name' );
const age = integer ('Age in years' );
const score = number ('Score 0-1' );
const active = boolean ('Is active' );
const priority = enumOf (['low' , 'medium' , 'high' ], 'Priority' );
const tags = array (string ('Tag' ), 'List of tags' );
const address = obj ({
street : string ('Street' ),
city : string ('City' ),
zip : optional (string ('ZIP' ))
}, 'Address' );
Client Tools (Run in Your Code) const greet = tool ('greet' )
.display ('Greet User' )
.describe ('Greets a user by name' )
.param ('name' , string ('Name to greet' ))
.requireApproval ()
.build ();
App Tools (Call AI Apps) const generate = appTool ('generate_image' , 'infsh/flux-schnell@latest' )
.describe ('Generate an image from text' )
.param ('prompt' , string ('Image description' ))
.setup ({ model : 'schnell' })
.input ({ steps : 20 })
.requireApproval ()
.build ();
Agent Tools (Delegate to Sub-agents) import { agentTool } from '@inferencesh/sdk' ;
const researcher = agentTool ('research' , 'my-org/researcher@v1' )
.describe ('Research a topic' )
.param ('topic' , string ('Topic to research' ))
.build ();
Webhook Tools (Call External APIs) import { webhookTool } from '@inferencesh/sdk' ;
const notify = webhookTool ('slack' , 'https://hooks.slack.com/...' )
.describe ('Send Slack notification' )
.secret ('SLACK_SECRET' )
.param ('channel' , string ('Channel' ))
.param ('message' , string ('Message' ))
.build ();
Internal Tools (Built-in Capabilities) import { internalTools } from '@inferencesh/sdk' ;
const config = internalTools ()
.plan ()
.memory ()
.webSearch (true )
.codeExecution (true )
.imageGeneration ({
enabled : true ,
appRef : 'infsh/flux@latest'
})
.build ();
const agent = client.agent ({
core_app : { ref : 'infsh/claude-sonnet-4@latest' },
internal_tools : config
});
Streaming Agent Responses const response = await agent.sendMessage ('Explain quantum computing' , {
onMessage : (msg ) => {
if (msg.content ) {
process.stdout .write (msg.content );
}
},
onToolCall : async (call) => {
console .log (`\n[Tool: ${call.name} ]` );
const result = await executeTool (call.name , call.args );
agent.submitToolResult (call.id , result);
}
});
File Attachments
import { readFileSync } from 'fs' ;
const response = await agent.sendMessage ('What\'s in this image?' , {
files : [readFileSync ('image.png' )]
});
const response = await agent.sendMessage ('Analyze this' , {
files : ['data:image/png;base64,iVBORw0KGgo...' ]
});
const input = document .querySelector ('input[type="file"]' );
const response = await agent.sendMessage ('Describe this' , {
files : [input.files [0 ]]
});
Skills (Reusable Context) const agent = client.agent ({
core_app : { ref : 'infsh/claude-sonnet-4@latest' },
skills : [
{
name : 'code-review' ,
description : 'Code review guidelines' ,
content : '# Code Review\n\n1. Check security\n2. Check performance...'
},
{
name : 'api-docs' ,
description : 'API documentation' ,
url : 'https://example.com/skills/api-docs.md'
}
]
});
Server Proxy (Frontend Apps) For browser apps, proxy through your backend to keep API keys secure:
Client Setup const client = inference ({
proxyUrl : '/api/inference/proxy'
});
Next.js Proxy (App Router)
import { createRouteHandler } from '@inferencesh/sdk/proxy/nextjs' ;
const route = createRouteHandler ({
apiKey : process.env .INFERENCE_API_KEY
});
export const POST = route.POST ;
Express Proxy import express from 'express' ;
import { createProxyMiddleware } from '@inferencesh/sdk/proxy/express' ;
const app = express ();
app.use ('/api/inference/proxy' , createProxyMiddleware ({
apiKey : process.env .INFERENCE_API_KEY
}));
Supported Frameworks
Next.js (App Router & Pages Router)
Express
Hono
Remix
SvelteKit
TypeScript Support Full type definitions included:
import type {
TaskDTO ,
ChatDTO ,
ChatMessageDTO ,
AgentTool ,
TaskStatusCompleted ,
TaskStatusFailed
} from '@inferencesh/sdk' ;
if (result.status === TaskStatusCompleted ) {
console .log ('Done!' );
} else if (result.status === TaskStatusFailed ) {
console .log ('Failed:' , result.error );
}
Error Handling import { RequirementsNotMetException , InferenceError } from '@inferencesh/sdk' ;
try {
const result = await client.run ({ app : 'my-app' , input : {...} });
} catch (e) {
if (e instanceof RequirementsNotMetException ) {
console .log ('Missing requirements:' );
for (const err of e.errors ) {
console .log (` - ${err.type } : ${err.key} ` );
}
} else if (e instanceof InferenceError ) {
console .log ('API error:' , e.message );
}
}
Human Approval Workflows const response = await agent.sendMessage ('Delete all temp files' , {
onToolCall : async (call) => {
if (call.requiresApproval ) {
const approved = await promptUser (`Allow ${call.name} ?` );
if (approved) {
const result = await executeTool (call.name , call.args );
agent.submitToolResult (call.id , result);
} else {
agent.submitToolResult (call.id , { error : 'Denied by user' });
}
}
}
});
CommonJS Support const { inference, tool, string } = require ('@inferencesh/sdk' );
const client = inference ({ apiKey : 'inf_...' });
const result = await client.run ({...});
Reference Files
Agent Patterns - Multi-agent, RAG, batch processing patterns
Tool Builder - Complete tool builder API reference
Server Proxy - Next.js, Express, Hono, Remix, SvelteKit setup
Streaming - Real-time progress updates and SSE handling
File Handling - Upload, download, and manage files
Sessions - Stateful execution with warm workers
TypeScript - Type definitions and type-safe patterns
React Integration - Hooks, components, and patterns
Related Skills
npx skills add inference-sh/skills@python-sdk
npx skills add inference-sh/skills@inference-sh
npx skills add inference-sh/skills@llm-models
npx skills add inference-sh/skills@ai-image-generation
Documentation Related occupations SOC
Based on SOC occupation classification
More from this repository End-to-end brand identity orchestration system. Generates text strategy, visual assets, campaign copy, video deliverables, and publishing outputs using 44 specialized skills across 9 categories. Chains FAL.AI/Nano Banana/Flux visual generation with brand positioning, buyer personas, and campaign workflows via wave-based execution. Includes Remotion-based programmatic video generation.
Transform markdown documentation folders into professional Astro-based wikis using refero-design principles (research-first, anti-AI-slop: no default emojis, no 3-column layouts, sections + dividers + media blocks over cards, neutral color system). Use when the user has a folder of .md files and wants to generate a polished wiki/documentation site with dark/light mode support, readable typography, and professional aesthetics. Triggers on requests involving markdown-to-wiki conversion, documentation site generation, Astro wiki creation, or brand wiki themes.
Defines brand voice persona and tone calibration using persona and positioning data to produce a reusable meta-prompt for copywriting.