Inference Logoinference.sh

Running Apps

Call apps programmatically.


Basic usage

Python:

python
1from inferencesh import inference2 3client = inference(api_key="inf_your_key")4 5result = client.run({6    "app": "infsh/echo",7    "input": {"message": "Hello!"}8})9 10print(result["output"])

JavaScript:

javascript
1const result = await client.run({2  app: 'infsh/echo',3  input: { message: 'Hello!' }4});5 6console.log(result.output);

App identifier

Format: username/app-name

Examples:

  • infsh/stable-diffusion
  • myname/my-app

With setup parameters

Setup parameters configure the app before running (e.g., model selection). They affect worker warmth and scheduling:

python
1result = client.run({2    "app": "infsh/flux",3    "setup": {"model": "schnell"},4    "input": {"prompt": "A sunset"}5})

JavaScript:

javascript
1const result = await client.run({2  app: 'infsh/flux',3  setup: { model: 'schnell' },4  input: { prompt: 'A sunset' }5});

Workers with matching setup parameters are considered "warm" and skip the setup phase.


Fire and forget

Start a task without waiting:

python
1task = client.run({2    "app": "slow-app",3    "input": {...}4}, wait=False)5 6print(f"Task ID: {task['id']}")

Check status later.


With cURL

bash
1curl -X POST https://api.inference.sh/apps/run \2  -H "Authorization: Bearer inf_your_key" \3  -H "Content-Type: application/json" \4  -d '{5    "app": "infsh/echo",6    "input": {"message": "Hello!"}7  }'

Private workers

python
1result = client.run({2    "app": "my-app",3    "input": {...},4    "infra": "private"5})

Next

Streaming

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.