With Client SDKs you can call custom or public AI models with just one line of code!

Prerequisites

  • Select a model from Model Yard
  • Create an API Key

You can use two ways to call a model on Each:

Client SDK

With Client SDK you need to initialize our SDK in your language and then you can use custom methods and calls to Each backend servers.

Initialize SDK

// Please make sure that you run 'npm install @eachlabs/aiflow@latest'
import Each from '@eachlabs/aiflow';

const each = new Each({
    auth: process.env.EACH_API_KEY || 'YOUR_API_KEY'
});

Run Inference

When you call a model, you’ll receive a prediction ID that you can use to check the status and get results. The final response will include the model outputs and additional metadata. Here’s how to make the call and handle the response:

// Start the prediction
const response = await each.predictions.run({
  model: "text-to-song-advanced",
  version: "0.0.1",
  input: {
    "lyrics": "I’m a little teapot, yes it’s true, Here’s an example of what I can do. I can change my handle and my spout, Just tip me over and pour me out!",
    "vocal": "female vocal",
    "mood": "relaxed",
    "genre": "pop"
  },
});

// Response contains the prediction ID
console.log(response);
// {
//     "status": "success", 
//     "message": "Prediction created successfully",
//     "predictionID": "990619d5-9a78-42af-bf6f-90e4add5b228"
// }

// Poll for results using the prediction ID
const result = await each.predictions.get(response.predictionID);
if (result.status === "success") {
    console.log("Prediction completed successfully:", result);
} else if (result.status === "error") {
    console.log("Prediction failed:", result);
} else if (result.status === "cancelled") {
    console.log("Prediction was cancelled:", result);
}

Parse Output

Output can be array, object or stringified JSON. You can parse it as you want. If the model / workflow returns an single URL, you need to parse it as a string.

Console

The easiest way! You can call public or custom model via console. Select your model and you can use ▶ Demo tab on the page.