Skip to content
looot docs
Esc
↑↓navigate↵open⌘Jpreview
On this page

Replicate / Generate an image

Replicate HTTP API tool replicate-models-predictions on looot: input fields, $0.003 per result, output shape, and code to run it with curl, JavaScript or Python.

Generates images with one of 5 official Replicate models: FLUX schnell, FLUX dev, FLUX 1.1 pro, Ideogram v3 turbo and Recraft v3. Send model_owner, model_name and input (the model’s own inputs, e.g. prompt). The run is asynchronous; the result is the finished prediction with image URLs in output. As the image.generate job it defaults to FLUX schnell.

Inputs

Name Type Required Description
input object yes The model’s input as a JSON object. The input schema depends on what model you are running. To see the available inputs, click the “API” tab on the model you are running or get the model version and look at its openapi_schema property. For example, stability-ai/sdxl takes prompt as an input. Files should be passed as HTTP URLs or data URLs. Use an HTTP URL when: - you have a large file > 256kb - you want to be able to use…
stream boolean no This field is deprecated. Request a URL to receive streaming output using server-sent events (SSE). This field is no longer needed as the returned prediction will always have a stream entry in its urls property if the model supports streaming.
webhook string no An HTTPS URL for receiving a webhook when the prediction has new output. The webhook will be a POST request where the request body is the same as the response body of the get prediction operation. If there are network problems, we will retry the webhook a few times, so make sure it can be safely called more than once. Replicate will not follow redirects when sending webhook requests to your service, so be sure to specify a…
webhook_events_filter array no By default, we will send requests to your webhook URL whenever there are new outputs or the prediction has finished. You can change which events trigger webhook requests by specifying webhook_events_filter in the prediction request: - start: immediately on prediction start - output: each time a prediction generates an output (note that predictions can generate multiple outputs) - logs: each time log output is generated by a prediction - completed: when the prediction reaches a termi…
model_name string yes Official model to run: black-forest-labs/flux-schnell ($0.003 per output image), black-forest-labs/flux-dev ($0.025 per output image), black-forest-labs/flux-1.1-pro ($0.04 per output image), ideogram-ai/ideogram-v3-turbo ($0.03 per output image), recraft-ai/recraft-v3 ($0.04 per output image).
model_owner string yes Owner of the official model.

Output

The run’s result holds the provider’s answer. Signed in, looot inspect replicate-models-predictions prints its fields.

Run it

Every call needs your API token in LOOOT_TOKEN; Sign in shows how to get one. Each run also needs a new idempotency key, so a retry never pays twice. With wait: 30 the answer comes back inline when the run ends within 30 seconds. Otherwise you get the running run back: poll GET /v1/runs/<runId>.

Example input with placeholder values:

curl -X POST "https://api.looot.ai/v1/runs" \
  -H "Authorization: Bearer $LOOOT_TOKEN" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{"endpointId":"replicate-models-predictions","input":{"model_owner":"<model_owner>","model_name":"<model_name>","input":{"prompt":"Tell me a joke","system_prompt":"You are a helpful assistant"},"webhook":"https://example.com/webhook","webhook_events_filter":["https://example.com/webhook","https://example.com/webhook"]},"wait":30}'
const response = await fetch("https://api.looot.ai/v1/runs", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.LOOOT_TOKEN}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    endpointId: "replicate-models-predictions",
    input: {
      model_owner: "<model_owner>",
      model_name: "<model_name>",
      input: {
        prompt: "Tell me a joke",
        system_prompt: "You are a helpful assistant",
      },
      webhook: "https://example.com/webhook",
      webhook_events_filter: ["https://example.com/webhook", "https://example.com/webhook"],
    },
    wait: 30,
  }),
});
const run = await response.json();
console.log(run.status, run.result);
import os
import uuid

import requests

response = requests.post(
    "https://api.looot.ai/v1/runs",
    headers={
        "Authorization": f"Bearer {os.environ['LOOOT_TOKEN']}",
        "Idempotency-Key": str(uuid.uuid4()),
    },
    json={
        "endpointId": "replicate-models-predictions",
        "input": {
            "model_owner": "<model_owner>",
            "model_name": "<model_name>",
            "input": {
                "prompt": "Tell me a joke",
                "system_prompt": "You are a helpful assistant",
            },
            "webhook": "https://example.com/webhook",
            "webhook_events_filter": ["https://example.com/webhook", "https://example.com/webhook"],
        },
        "wait": 30,
    },
    timeout=90,
)
run = response.json()
print(run["status"], run.get("result"))

To let looot pick among every provider of this job instead, send job:image.generate as endpointId; see the job page.

Was this page helpful?