API reference

Updated at:

The AIWorkflow (AI analysis workflow) module of the AI Education App Server submits AI analysis workflow tasks for ApsaraVideo VOD media assets and returns the analysis results to your client. This reference describes the request parameters, response structures, data models, and error codes of the operations that the module currently provides.

Prerequisites

  • The App Server runs locally or is deployed to Function Compute.

  • An AI workflow is available in the ApsaraVideo VOD console. SubmitWorkflowJob requires the ID of this workflow.

  • The configuration file of the App Server specifies the ak and sk credentials and the region.

API specifications

Basic information

Item

Description

Request URL

http://localhost:9000 when you run the service locally. After you deploy the service to Function Compute, replace it with the public endpoint of the function.

Request method

GET or POST. All request samples in this topic use POST.

Content-Type

application/x-www-form-urlencoded.

Character encoding

UTF-8.

Call sequence

The operations in the AIWorkflow module are chained in the following order:

  1. Call SubmitWorkflowJob with the media asset ID (MediaId) and the AI workflow ID (WorkflowId) to start an AI analysis workflow task.

  2. Call GetWorkflowTask with the workflow task ID (TaskId) and check the returned Status field until it becomes Success or Fail.

  3. After Status becomes Success, call GetMediaAiAnalysis or GetMediaAiAnalysisByResultType with the same MediaId to get the AI analysis results.

Response formats

Operations in the AIWorkflow module fall into two categories. Note the difference in response structures when you integrate them:

  • Pass-through operations — SubmitWorkflowJob, GetWorkflowTask, and GetMediaAiAnalysis. Their response structures are the same as those of the corresponding OpenAPI operations in ApsaraVideo VOD.

  • Structured operation — GetMediaAiAnalysisByResultType. It parses the raw JSON string into a structured object before returning it, so that your client can use the result directly.

    GetMediaAiAnalysis and GetMediaAiAnalysisByResultType return the same AI analysis data in different formats. The following table describes how to choose between them.

Requirement

Operation

(Recommended) Use the analysis results in a client without extra parsing, or filter the results by result type.

GetMediaAiAnalysisByResultType

Keep the response identical to the corresponding OpenAPI operation in ApsaraVideo VOD, or parse the raw content string in your own code.

GetMediaAiAnalysis

Workflow management

Important

Before using the AIWorkflow module, you must submit a ticket to request activation of AIWorkflow and obtain a workflow ID.

SubmitWorkflowJob: Submit a workflow task

Submits an AI analysis workflow task for a specified media asset. Request path: /SubmitWorkflowJob. The response structure is the same as that of the SubmitWorkflowJob operation.

The following table describes the request parameters.

Parameter

Type

Required

Description

MediaId

String

Yes

The ID of the ApsaraVideo VOD media asset.

WorkflowId

String

Yes

The ID of the AI workflow.

regionId

String

No

The region ID. If you leave this parameter blank, the region in the configuration file is used.

Sample request:

curl -X POST http://localhost:9000/SubmitWorkflowJob \
  -d 'MediaId=YOUR_MEDIA_ID&WorkflowId=YOUR_WORKFLOW_ID&regionId=cn-shanghai'

Sample response:

{
  "RequestId": "xxx",
  "JobId": "job_xxx"
}

GetWorkflowTask: Query a workflow task

Queries the execution status and result of a workflow task by task ID. Request path: /GetWorkflowTask. The response structure is the same as that of the GetWorkflowTask operation.

The following table describes the request parameters.

Parameter

Type

Required

Description

TaskId

String

Yes

The ID of the workflow task.

Sample request:

curl -X POST http://localhost:9000/GetWorkflowTask \
  -d 'TaskId=YOUR_TASK_ID'

Sample response:

{
  "RequestId": "xxx",
  "WorkflowTask": {
    "TaskId": "task_xxx",
    "Status": "Success",
    "MediaId": "media_xxx",
    "CreateTime": "2026-01-01T00:00:00Z"
  }
}

The following table describes the valid values of the task status (Status).

Value

Description

Init

Initialized. The task is submitted but has not started.

Processing

In progress. Poll the task at intervals of at least several seconds to avoid frequent calls.

Success

Succeeded. Call GetMediaAiAnalysis or GetMediaAiAnalysisByResultType to get the AI analysis results.

Fail

Failed. Check the media asset and the workflow configuration based on the returned information.

AI analysis results

GetMediaAiAnalysis: Get raw AI analysis results

Gets the raw AI analysis data of a media asset as a JSON string. Request path: /GetMediaAiAnalysis.For details, please see GetMediaAiAnalysis.

The response of this operation is cached for 5 minutes.

The following table describes the request parameter MediaId.

Parameter

Type

Required

Description

MediaId

String

Yes

The ID of the ApsaraVideo VOD media asset.

Sample request:

curl -X POST http://localhost:9000/GetMediaAiAnalysis \
  -d 'MediaId=YOUR_MEDIA_ID'

Sample response:

