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 "X-API-Key: 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={"X-API-Key": "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: { "X-API-Key": "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 |
urls.cancel | string | URL to cancel the prediction |
urls.get | string | URL to re-fetch this prediction |
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 |