{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/civitai/main/json-schema/civitai-workflow-schema.json",
  "title": "Civitai Orchestration Workflow",
  "description": "An orchestration workflow submitted to the Civitai Orchestration API.",
  "type": "object",
  "required": ["id", "status"],
  "properties": {
    "id": { "type": "string" },
    "status": {
      "type": "string",
      "enum": ["unassigned", "preparing", "processing", "succeeded", "failed", "expired", "canceled"]
    },
    "tags": { "type": "array", "items": { "type": "string" } },
    "callbackUrl": { "type": "string", "format": "uri" },
    "callbackEvents": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": ["workflow:*", "workflow:succeeded", "workflow:failed", "workflow:processing", "workflow:expired", "workflow:canceled", "step:*", "job:*"]
      }
    },
    "createdAt": { "type": "string", "format": "date-time" },
    "startedAt": { "type": "string", "format": "date-time" },
    "completedAt": { "type": "string", "format": "date-time" },
    "cost": {
      "type": "object",
      "properties": {
        "base": { "type": "integer", "description": "Buzz cost." },
        "total": { "type": "integer" },
        "currency": { "type": "string", "enum": ["BUZZ"] }
      }
    },
    "steps": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "$type": {
            "type": "string",
            "enum": ["imageGen", "videoGen", "audioGen", "textGen", "transcribe", "tts", "music", "upscale", "interpolate", "training", "comfy", "moderation"]
          },
          "name": { "type": "string" },
          "status": { "type": "string" },
          "input": {
            "type": "object",
            "properties": {
              "engine": { "type": "string" },
              "model": { "type": "string", "description": "AIR identifier." },
              "prompt": { "type": "string" },
              "negativePrompt": { "type": "string" },
              "width": { "type": "integer" },
              "height": { "type": "integer" },
              "aspectRatio": { "type": "string" },
              "steps": { "type": "integer" },
              "cfgScale": { "type": "number" },
              "sampler": { "type": "string" },
              "seed": { "type": "integer" },
              "quantity": { "type": "integer" },
              "additionalNetworks": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "air": { "type": "string" },
                    "strength": { "type": "number" }
                  }
                }
              }
            },
            "additionalProperties": true
          },
          "jobs": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": { "type": "string" },
                "status": { "type": "string" },
                "result": {
                  "type": "object",
                  "properties": {
                    "blobs": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "blobId": { "type": "string" },
                          "url": { "type": "string", "format": "uri" },
                          "mimeType": { "type": "string" },
                          "width": { "type": "integer" },
                          "height": { "type": "integer" },
                          "durationMs": { "type": "integer" },
                          "nsfwLevel": { "type": "integer" }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
