Replicate
创建一个 Replicate prediction
POST /replicate/v1/models//predictions 通过 CometAPI 上的 Replicate 格式创建 FLUX 图像,支持宽高比、质量、输出格式和输入调优。
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"
}
}使用此路由可在 CometAPI 上启动一个 Replicate 风格的 prediction,并返回一个 prediction id 以供后续轮询。
首次请求检查清单
- 将每个模型参数都放在
input对象内 - 首次请求建议从
black-forest-labs/flux-schnell开始,以获得最快的响应 - 除非你明确需要
input_image或input_images,否则首次请求请仅使用文本 - 保存返回的 prediction
id,用于状态检查
任务流程
1
创建 prediction
通过此端点提交路径 model id 和
input 对象。2
保存 prediction id
保存返回的
id,因为后续轮询需要用到它。3
轮询 prediction
继续阅读 获取一个 Replicate prediction,直到
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"
}
}