Inference Logoinference.sh

SDK Overview

The official inference.sh SDKs for Python and JavaScript/TypeScript.

Both SDKs send X-API-Version: 2 on every request, so responses use bare JSON objects and RFC 9457 errors. Raw curl calls without that header get the legacy wrapped format — see REST API versioning.


Installation

1# Installation2pip install inferencesh34# With async support5pip install inferencesh[async]

Quick Start

1from inferencesh import inference23client = inference(api_key="inf_your_key")45# Run an app and wait for result6result = client.tasks.run({7    "app": "infsh/flux",8    "input": {"prompt": "A sunset over mountains"}9})1011print(result["output"])

Client structure

Both SDKs expose namespaced APIs on the client. The JavaScript SDK covers the full REST surface; Python currently ships the core run/chat namespaces.

NamespacePurposePythonJavaScript
tasksRun, get, cancel, list, and stream app tasks
filesUpload, list, get, and delete files
agentsCreate agents and send messages
sessionsList, inspect, keepalive, and end sessions
appsList, create, and manage deployed apps
chatsList and manage chats; getTrace() for agent observability
enginesList, drain, update, and extend cloud engine rentals
flows / flowRunsFlow definitions and run lifecycle (flowRuns.create, stream, streamTasks)
searchProgrammatic /suggest and /search
knowledge / skillsKnowledge and skill CRUD
teams, secrets, apiKeys, integrations, projects, mcpServersWorkspace and connector management

Top-level run() / uploadFile() (JavaScript) and run() / upload_file() (Python) are legacy aliases for tasks.run() and files.upload().

When a namespace is JavaScript-only, call the equivalent REST endpoint from Python until the SDK adds helpers.

Inspect and observability (JavaScript)

MethodREST endpointDescription
client.tasks.getLogs(id)GET /tasks/{id}/logsStructured task log lines
client.tasks.getTimings(id)GET /tasks/{id}/timingsPhase durations from status events
client.tasks.getTelemetry(id)GET /tasks/{id}/telemetryTime-series CPU, RAM, GPU, and volume samples
client.chats.getTrace(id)GET /chats/{id}/traceAgent execution graph (nodes, edges, step counts)

Tasks REST API · Agents REST API · Observability

Both SDKs call the API with X-API-Version: 2 (bare DTOs, RFC 9457 errors). Use inferencesh ≥ v0.7.8 or @inferencesh/sdk ≥ v0.6.11 for the full JavaScript REST surface (knowledge, teams, search, task observability helpers, and related namespaces).

Python SDK · JavaScript SDK · REST API versioning


What's in the SDK?

Running Apps

Execute AI apps on inference.sh infrastructure.

Agent SDK

Build and interact with AI agents programmatically.

Server Proxy

Protect API keys in frontend applications.

Building Apps

Create your own apps to run on inference.sh. → See Extend overview or Extending Apps for the app development guide.


Environment Variables

1import os2from inferencesh import inference34client = inference(api_key=os.environ["INFERENCE_API_KEY"])

TypeScript Support

The JavaScript SDK includes full TypeScript definitions:

typescript
1import type { Task, ApiTaskRequest, InferenceConfig } from '@inferencesh/sdk';

Browser & Node.js

The JavaScript SDK 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 the Server Proxy in production.


Requirements

  • Python 3.8+
  • requests for sync client
  • aiohttp for async client (optional)
  • Node.js 18.0.0+
  • Modern browsers with fetch support

Language references

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.