Endpoint
GET https://api.eachlabs.ai/v1/prediction/{id}
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
id | string | Yes | Prediction ID returned from Create Prediction |
Code Examples
curl https://api.eachlabs.ai/v1/prediction/abc123-def456-ghi789 \
-H "Authorization: Bearer YOUR_API_KEY"
import requests
import time
prediction_id = "abc123-def456-ghi789"
while True:
response = requests.get(
f"https://api.eachlabs.ai/v1/prediction/{prediction_id}",
headers={"Authorization": "Bearer YOUR_API_KEY"}
)
data = response.json()
if data["status"] in ("success", "error", "cancelled"):
break
print(f"Status: {data['status']}...")
time.sleep(2)
if data["status"] == "success":
print(f"Output: {data['output']}")
else:
print(f"Failed: {data.get('logs')}")
async function waitForPrediction(predictionId) {
while (true) {
const response = await fetch(
`https://api.eachlabs.ai/v1/prediction/${predictionId}`,
{ headers: { "Authorization": "Bearer YOUR_API_KEY" } }
);
const data = await response.json();
if (["success", "error", "cancelled"].includes(data.status)) {
return data;
}
console.log(`Status: ${data.status}...`);
await new Promise((r) => setTimeout(r, 2000));
}
}
const result = await waitForPrediction("abc123-def456-ghi789");
console.log(`Output: ${result.output}`);
Response
{
"id": "abc123-def456-ghi789",
"input": {
"prompt": "A beautiful sunset over the ocean with vibrant colors",
"aspect_ratio": "16:9"
},
"status": "success",
"output": "https://storage.example.com/predictions/abc123/image.jpg",
"logs": null,
"metrics": {
"predict_time": 12.5,
"cost": 0.05
},
"urls": {
"cancel": "https://api.eachlabs.ai/v1/prediction/abc123-def456-ghi789/cancel",
"get": "https://api.eachlabs.ai/v1/prediction/abc123-def456-ghi789"
}
}
Response Fields
| Field | Type | Description |
|---|---|---|
id | string | Prediction ID |
input | object | Input parameters used |
status | string | created, starting, processing, success, error, or cancelled |
output | string | array | object | Prediction output (type depends on model) |
logs | string | null | Execution logs |
metrics.predict_time | number | Processing time in seconds |
metrics.cost | number | Cost in USD |
metrics.tier | string | Compute tier the execution was billed on (cpu or gpu). Metered engines (Video API) only; omitted for other models |
metrics.billed_seconds | integer | Billed compute seconds. Metered engines only; omitted for other models |
metrics.output_gb | number | Size of the uploaded output artifacts in GB. Metered engines only; omitted for other models |
urls.cancel | string | URL to cancel the prediction |
urls.get | string | URL to re-fetch this prediction |
The
metrics.tier, metrics.billed_seconds, and metrics.output_gb fields appear only on predictions run against metered engines such as the Video API, where they show exactly what the execution was billed for. When present, they are emitted even at zero values — for example, a probe job reports output_gb: 0.Prediction Status Values
| Status | Description |
|---|---|
created | Prediction is queued, not yet started |
starting | Prediction is initializing |
processing | Model is processing the input |
success | Prediction completed successfully |
error | Prediction failed |
cancelled | Prediction was cancelled |
Error Responses
| Status | Body | Description |
|---|---|---|
404 | {"error": "Prediction not found"} | Invalid prediction ID |
500 | {"error": "Internal server error"} | Server error |