Replicate
إنشاء prediction في Replicate
يقوم POST /replicate/v1/models//predictions بإنشاء صور FLUX عبر تنسيق Replicate على CometAPI، مع نسبة الأبعاد، والجودة، وتنسيق الإخراج، وضبط input.
POST
/
replicate
/
v1
/
models
/
{models}
/
predictions
cURL
curl https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A paper boat floating on calm water at sunrise.",
"aspect_ratio": "1:1",
"output_format": "webp"
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"input": {
"prompt": "A paper boat floating on calm water at sunrise.",
"aspect_ratio": "1:1",
"output_format": "webp",
}
},
)
prediction = response.json()
print(prediction["id"], prediction["status"]) # poll GET /replicate/v1/predictions/{id}const response = await fetch(
"https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
input: {
prompt: "A paper boat floating on calm water at sunrise.",
aspect_ratio: "1:1",
output_format: "webp",
},
}),
}
);
const prediction = await response.json();
console.log(prediction.id, prediction.status); // poll GET /replicate/v1/predictions/{id}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/replicate/v1/models/{models}/predictions",
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([
'input' => [
'prompt' => 'A paper boat floating on calm water at sunrise.',
'aspect_ratio' => '1:1',
'output_format' => 'webp',
'output_quality' => 80
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.cometapi.com/replicate/v1/models/{models}/predictions"
payload := strings.NewReader("{\n \"input\": {\n \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n \"aspect_ratio\": \"1:1\",\n \"output_format\": \"webp\",\n \"output_quality\": 80\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.cometapi.com/replicate/v1/models/{models}/predictions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": {\n \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n \"aspect_ratio\": \"1:1\",\n \"output_format\": \"webp\",\n \"output_quality\": 80\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/replicate/v1/models/{models}/predictions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": {\n \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n \"aspect_ratio\": \"1:1\",\n \"output_format\": \"webp\",\n \"output_quality\": 80\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "q4chw5rey9rmt0cww76t4h3ma4",
"model": "black-forest-labs/flux-schnell",
"version": "hidden",
"input": {
"aspect_ratio": "1:1",
"output_format": "webp",
"output_quality": 80,
"prompt": "A paper boat floating on calm water at sunrise."
},
"logs": "",
"output": null,
"data_removed": false,
"error": null,
"source": "api",
"status": "starting",
"created_at": "2026-03-12T11:27:18.258Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/q4chw5rey9rmt0cww76t4h3ma4/cancel",
"get": "https://api.replicate.com/v1/predictions/q4chw5rey9rmt0cww76t4h3ma4",
"stream": "https://stream.replicate.com/v1/files/example",
"web": "https://replicate.com/p/q4chw5rey9rmt0cww76t4h3ma4"
}
}استخدم هذا المسار لبدء prediction بأسلوب Replicate على CometAPI واسترجاع prediction id لاستخدامه لاحقًا في polling.
قائمة التحقق للطلب الأول
- ضع كل معلمات model داخل الكائن
input - ابدأ بـ
black-forest-labs/flux-schnellللحصول على أسرع طلب أول - اجعل الطلب الأول نصيًا فقط ما لم تكن تحتاج تحديدًا إلى
input_imageأوinput_images - احفظ قيمة
idالمُعادة للتحقق من الحالة
تدفق المهمة
1
إنشاء prediction
أرسل model ID الخاص بالمسار والكائن
input عبر نقطة النهاية هذه.2
تخزين prediction id
احفظ
id المُعاد، لأنك ستحتاج إليه في polling لاحقًا.3
إجراء polling على prediction
تابع إلى الحصول على prediction في Replicate حتى تتم تعبئة
output أو يظهر خطأ.التفويضات
Bearer token authentication. Use your CometAPI key.
معلمات المسار
Replicate model id, for example black-forest-labs/flux-schnell or black-forest-labs/flux-kontext-pro.
الجسم
application/json
Provider-specific model input. Keep all parameters inside this object.
Show child attributes
Show child attributes
⌘I
cURL
curl https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions \
-H "Authorization: Bearer $COMETAPI_KEY" \
-H "Content-Type: application/json" \
-d '{
"input": {
"prompt": "A paper boat floating on calm water at sunrise.",
"aspect_ratio": "1:1",
"output_format": "webp"
}
}'import os
import requests
response = requests.post(
"https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions",
headers={"Authorization": "Bearer " + os.environ["COMETAPI_KEY"]},
json={
"input": {
"prompt": "A paper boat floating on calm water at sunrise.",
"aspect_ratio": "1:1",
"output_format": "webp",
}
},
)
prediction = response.json()
print(prediction["id"], prediction["status"]) # poll GET /replicate/v1/predictions/{id}const response = await fetch(
"https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COMETAPI_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
input: {
prompt: "A paper boat floating on calm water at sunrise.",
aspect_ratio: "1:1",
output_format: "webp",
},
}),
}
);
const prediction = await response.json();
console.log(prediction.id, prediction.status); // poll GET /replicate/v1/predictions/{id}<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.cometapi.com/replicate/v1/models/{models}/predictions",
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([
'input' => [
'prompt' => 'A paper boat floating on calm water at sunrise.',
'aspect_ratio' => '1:1',
'output_format' => 'webp',
'output_quality' => 80
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$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.cometapi.com/replicate/v1/models/{models}/predictions"
payload := strings.NewReader("{\n \"input\": {\n \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n \"aspect_ratio\": \"1:1\",\n \"output_format\": \"webp\",\n \"output_quality\": 80\n }\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
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.cometapi.com/replicate/v1/models/{models}/predictions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"input\": {\n \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n \"aspect_ratio\": \"1:1\",\n \"output_format\": \"webp\",\n \"output_quality\": 80\n }\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.cometapi.com/replicate/v1/models/{models}/predictions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"input\": {\n \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n \"aspect_ratio\": \"1:1\",\n \"output_format\": \"webp\",\n \"output_quality\": 80\n }\n}"
response = http.request(request)
puts response.read_body{
"id": "q4chw5rey9rmt0cww76t4h3ma4",
"model": "black-forest-labs/flux-schnell",
"version": "hidden",
"input": {
"aspect_ratio": "1:1",
"output_format": "webp",
"output_quality": 80,
"prompt": "A paper boat floating on calm water at sunrise."
},
"logs": "",
"output": null,
"data_removed": false,
"error": null,
"source": "api",
"status": "starting",
"created_at": "2026-03-12T11:27:18.258Z",
"urls": {
"cancel": "https://api.replicate.com/v1/predictions/q4chw5rey9rmt0cww76t4h3ma4/cancel",
"get": "https://api.replicate.com/v1/predictions/q4chw5rey9rmt0cww76t4h3ma4",
"stream": "https://stream.replicate.com/v1/files/example",
"web": "https://replicate.com/p/q4chw5rey9rmt0cww76t4h3ma4"
}
}