Intelligent document summarization uses AI to condense long documents into brief summaries that highlight key points. Instead of reading an entire document, you submit the text through the OSS API and receive a generated summary — saving time when processing large volumes of content.
Prerequisites
Before you begin, make sure that:
Your OSS bucket is bound to an Intelligent Media Management (IMM) project. To bind a bucket using the OSS console, see Quick start. To bind using the IMM API, see AttachOSSBucket.
You have the required permissions.
Limitations
| Constraint | Detail |
|---|---|
| Processing mode | Synchronous only (x-oss-process) |
| Request method | POST only |
| Anonymous access | Not supported |
| Maximum input size | 19,500 bytes (for the content parameter) |
How it works
Submit a POST request with the x-oss-process=doc/summarize parameter. Pass the text to summarize as a URL-safe Base64-encoded value in the content parameter.
The document name in the request path (for example, example.doc) is a placeholder only. Intelligent document summarization reads the content parameter value — not the document file itself.
Response formats:
| Format | format value | Behavior |
|---|---|---|
| JSON (default) | json | Returns a single response packet with the complete summary. |
| SSE | event-stream | Returns multiple packets using server-sent events (SSE). Each packet contains the summary text accumulated so far. Use this for streaming output. |
API reference
Action: doc/summarize
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
content | string | Yes | Text to summarize, encoded in URL-safe Base64. Maximum 19,500 bytes. |
format | string | No | Response format. Valid values: json (default), event-stream. |
Response parameters
| Parameter | Type | Description |
|---|---|---|
RequestId | string | The request ID. |
Output | struct | The output object. Contains Text and FinishReason. |
Output.Text | string | The generated summary. |
Output.FinishReason | string | Task status. null: still running. stop: completed. |
Use the RESTful API
JSON mode
Encode the text to summarize in URL-safe Base64 and include it in the content parameter. The response returns the complete summary in a single JSON packet.
Sample request:
POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
x-oss-process=doc/summarize,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65Lit5Z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5ZG96L-Q55qE5rex5YWl5YmW5p6Q77yM5Y-N5pig5LqG5bCB5bu656S-5Lya5pyr5pyf5aSn5a625peP55qE6I2j5p6v5YW06KGw5ZKM56S-5Lya546w5a6e55qE5rex5Yi75o-t56S644CC6L-Z5Zub5aSn5ZCN6JGX77yM5ZCE5YW354m56Imy77yM5ZCE5pyJ5Y2D56eL77yM5LiN5LuF5Zyo5Lit5Zu95paH5a2m5Y-y5LiK55WZ5LiL5LqG5rWT5aKo6YeN5b2p55qE5LiA56yU77yM5pu05Zyo5LiW55WM5paH5a2m6aKG5Z-f5YaF5Lqn55Sf5LqG5rex6L-c5b2x5ZON77yM5oiQ5Li65LqG5Lit5Y2O5paH5YyW5LiN5Y-v5oiW57y655qE6YeN6KaB57uE5oiQ6YOo5YiG44CCSample response:
HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:09:00 GMT
Content-Type: application/json;charset=UTF-8
Connection: close
x-oss-request-id: 676144309D4E643133E487D4
x-oss-server-time: 2010
Content-Encoding: gzip
{
"RequestId": "676144309D4E643133E487D4",
"Output": {
"Text": "\"The Old Man and the Sea\" by Ernest Hemingway is a narrative about an elderly fisherman, Santiago, who embarks on an epic journey to catch a massive marlin. The story delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.",
"FinishReason": "stop"
}
}SSE mode
Set format to event-stream to receive the summary as a stream. Each packet contains the full summary text accumulated up to that point. The final packet has FinishReason: "stop".
Sample request:
POST /example.doc?x-oss-process HTTP/1.1
Host: doc-demo.oss-cn-hangzhou.aliyuncs.com
Date: Fri, 28 Oct 2022 06:40:10 GMT
Authorization: OSS4-HMAC-SHA256 Credential=LTAI********************/20250417/cn-hangzhou/oss/aliyun_v4_request,Signature=a7c3554c729d71929e0b84489addee6b2e8d5cb48595adfc51868c299c0c218e
x-oss-process=doc/summarize,format_event-stream,content__5Zub5aSn5ZCN6JGX77yM6KKr6KqJ5Li65L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q654mp5ZG96L-Q55qE5rex5YWl5YmW5p6Q77yM5Y-N5pig5LqG5bCB5bu656S-5Lya5pyr5pyf5aSn5a625peP55qE6I2j5p6v5YW06KGw5ZKM56S-5Lya546w5a6e55qE5rex5Yi75o-t56S644CC6L-Z5Zub5aSn5ZCN6JGX77yM5ZCE5YW354m56Imy77yM5ZCE5pyJ5Y2D56eL77yM5LiN5LuF5Zyo5Lit5Zu95paH5a2m5Y-y5LiK55WZ5LiL5LqG5rWT5aKo6YeN5b2p55qE5LiA56yU77yM5pu05Zyo5LiW55WM5paH5a2m6aKG5Z-f5YaF5Lqn55Sf5LqG5rex6L-c5b2x5ZON77yM5oiQ5Li65LqG5Lit5Y2O5paH5YyW5LiN5Y-v5oiW57y655qE6YeN6KaB57uE5oiQ6YOo5YiG44CCSample response:
HTTP/1.1 200 OK
Server: AliyunOSS
Date: Thu, 10 Aug 2023 11:20:11 GMT
Content-Type: text/event-stream;charset=UTF-8
Transfer-Encoding: chunked
Connection: close
x-oss-request-id: 669F7CE338492236349AF037
x-oss-server-time: 587
id: 0
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The","FinishReason":"null"}}
id: 1
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old","FinishReason":"null"}}
...
id: 20
event: Result
data: {"RequestId":"669F7CE338492236349AF037","Output":{"Text":"\"The Old Man and the Sea\" by Ernest Hemingway narrates the story of Santiago, an elderly fisherman, and his arduous journey to catch a massive marlin. The narrative delves into themes of human endurance, perseverance, and the struggle against nature. Santiago's steadfast resolve and dignity amidst challenges highlight the resilience of the human spirit.","FinishReason":"stop"}}Use OSS SDKs
All examples below encode the content as URL-safe Base64 and use doc/summarize to submit the request. The document name in the request path is a placeholder — the SDK does not read the document file.
Java
Requires OSS SDK for Java V3.17.4 or later.
import com.aliyun.oss.*;
import com.aliyun.oss.common.auth.*;
import com.aliyun.oss.common.comm.SignVersion;
import com.aliyun.oss.common.utils.BinaryUtil;
import com.aliyun.oss.common.utils.IOUtils;
import com.aliyun.oss.model.GenericResult;
import com.aliyun.oss.model.ProcessObjectRequest;
import java.io.IOException;
import java.util.Formatter;
public class Demo {
public static void main(String[] args) throws ClientException, com.aliyuncs.exceptions.ClientException {
// Specify the endpoint of the region in which the bucket is located.
String endpoint = "http://oss-cn-hangzhou.aliyuncs.com";
// Specify the ID of the Alibaba Cloud region in which the bucket is located.
String region = "cn-hangzhou";
// Obtain access credentials from environment variables. Before you run the sample code,
// make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
EnvironmentVariableCredentialsProvider credentialsProvider = CredentialsProviderFactory.newEnvironmentVariableCredentialsProvider();
// Specify the name of the bucket.
String bucketName = "examplebucket";
// Specify the document name. This is a placeholder — intelligent document summarization
// does not read the document file.
String key = "example.docx";
// Specify the text to summarize.
String content = "yourContent";
String encodeContent = BinaryUtil.toBase64String(content.getBytes()).replaceAll("\\+", "-")
.replaceAll("/", "_").replaceAll("=", "");
ClientBuilderConfiguration clientBuilderConfiguration = new ClientBuilderConfiguration();
clientBuilderConfiguration.setSignatureVersion(SignVersion.V4);
OSS ossClient = OSSClientBuilder.create()
.endpoint(endpoint)
.credentialsProvider(credentialsProvider)
.clientConfiguration(clientBuilderConfiguration)
.region(region)
.build();
try {
StringBuilder sbStyle = new StringBuilder();
Formatter styleFormatter = new Formatter(sbStyle);
styleFormatter.format("doc/summarize,content_%s", encodeContent);
System.out.println(sbStyle.toString());
ProcessObjectRequest request = new ProcessObjectRequest(bucketName, key, sbStyle.toString());
GenericResult processResult = ossClient.processObject(request);
String json = IOUtils.readStreamAsString(processResult.getResponse().getContent(), "UTF-8");
processResult.getResponse().getContent().close();
System.out.println(json);
} catch (OSSException oe) {
System.out.println("Caught an OSSException: " + oe.getErrorMessage());
System.out.println("Error Code: " + oe.getErrorCode());
System.out.println("Request ID: " + oe.getRequestId());
System.out.println("Host ID: " + oe.getHostId());
} catch (ClientException ce) {
System.out.println("Caught a ClientException: " + ce.getMessage());
} catch (IOException e) {
e.printStackTrace();
} finally {
if (ossClient != null) {
ossClient.shutdown();
}
}
}
}PHP
Requires OSS SDK for PHP V2.7.0 or later.
<?php
// Obtain access credentials from environment variables. Before you run the sample code,
// make sure that the OSS_ACCESS_KEY_ID and OSS_ACCESS_KEY_SECRET environment variables are configured.
$ak = getenv('OSS_ACCESS_KEY_ID');
$sk = getenv('OSS_ACCESS_KEY_SECRET');
// Specify the name of the bucket.
$bucket = 'examplebucket';
// Specify the document name. This is a placeholder — intelligent document summarization
// does not read the document file.
$objectKey = 'example.docx';
// Specify the text to summarize.
$txt = "yourContent";
$base64url = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($txt));
$body = sprintf("x-oss-process=doc/summarize,content_%s", $base64url);
$httpVerb = 'POST';
$contentMd5 = base64_encode(md5($body, true));
$contentType = '';
$date = gmdate('D, d M Y H:i:s T');
$stringToSign = $httpVerb . "\n" . $contentMd5 . "\n" . $contentType . "\n" . $date . "\n" . "/{$bucket}/{$objectKey}?x-oss-process";
$signature = base64_encode(hash_hmac('sha1', $stringToSign, $sk, true));
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://{$bucket}.oss-cn-hangzhou.aliyuncs.com/{$objectKey}?x-oss-process");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST');
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Date: ' . $date,
'Authorization: OSS ' . $ak . ':' . $signature,
'Content-Type: ' . $contentType,
'Content-Md5:' . $contentMd5,
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
$response = curl_exec($ch);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($response === false) {
echo "Error: " . curl_error($ch);
} else {
if ($httpcode == 200) {
var_dump($response);
} else {
echo "Error: HTTP code " . $httpcode;
}
}Go
Requires OSS SDK for Go V3.0.2 or later.
package main
import (
"encoding/base64"
"encoding/json"
"fmt"
"io"
"os"
"strings"
"github.com/aliyun/aliyun-oss-go-sdk/oss"
)
type TextData struct {
RequestId string `json:"RequestId"`
Output struct {
Text string `json:"Text"`
FinishReason string `json:"FinishReason"`
} `json:"Output"`
}
func main() {
// Obtain access credentials from environment variables. Before you run the sample code,
// make sure that the OSS_ACCESS_KEY_ID, OSS_ACCESS_KEY_SECRET, and OSS_SESSION_TOKEN
// environment variables are configured.
provider, err := oss.NewEnvironmentVariableCredentialsProvider()
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
client, err := oss.New(
"https://oss-cn-hangzhou.aliyuncs.com", "", "",
oss.SetCredentialsProvider(&provider),
oss.AuthVersion(oss.AuthV4),
oss.Region("cn-hangzhou"),
)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
// Specify the name of the bucket.
bucket, err := client.Bucket("examplebucket")
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
params := make(map[string]interface{})
params["x-oss-process"] = nil
// Specify the text to summarize.
txt := "yourContent"
data := fmt.Sprintf("x-oss-process=doc/summarize,content_%v", base64.URLEncoding.EncodeToString([]byte(txt)))
// example.docx is a placeholder — intelligent document summarization does not read the document file.
response, err := bucket.Do("POST", "example.docx", params, nil, strings.NewReader(data), nil)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
defer response.Body.Close()
jsonData, err := io.ReadAll(response.Body)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
var text TextData
err = json.Unmarshal(jsonData, &text)
if err != nil {
fmt.Println("Error:", err)
os.Exit(-1)
}
fmt.Printf("RequestId: %v\n", text.RequestId)
fmt.Printf("Text: %v\n", text.Output.Text)
fmt.Printf("FinishReason: %v\n", text.Output.FinishReason)
}