arazzo: 1.0.1
info:
  title: AlefBot transcription workflow
  version: 1.0.0
  summary: Upload, transcribe, track, and download a media file.
sourceDescriptions:
- name: alefBotPublicApi
  url: https://alef-bot.top/api/v1/openapi.json
  type: openapi
workflows:
- workflowId: transcribeFile
  summary: Create a transcription from a local media file.
  inputs:
    type: object
    required:
    - file
    - filename
    - contentType
    - sizeBytes
    properties:
      file:
        type: string
        contentMediaType: application/octet-stream
        description: The local media bytes to upload.
      filename:
        type: string
      contentType:
        type: string
      sizeBytes:
        type: integer
      outputFormat:
        type: string
        enum:
        - srt
        - txt
        - docx
        default: srt
  steps:
  - stepId: reserveUpload
    operationId: createUpload
    requestBody:
      contentType: application/json
      payload:
        filename: $inputs.filename
        content_type: $inputs.contentType
        size_bytes: $inputs.sizeBytes
    successCriteria:
    - condition: $statusCode == 201
    outputs:
      uploadId: $response.body#/upload_id
  - stepId: transferMedia
    operationId: uploadBinary
    parameters:
    - name: upload_id
      in: path
      value: $steps.reserveUpload.outputs.uploadId
    requestBody:
      contentType: application/octet-stream
      payload: $inputs.file
    successCriteria:
    - condition: $statusCode == 200
  - stepId: startTranscription
    operationId: createTranscription
    requestBody:
      contentType: application/json
      payload:
        upload_id: $steps.reserveUpload.outputs.uploadId
        translate_to_hebrew: false
        model_tier: standard
        output_format: srt
    successCriteria:
    - condition: $statusCode == 200 || $statusCode == 202
    outputs:
      jobId: $response.body#/job_id
  - stepId: trackTranscription
    operationId: getTranscription
    parameters:
    - name: job_id
      in: path
      value: $steps.startTranscription.outputs.jobId
    successCriteria:
    - condition: $statusCode == 200
    - condition: $response.body#/status == 'completed'
    onFailure:
    - name: retryUntilCompleted
      type: retry
      retryAfter: 2
      retryLimit: 60
      criteria:
      - condition: $statusCode == 200 && $response.body#/status != 'completed'
  - stepId: downloadArtifact
    operationId: getTranscriptionArtifact
    parameters:
    - name: job_id
      in: path
      value: $steps.startTranscription.outputs.jobId
    - name: format
      in: query
      value: $inputs.outputFormat
    successCriteria:
    - condition: $statusCode == 200
