Replicate · Arazzo Workflow

Replicate Pick a Model from a Collection and Predict

Version 1.0.0

Read a curated collection, confirm a chosen model, run its latest version, and poll the prediction.

1 workflow 1 source API 1 provider
View Spec View on GitHub Artificial IntelligenceMachine LearningImage GenerationLanguage ModelsModel DeploymentArazzoWorkflows

Provider

replicate

Workflows

collection-predict
Resolve a model from a curated collection and run a prediction on its latest version.
Reads a collection by slug, confirms a chosen model to obtain its latest version, submits a prediction for that version, and polls the prediction until it succeeds, fails, or is canceled.
4 steps inputs: apiToken, collectionSlug, input, modelName, modelOwner outputs: collectionName, latestVersionId, output, predictionId, status
1
getCollection
collections.get
Read the curated collection to confirm it exists and that it lists models to choose from.
2
getModel
models.get
Confirm the chosen model and capture its latest version ID to run.
3
createPrediction
predictions.create
Create a prediction for the chosen model's latest version with the supplied input.
4
getPrediction
predictions.get
Retrieve the prediction state, repeating via the retry branch until the prediction reaches a terminal status.

Source API Descriptions

Arazzo Workflow Specification

replicate-collection-predict-workflow.yml Raw ↑
arazzo: 1.0.1
info:
  title: Replicate Pick a Model from a Collection and Predict
  summary: Read a curated collection, confirm a chosen model, run its latest version, and poll the prediction.
  description: >-
    Replicate groups models into curated collections such as super-resolution or
    text-to-image. This workflow reads a collection, confirms a chosen model
    from it via the model endpoint to resolve its latest version, runs a
    prediction against that version, and polls the prediction until it reaches a
    terminal state. Every step spells out its request inline so the flow can be
    read and executed without opening the underlying OpenAPI description.
  version: 1.0.0
sourceDescriptions:
- name: replicateApi
  url: ../openapi/replicate-openapi.yml
  type: openapi
workflows:
- workflowId: collection-predict
  summary: Resolve a model from a curated collection and run a prediction on its latest version.
  description: >-
    Reads a collection by slug, confirms a chosen model to obtain its latest
    version, submits a prediction for that version, and polls the prediction
    until it succeeds, fails, or is canceled.
  inputs:
    type: object
    required:
    - apiToken
    - collectionSlug
    - modelOwner
    - modelName
    - input
    properties:
      apiToken:
        type: string
        description: Replicate API token used as a Bearer credential.
      collectionSlug:
        type: string
        description: The slug of the collection, like super-resolution or text-to-image.
      modelOwner:
        type: string
        description: The owner of the model chosen from the collection.
      modelName:
        type: string
        description: The name of the model chosen from the collection.
      input:
        type: object
        description: The model's input as a JSON object for the prediction.
  steps:
  - stepId: getCollection
    description: >-
      Read the curated collection to confirm it exists and that it lists models
      to choose from.
    operationId: collections.get
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.apiToken
    - name: collection_slug
      in: path
      value: $inputs.collectionSlug
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      collectionName: $response.body#/name
  - stepId: getModel
    description: >-
      Confirm the chosen model and capture its latest version ID to run.
    operationId: models.get
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.apiToken
    - name: model_owner
      in: path
      value: $inputs.modelOwner
    - name: model_name
      in: path
      value: $inputs.modelName
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      latestVersionId: $response.body#/latest_version/id
  - stepId: createPrediction
    description: >-
      Create a prediction for the chosen model's latest version with the
      supplied input.
    operationId: predictions.create
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.apiToken
    requestBody:
      contentType: application/json
      payload:
        version: $steps.getModel.outputs.latestVersionId
        input: $inputs.input
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      predictionId: $response.body#/id
  - stepId: getPrediction
    description: >-
      Retrieve the prediction state, repeating via the retry branch until the
      prediction reaches a terminal status.
    operationId: predictions.get
    parameters:
    - name: Authorization
      in: header
      value: Bearer $inputs.apiToken
    - name: prediction_id
      in: path
      value: $steps.createPrediction.outputs.predictionId
    successCriteria:
    - condition: $statusCode == 200
    outputs:
      status: $response.body#/status
      output: $response.body#/output
    onSuccess:
    - name: predictionDone
      type: end
      criteria:
      - context: $response.body
        condition: $.status == "succeeded" || $.status == "failed" || $.status == "canceled"
        type: jsonpath
    - name: keepPolling
      type: retry
      retryAfter: 2
      retryLimit: 60
      stepId: getPrediction
      criteria:
      - context: $response.body
        condition: $.status == "starting" || $.status == "processing"
        type: jsonpath
  outputs:
    collectionName: $steps.getCollection.outputs.collectionName
    latestVersionId: $steps.getModel.outputs.latestVersionId
    predictionId: $steps.createPrediction.outputs.predictionId
    status: $steps.getPrediction.outputs.status
    output: $steps.getPrediction.outputs.output