{
  "RequestId": "xxx",
  "AiAnalysisResultList": {
    "AiAnalysisResult": [
      {
        "Title": "Video summary",
        "ResultType": "Summary",
        "Extra": "",
        "Content": "{...}"
      },
      {
        "Title": "Video chapters",
        "ResultType": "Chapter",
        "Extra": "",
        "Content": "[{...}]"
      }
    ]
  }
}

GetMediaAiAnalysisByResultType: Get analysis results by result type

Gets the AI analysis results of a media asset, filters them by ResultType, and returns structured objects that your client can use directly. Request path: /GetMediaAiAnalysisByResultType.

The following table describes the request parameters.

Parameter

Type

Required

Description

MediaId

String

Yes

The ID of the ApsaraVideo VOD media asset.

ResultType

String

No

The result type filter. Valid values: Summary, Chapter. If you leave this parameter blank, all result types are returned.

Sample requests:

# Get the summary
curl -X POST http://localhost:9000/GetMediaAiAnalysisByResultType \
  -d 'MediaId=YOUR_MEDIA_ID&ResultType=Summary'

# Get the chapters
curl -X POST http://localhost:9000/GetMediaAiAnalysisByResultType \
  -d 'MediaId=YOUR_MEDIA_ID&ResultType=Chapter'

# Get all result types
curl -X POST http://localhost:9000/GetMediaAiAnalysisByResultType \
  -d 'MediaId=YOUR_MEDIA_ID'

Sample response for ResultType=Summary:

{
  "AiAnalysisResult": [
    {
      "Title": "Video summary",
      "ResultType": "Summary",
      "Extra": "",
      "SummaryContent": {
        "ParagraphSummary": "This video mainly covers...",
        "ConversationalSummary": [],
        "MindMapSummary": [],
        "MarkdownContent": "# Video summary..."
      }
    }
  ]
}

For the definitions of the returned fields, see the Data models section.

Data models

The following models define the fields of the AI analysis results that the AIWorkflow module returns.

AiAnalysisResponse

The top-level response structure of AI analysis results. It contains only the AiAnalysisResult field.

Field

Type

Description

AiAnalysisResult

List

The list of AI analysis results.

AiAnalysisResult

A single AI analysis result.

Field

Type

Description

Title

String

The title of the result.

ResultType

String

The result type. Valid values: Summary, Chapter.

Extra

String

Additional information.

Content

String

The raw content string. This field is blank after the content is parsed into a structured object.

SummaryContent

SummaryContent

The structured content when ResultType is Summary.

ChapterContentItems

List of ChapterContentItem

The structured content when ResultType is Chapter.

SummaryContent

The structured content of the Summary result type.

Field

Type

Description

ParagraphSummary

String

The paragraph summary.

ConversationalSummary

List of ConversationalSummary

The conversational summary, organized by speaker.

MindMapSummary

List of MindMapSummary

The mind map summary.

MarkdownContent

String

The summary content in Markdown, which you can render directly.

ConversationalSummary

An element of the conversational summary.

Field

Type

Description

SpeakerId

String

The speaker ID.

SpeakerName

String

The name of the speaker.

Summary

String

The summary content of the speaker.

MindMapSummary

An element of the mind map summary.

Field

Type

Description

Title

String

The title of the node.

Topic

List

The list of subtopics.

ChapterContentItem

A content element of the Chapter result type.

Field

Type

Description

ChapterId

Integer

The ID of the chapter.

ChapterTitle

String

The title of the chapter.

StartTime

Long

The start time of the chapter, in milliseconds.

EndTime

Long

The end time of the chapter, in milliseconds.

ThumbnailUrl

String

The URL of the chapter thumbnail.

Summary

String

The summary of the chapter.

KnowledgePoints

List of KnowledgePoint

The key points covered in the chapter.

KnowledgePoint

An element of the key points.

Field

Type

Description

PointId

Integer

The ID of the key point.

Point

String

The name of the key point.

Description

String

The description of the key point.

Error codes

HTTP status codes

Status code

Description

200

The request is successful.

400

Invalid request parameters. This error usually occurs when a required parameter is missing. Check parameters such as MediaId, WorkflowId, and TaskId.

500

Internal server error. Check the server logs to locate the exception.

Business messages

Message

Description

Empty input parameter

A required parameter is missing. Check required parameters such as MediaId, WorkflowId, and TaskId.

Common ApsaraVideo VOD error codes

Error code

Description

Solution

InvalidAccessKeyId.NotFound

The AccessKey does not exist.

Check whether the ak value in the configuration file is correct and whether it is disabled or deleted.

SignatureDoesNotMatch

The signature is invalid.

Check whether the sk value in the configuration file is correct, including leading and trailing spaces.

InvalidParameter

The parameter is invalid.

Check the parameter format and value range.

MediaNotExist

The media asset does not exist.

Make sure that MediaId is correct and that the media asset is in the configured region.

For the complete list of error codes, see Public error codes.