{
  "openapi": "3.1.0",
  "info": {
    "title": "Create Predictions - General API",
    "version": "1.0.0",
    "description": "Create a Replicate-style prediction on CometAPI and receive a prediction id for later polling."
  },
  "servers": [
    {
      "url": "https://api.cometapi.com"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication. Use your CometAPI key."
      }
    }
  },
  "paths": {
    "/replicate/v1/models/{models}/predictions": {
      "post": {
        "summary": "Create a Replicate prediction",
        "operationId": "create_predictions_general",
        "description": "Submit a prediction request using a model id in the path and a provider-specific `input` object in the body.",
        "parameters": [
          {
            "name": "models",
            "in": "path",
            "required": true,
            "description": "Replicate model id, for example `black-forest-labs/flux-schnell` or `black-forest-labs/flux-kontext-pro`.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input"
                ],
                "properties": {
                  "input": {
                    "type": "object",
                    "description": "Provider-specific model input. Keep all parameters inside this object.",
                    "required": [
                      "prompt"
                    ],
                    "properties": {
                      "prompt": {
                        "type": "string"
                      },
                      "aspect_ratio": {
                        "type": "string",
                        "description": "Common aspect ratios supported by many FLUX models, for example `1:1`, `16:9`, `9:16`, `3:2`, or `2:3`."
                      },
                      "output_format": {
                        "type": "string",
                        "enum": [
                          "webp",
                          "png",
                          "jpg",
                          "jpeg"
                        ]
                      },
                      "output_quality": {
                        "type": "integer",
                        "minimum": 1,
                        "maximum": 100
                      },
                      "input_image": {
                        "type": "string",
                        "description": "Single reference image URL or provider-supported image input for edit or context-aware models such as `flux-kontext-pro`."
                      },
                      "input_images": {
                        "type": "array",
                        "description": "Multiple reference images when the selected Replicate-compatible model supports them.",
                        "items": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "default": {
                  "input": {
                    "prompt": "A paper boat floating on calm water at sunrise.",
                    "aspect_ratio": "1:1",
                    "output_format": "webp",
                    "output_quality": 80
                  }
                }
              },
              "examples": {
                "Validated text-only request": {
                  "summary": "Validated text-only request",
                  "value": {
                    "input": {
                      "prompt": "A paper boat floating on calm water at sunrise.",
                      "aspect_ratio": "1:1",
                      "output_format": "webp",
                      "output_quality": 80
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Prediction accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "model",
                    "input",
                    "output",
                    "error",
                    "status",
                    "created_at",
                    "urls"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "model": {
                      "type": "string"
                    },
                    "version": {
                      "type": "string"
                    },
                    "input": {
                      "type": "object"
                    },
                    "logs": {
                      "type": "string"
                    },
                    "output": {
                      "type": [
                        "array",
                        "null"
                      ],
                      "items": {
                        "type": "string"
                      }
                    },
                    "data_removed": {
                      "type": "boolean"
                    },
                    "error": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "source": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "urls": {
                      "type": "object",
                      "properties": {
                        "cancel": {
                          "type": "string"
                        },
                        "get": {
                          "type": "string"
                        },
                        "stream": {
                          "type": "string"
                        },
                        "web": {
                          "type": "string"
                        }
                      }
                    }
                  },
                  "example": {
                    "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"
                    }
                  }
                }
              }
            }
          }
        },
        "x-codeSamples": [
          {
            "lang": "Shell",
            "label": "Default",
            "source": "curl https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions \\\n  -H \"Authorization: Bearer $COMETAPI_KEY\" \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\n    \"input\": {\n      \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n      \"aspect_ratio\": \"1:1\",\n      \"output_format\": \"webp\"\n    }\n  }'\n"
          },
          {
            "lang": "Python",
            "label": "Default",
            "source": "import os\nimport requests\n\nresponse = requests.post(\n    \"https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions\",\n    headers={\"Authorization\": \"Bearer \" + os.environ[\"COMETAPI_KEY\"]},\n    json={\n        \"input\": {\n            \"prompt\": \"A paper boat floating on calm water at sunrise.\",\n            \"aspect_ratio\": \"1:1\",\n            \"output_format\": \"webp\",\n        }\n    },\n)\n\nprediction = response.json()\nprint(prediction[\"id\"], prediction[\"status\"])  # poll GET /replicate/v1/predictions/{id}\n"
          },
          {
            "lang": "JavaScript",
            "label": "Default",
            "source": "const response = await fetch(\n    \"https://api.cometapi.com/replicate/v1/models/black-forest-labs/flux-schnell/predictions\",\n    {\n        method: \"POST\",\n        headers: {\n            Authorization: `Bearer ${process.env.COMETAPI_KEY}`,\n            \"Content-Type\": \"application/json\",\n        },\n        body: JSON.stringify({\n            input: {\n                prompt: \"A paper boat floating on calm water at sunrise.\",\n                aspect_ratio: \"1:1\",\n                output_format: \"webp\",\n            },\n        }),\n    }\n);\n\nconst prediction = await response.json();\nconsole.log(prediction.id, prediction.status); // poll GET /replicate/v1/predictions/{id}\n"
          }
        ]
      }
    }
  }
}