{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sunbird-ai/json-schema/sunbird-ai-worker-translation-response-schema.json",
  "title": "WorkerTranslationResponse",
  "description": "Translation worker output wrapped with job-execution metadata.",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/sunbird-ai-api-openapi.json#/components/schemas/WorkerTranslationResponse",
  "properties": {
    "delayTime": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Delaytime",
      "description": "Time spent waiting in queue (ms)"
    },
    "executionTime": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Executiontime",
      "description": "Time spent executing the job (ms)"
    },
    "id": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Id",
      "description": "Unique job identifier"
    },
    "output": {
      "anyOf": [
        {
          "$ref": "#/$defs/WorkerTranslationOutput"
        },
        {
          "type": "null"
        }
      ],
      "description": "The translation output data"
    },
    "status": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Status",
      "description": "Job status (e.g., COMPLETED, FAILED)"
    },
    "workerId": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Workerid",
      "description": "Identifier of the worker that processed the job"
    },
    "usage": {
      "anyOf": [
        {
          "$ref": "#/$defs/TokenUsage"
        },
        {
          "type": "null"
        }
      ],
      "description": "Token usage for the Sunflower translation call"
    }
  },
  "additionalProperties": true,
  "type": "object",
  "$defs": {
    "TokenUsage": {
      "properties": {
        "prompt_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Prompt Tokens",
          "description": "Tokens in the prompt/input"
        },
        "completion_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Completion Tokens",
          "description": "Tokens in the generated completion"
        },
        "total_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Total Tokens",
          "description": "Total tokens consumed"
        }
      },
      "type": "object",
      "title": "TokenUsage",
      "description": "Token usage statistics, OpenAI field names."
    },
    "WorkerTranslationOutput": {
      "properties": {
        "text": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Text",
          "description": "Translated text output"
        },
        "translated_text": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Translated Text",
          "description": "Alternative translated text field"
        },
        "source_language": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Source Language",
          "description": "Source language code if returned"
        },
        "target_language": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Target Language",
          "description": "Target language code if returned"
        },
        "Error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Error",
          "description": "Error message if translation failed"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "title": "WorkerTranslationOutput",
      "description": "Output returned by the translation worker.\n\nWorkers differ in the field they use for the translated text, so both\n`text` and `translated_text` are accepted."
    }
  }
}