Skip to main content
POST
/
v1
/
prediction
/
run
Run Model Prediction Synchronously
curl --request POST \
  --url https://api.eachlabs.ai/v1/prediction/run \
  --header 'Content-Type: application/json' \
  --header 'X-API-Key: <api-key>' \
  --data '
{
  "model": "eachlabs-llm-router",
  "input": {
    "model": "openai/gpt-4o-mini",
    "messages": [
      {
        "role": "user",
        "content": "Write a one sentence caption."
      }
    ]
  }
}
'
import requests

url = "https://api.eachlabs.ai/v1/prediction/run"

payload = {
    "model": "eachlabs-llm-router",
    "input": {
        "model": "openai/gpt-4o-mini",
        "messages": [
            {
                "role": "user",
                "content": "Write a one sentence caption."
            }
        ]
    }
}
headers = {
    "X-API-Key": "<api-key>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
  method: 'POST',
  headers: {'X-API-Key': '<api-key>', 'Content-Type': 'application/json'},
  body: JSON.stringify({
    model: 'eachlabs-llm-router',
    input: {
      model: 'openai/gpt-4o-mini',
      messages: [{role: 'user', content: 'Write a one sentence caption.'}]
    }
  })
};

fetch('https://api.eachlabs.ai/v1/prediction/run', options)
  .then(res => res.json())
  .then(res => console.log(res))
  .catch(err => console.error(err));
<?php

$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => "https://api.eachlabs.ai/v1/prediction/run",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => json_encode([
    'model' => 'eachlabs-llm-router',
    'input' => [
        'model' => 'openai/gpt-4o-mini',
        'messages' => [
                [
                                'role' => 'user',
                                'content' => 'Write a one sentence caption.'
                ]
        ]
    ]
  ]),
  CURLOPT_HTTPHEADER => [
    "Content-Type: application/json",
    "X-API-Key: <api-key>"
  ],
]);

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
package main

import (
	"fmt"
	"strings"
	"net/http"
	"io"
)

func main() {

	url := "https://api.eachlabs.ai/v1/prediction/run"

	payload := strings.NewReader("{\n  \"model\": \"eachlabs-llm-router\",\n  \"input\": {\n    \"model\": \"openai/gpt-4o-mini\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"Write a one sentence caption.\"\n      }\n    ]\n  }\n}")

	req, _ := http.NewRequest("POST", url, payload)

	req.Header.Add("X-API-Key", "<api-key>")
	req.Header.Add("Content-Type", "application/json")

	res, _ := http.DefaultClient.Do(req)

	defer res.Body.Close()
	body, _ := io.ReadAll(res.Body)

	fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.eachlabs.ai/v1/prediction/run")
  .header("X-API-Key", "<api-key>")
  .header("Content-Type", "application/json")
  .body("{\n  \"model\": \"eachlabs-llm-router\",\n  \"input\": {\n    \"model\": \"openai/gpt-4o-mini\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"Write a one sentence caption.\"\n      }\n    ]\n  }\n}")
  .asString();
require 'uri'
require 'net/http'

url = URI("https://api.eachlabs.ai/v1/prediction/run")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["X-API-Key"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n  \"model\": \"eachlabs-llm-router\",\n  \"input\": {\n    \"model\": \"openai/gpt-4o-mini\",\n    \"messages\": [\n      {\n        \"role\": \"user\",\n        \"content\": \"Write a one sentence caption.\"\n      }\n    ]\n  }\n}"

response = http.request(request)
puts response.read_body
{
  "status": "success",
  "message": "Prediction completed successfully",
  "predictionID": "abc123-def456-ghi789",
  "output": {
    "text": "A cinematic sunset over the ocean."
  },
  "error": ""
}
{
  "error": "slug parameter is required"
}
{
  "error": "Invalid or missing API key"
}
{
  "error": "invalid request body"
}
{
  "error": "Failed to fetch models: internal error"
}

Authorizations

X-API-Key
string
header
required

API key for authentication

Body

application/json
model
string
required

Model slug or identifier

Example:

"flux-1-1-pro"

input
object
required

Input parameters for the prediction

Example:
{
  "prompt": "A beautiful sunset over the ocean with vibrant colors",
  "aspect_ratio": "16:9"
}
version
string
deprecated

Deprecated. This field is ignored. Kept for backwards compatibility.

Example:

"0.0.1"

webhook_url
string<uri>

Optional webhook URL to receive prediction result asynchronously

Example:

"https://your-app.com/webhook"

webhook_secret
string

Optional secret used to sign webhook requests

Example:

"your-secret-key"

Response

Prediction completed or failed synchronously

status
enum<string>

Final terminal status of the synchronous prediction

Available options:
success,
failed,
cancelled
Example:

"success"

message
string

Human-readable message

Example:

"Prediction completed successfully"

predictionID
string

Unique prediction identifier

Example:

"abc123-def456-ghi789"

output

Prediction output, when available

error
string

User-facing error message when the prediction failed

Example:

""

Last modified on June 17, 2026