{
  "openapi": "3.0.3",
  "info": {
    "title": "TFI API",
    "version": "1.0.0",
    "description": "Endpoints for creating AI talking video jobs and generating signed download paths."
  },
  "servers": [
    {
      "url": "https://api.techforgeinnovate.com",
      "description": "Local development"
    }
  ],
  "paths": {
    "/jobs/v2": {
      "post": {
        "summary": "Trigger AI talking video job",
        "description": "Creates a rendering job for an AI talking video based on supplied media and options.",
        "operationId": "createJobV2",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JobTriggerRequest"
              },
              "example": {
                "image_url": "https://cdn.example.com/image.png",
                "audio_url": "https://cdn.example.com/audio.mp3",
                "is_clone_required": false,
                "language": "en",
                "version": 6,
                "job_type": "ai_talking_video",
                "project_id": "468ea7a0-66e1-4357-a760-236e54167f3e",
                "output_size": 400,
                "crop": true,
                "dynamic_scale": 1,
                "iteration_count": 10,
                "expand_ratio": 0.5,
                "values": []
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Job accepted and queued for processing.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JobResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request payload."
          },
          "401": {
            "description": "Missing or invalid API key."
          }
        }
      }
    },
    "/storage/generate-signed-path": {
      "get": {
        "summary": "Generate signed download path",
        "description": "Returns a temporary signed URL for the requested storage key.",
        "operationId": "generateSignedPath",
        "security": [
          {
            "ApiKeyAuth": []
          }
        ],
        "parameters": [
          {
            "name": "path",
            "in": "query",
            "description": "Storage key to sign (e.g. ai-talking-videos/{projectId}/outputs/{file}.mp4).",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Signed URL generated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/SignedPathResponse"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid API key."
          },
          "404": {
            "description": "Requested path was not found."
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "ApiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "schemas": {
      "JobTriggerRequest": {
        "type": "object",
        "required": [
          "image_url",
          "audio_url",
          "job_type",
          "project_id"
        ],
        "properties": {
          "image_url": {
            "type": "string",
            "format": "uri",
            "description": "Publicly accessible URL for the source image."
          },
          "audio_url": {
            "type": "string",
            "format": "uri",
            "description": "Publicly accessible URL for the narration audio."
          },
          "is_clone_required": {
            "type": "boolean",
            "description": "Whether a clone pass should be performed before rendering."
          },
          "language": {
            "type": "string",
            "description": "Language code for lip-syncing."
          },
          "version": {
            "type": "integer",
            "description": "Model version to use for rendering.",
            "enum": [4, 5, 6],
            "example": 6
          },
          "job_type": {
            "type": "string",
            "description": "Type of job being requested (e.g. ai_talking_video)."
          },
          "project_id": {
            "type": "string",
            "format": "uuid",
            "description": "Project identifier associated with this job."
          },
          "output_size": {
            "type": "integer",
            "description": "Output resolution edge size in pixels."
          },
          "crop": {
            "type": "boolean",
            "description": "Whether to crop the input image before rendering."
          },
          "dynamic_scale": {
            "type": "number",
            "description": "Scaling factor applied during rendering."
          },
          "iteration_count": {
            "type": "integer",
            "description": "Number of refinement iterations to run."
          },
          "expand_ratio": {
            "type": "number",
            "description": "Ratio for expanding the canvas during processing."
          },
          "values": {
            "type": "array",
            "description": "Additional tuning parameters for the renderer.",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "JobResponse": {
        "type": "object",
        "required": [
          "jobId",
          "status"
        ],
        "properties": {
          "jobId": {
            "type": "string",
            "format": "uuid",
            "description": "Unique identifier for the submitted job."
          },
          "status": {
            "type": "string",
            "description": "Current status of the job.",
            "enum": [
              "queued",
              "processing",
              "done",
              "failed"
            ]
          },
          "message": {
            "type": "string",
            "description": "Optional status or error message."
          }
        }
      },
      "SignedPathResponse": {
        "type": "object",
        "required": [
          "signedUrl"
        ],
        "properties": {
          "signedUrl": {
            "type": "string",
            "format": "uri",
            "description": "Time-limited signed URL for downloading the file."
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "description": "Expiration timestamp for the signed URL."
          }
        }
      }
    }
  }
}