Replicate
Haal een Replicate prediction op
Voer een query uit op GET /replicate/v1/predictions/ om details van een Replicate prediction en realtime voortgang op te halen op basis van task-ID voor workflows voor beeldgeneratie.
GET
/
replicate
/
v1
/
predictions
/
{id}
cURL
curl "https://api.cometapi.com/replicate/v1/predictions/<prediction_id>" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import time
import requests
prediction_id = "<prediction_id>"
headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}
while True:
prediction = requests.get(
f"https://api.cometapi.com/replicate/v1/predictions/{prediction_id}",
headers=headers,
).json()
print(prediction["status"])
if prediction["status"] in ("succeeded", "failed", "canceled"):
break
time.sleep(3)
if prediction["status"] == "succeeded":
print(prediction["output"])
const predictionId = "<prediction_id>";
const headers = { Authorization: `Bearer ${process.env.COMETAPI_KEY}` };
let prediction;
while (true) {
prediction = await (await fetch(
`https://api.cometapi.com/replicate/v1/predictions/${predictionId}`, { headers }
)).json();
console.log(prediction.status);
if (["succeeded", "failed", "canceled"].includes(prediction.status)) break;
await new Promise((resolve) => setTimeout(resolve, 3000));
}
if (prediction.status === "succeeded") console.log(prediction.output);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/replicate/v1/predictions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/replicate/v1/predictions/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/replicate/v1/predictions/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/replicate/v1/predictions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<prediction_id>",
"model": "black-forest-labs/flux-schnell",
"status": "succeeded",
"output": [
"https://replicate.delivery/xezq/.../out-0.webp"
],
"error": null
}Gebruik deze endpoint nadat je al een Replicate prediction-id hebt. Deze rapporteert de huidige taakstatus en geeft output-URL’s terug wanneer de prediction is voltooid.
Controleer eerst deze velden
statusom te zien of de prediction nog draait of al is voltooidoutputvoor URL’s van gegenereerde assetserrorvoor fouten aan de kant van de providermetricswanneer je uitvoeringsduur of details over het aantal afbeeldingen nodig hebt
Pollingpatroon
1
Maak eerst de prediction
Begin met Maak een Replicate prediction.
2
Poll op prediction-id
Blijf query’s uitvoeren totdat
status een terminale status heeft en output is gevuld of er een providerfout wordt geretourneerd.3
Sla voltooide assets op
Beschouw geretourneerde asset-URL’s als aflever-URL’s en verplaats ze naar je eigen opslag als je ze langdurig wilt bewaren.
Respons
200 - application/json
Current prediction state.
Laatst gewijzigd op 23 juni 2026
⌘I
cURL
curl "https://api.cometapi.com/replicate/v1/predictions/<prediction_id>" \
-H "Authorization: Bearer $COMETAPI_KEY"import os
import time
import requests
prediction_id = "<prediction_id>"
headers = {"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]}
while True:
prediction = requests.get(
f"https://api.cometapi.com/replicate/v1/predictions/{prediction_id}",
headers=headers,
).json()
print(prediction["status"])
if prediction["status"] in ("succeeded", "failed", "canceled"):
break
time.sleep(3)
if prediction["status"] == "succeeded":
print(prediction["output"])
const predictionId = "<prediction_id>";
const headers = { Authorization: `Bearer ${process.env.COMETAPI_KEY}` };
let prediction;
while (true) {
prediction = await (await fetch(
`https://api.cometapi.com/replicate/v1/predictions/${predictionId}`, { headers }
)).json();
console.log(prediction.status);
if (["succeeded", "failed", "canceled"].includes(prediction.status)) break;
await new Promise((resolve) => setTimeout(resolve, 3000));
}
if (prediction.status === "succeeded") console.log(prediction.output);
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/replicate/v1/predictions/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.cometapi.com/replicate/v1/predictions/{id}"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://api.cometapi.com/replicate/v1/predictions/{id}")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/replicate/v1/predictions/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"id": "<prediction_id>",
"model": "black-forest-labs/flux-schnell",
"status": "succeeded",
"output": [
"https://replicate.delivery/xezq/.../out-0.webp"
],
"error": null
}