All Products
Search
Document Center

Object Storage Service:Intelligent document tone rephrasing

Last Updated:Sep 12, 2025

You can use the intelligent document tone rephrasing feature to adjust the tone of your document, improve the expressions, and rephrase your document to a more professional, more relaxed, or more straightforward tone.

Prerequisites

An Object Storage Service (OSS) bucket is associated with your Intelligent Media Management (IMM) project. For more information about how to associate an IMM project with an OSS bucket in the OSS console, see Getting started. For more information about how to associate an IMM project with a bucket by calling an API operation, see AttachOSSBucket.

Usage notes

  • Intelligent document tone rephrasing supports only synchronous processing (x-oss-process).

  • You must use the POST method to send requests.

  • Anonymous access will be denied.

  • You must have the required permissions to use the feature. For more information, see permissions.

Parameters

Action: doc/rephrase

The following table describes the parameters.

Parameter

Type

Required

Description

tone

string

Yes

The tone to which you want to rephrase the document. Valid values:

  • professional: more professional.

  • relaxed: more relaxed.

  • straightforward: more straightforward.

  • confident: more confident.

  • friendly: friendlier.

content

string

Yes

The content that you want to rephrase. The content must be encoded in URL-safe Base64.

Note

The content can be up to 19,500 bytes in length.

format

string

No

The mode to return responses. Valid values:

  • json (default): regular mode. A data packet that contains the complete response is returned.

  • event-stream: Server-Sent Events (SSE) mode. Multiple packets are returned. Each packet contains full data.

The following table describes the response parameters.

Parameter

Type

Description

RequestId

string

The request ID.

Output

struct

The output.

Child node: Text and FinishReason

Text

string

The rephrased content.

Parent node: Output

FinishReason

string

The status of the rephrasing task. Valid values:

  • null: The task is running.

  • stop: The task ended.

Parent node: Output

Use the RESTful API

Note

If you use the RESTful API to rephrase documents, you must specify the filename, which is used only as a placeholder. Intelligent document rephrasing only identifies the value of the content parameter as the content to be rephrased.

Rephrase documents in regular mode

Processing method

  • File to be rephrased: example.doc

  • Text to be rephrased: Ernest Hemingway's "The Old Man and the Sea" is a tale of an old fisherman, Santiago, and his epic struggle to catch a giant marlin. This story is a profound exploration of human endurance, perseverance, and the battle against the forces of nature. Santiago's unwavering determination and dignity in the face of adversity serve as a testament to the strength of the human spirit.

  • The tone to be used: relaxed

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/rephrase,tone_relaxed,content_RXJuZXN0IEhlbWluZ3dheSdzICJUaGUgT2xkIE1hbiBhbmQgdGhlIFNlYSIgaXMgYSB0YWxlIG9mIGFuIG9sZCBmaXNoZXJtYW4sIFNhbnRpYWdvLCBhbmQgaGlzIGVwaWMgc3RydWdnbGUgdG8gY2F0Y2ggYSBnaWFudCBtYXJsaW4uIFRoaXMgc3RvcnkgaXMgYSBwcm9mb3VuZCBleHBsb3JhdGlvbiBvZiBodW1hbiBlbmR1cmFuY2UsIHBlcnNldmVyYW5jZSwgYW5kIHRoZSBiYXR0bGUgYWdhaW5zdCB0aGUgZm9yY2VzIG9mIG5hdHVyZS4gU2FudGlhZ28ncyB1bndhdmVyaW5nIGRldGVybWluYXRpb24gYW5kIGRpZ25pdHkgaW4gdGhlIGZhY2Ugb2YgYWR2ZXJzaXR5IHNlcnZlIGFzIGEgdGVzdGFtZW50IHRvIHRoZSBzdHJlbmd0aCBvZiB0aGUgaHVtYW4gc3Bpcml0Lg==

Sample 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
Vary: Accept-Encoding
x-oss-request-id: 67614664D1170E36323E2D22
x-oss-server-time: 2010
Content-Encoding: gzip

{
  "RequestId":"67614664D1170E36323E2D22",
  "Output":{
    "Text":"Ernest Hemingway's \"The Old Man and the Sea\" is a cool little story about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s all about how people keep going even when things get really tough, and how we stand up to nature's challenges with grit and grace. Santiago’s stubborn bravery and his dignity through it all show just how strong the human spirit can be. It’s like, if you ever feel down, just think of this guy battling it out with a huge fish for days!",
    "FinishReason":"stop"
  }
}

Rephrase documents in SSE mode

Processing method

  • File to be rephrased: example.doc

  • Text to be rephrased: Ernest Hemingway's "The Old Man and the Sea" is a tale of an old fisherman, Santiago, and his epic struggle to catch a giant marlin. This story is a profound exploration of human endurance, perseverance, and the battle against the forces of nature. Santiago's unwavering determination and dignity in the face of adversity serve as a testament to the strength of the human spirit.

  • The tone to be used: relaxed

  • Response format: event-stream

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/rephrase,tone_relaxed,format_event-stream,content_RXJuZXN0IEhlbWluZ3dheSdzICJUaGUgT2xkIE1hbiBhbmQgdGhlIFNlYSIgaXMgYSB0YWxlIG9mIGFuIG9sZCBmaXNoZXJtYW4sIFNhbnRpYWdvLCBhbmQgaGlzIGVwaWMgc3RydWdnbGUgdG8gY2F0Y2ggYSBnaWFudCBtYXJsaW4uIFRoaXMgc3RvcnkgaXMgYSBwcm9mb3VuZCBleHBsb3JhdGlvbiBvZiBodW1hbiBlbmR1cmFuY2UsIHBlcnNldmVyYW5jZSwgYW5kIHRoZSBiYXR0bGUgYWdhaW5zdCB0aGUgZm9yY2VzIG9mIG5hdHVyZS4gU2FudGlhZ28ncyB1bndhdmVyaW5nIGRldGVybWluYXRpb24gYW5kIGRpZ25pdHkgaW4gdGhlIGZhY2Ugb2YgYWR2ZXJzaXR5IHNlcnZlIGFzIGEgdGVzdGFtZW50IHRvIHRoZSBzdHJlbmd0aCBvZiB0aGUgaHVtYW4gc3Bpcml0Lg==

Sample 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: 6761463BD5C0693133B15752
x-oss-server-time: 587

id: 0
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Er","FinishReason":"null"}}

id: 1
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest","FinishReason":"null"}}

id: 2
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hem","FinishReason":"null"}}

id: 3
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"","FinishReason":"null"}}

id: 4
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and","FinishReason":"null"}}

id: 5
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is","FinishReason":"null"}}

id: 6
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old","FinishReason":"null"}}

id: 7
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago","FinishReason":"null"}}

id: 8
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure","FinishReason":"null"}}

id: 9
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a","FinishReason":"null"}}

id: 10
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin.","FinishReason":"null"}}

id: 11
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep","FinishReason":"null"}}

id: 12
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans","FinishReason":"null"}}

id: 13
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough","FinishReason":"null"}}

id: 14
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong","FinishReason":"null"}}

id: 15
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on","FinishReason":"null"}}

id: 16
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges.","FinishReason":"null"}}

id: 17
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes","FinishReason":"null"}}

id: 18
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago","FinishReason":"null"}}

id: 19
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up","FinishReason":"null"}}

id: 20
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up and shows just how","FinishReason":"null"}}

id: 21
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up and shows just how resilient the human spirit","FinishReason":"null"}}

id: 22
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up and shows just how resilient the human spirit can be. It","FinishReason":"null"}}

id: 23
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up and shows just how resilient the human spirit can be. It’s a story that","FinishReason":"null"}}

id: 24
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up and shows just how resilient the human spirit can be. It’s a story that’ll make you cheer","FinishReason":"null"}}

id: 25
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up and shows just how resilient the human spirit can be. It’s a story that’ll make you cheer for the underdog","FinishReason":"null"}}

id: 26
event: Result
data: {"RequestId":"6761463BD5C0693133B15752","Output":{"Text":"Ernest Hemingway’s \"The Old Man and the Sea\" is all about an old fisherman named Santiago and his big adventure trying to catch a massive marlin. It’s a deep dive into how humans can push through tough times, stay strong, and take on nature’s challenges. Despite everything that comes his way, Santiago keeps his chin up and shows just how resilient the human spirit can be. It’s a story that’ll make you cheer for the underdog!","FinishReason":"stop"}}

Use OSS SDKs

The following sample code provides examples on how to rephrase a document by using OSS SDKs for common programming languages. If you want to rephrase documents by using SDKs for other programming languages, modify the parameters based on the following sample code.

Java

OSS SDK for Java V3.17.4 or later is required.

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 = "https://oss-cn-hangzhou.aliyuncs.com";
        // Specify the ID of the Alibaba Cloud region in which the bucket is located. Example: cn-hangzhou. 
        String region = "cn-hangzhou";
        // Obtain a credential from the 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 filename, which is used only as a placeholder. Intelligent document rephrasing does not read the content of the file. 
        String key ="example.docx";
        // Specify the text content to be rephrased. 
        String content = "yourTxt";
        String encodeContent = BinaryUtil.toBase64String(content.getBytes()).replaceAll("\\+","-")
                .replaceAll("/","_").replaceAll("=","");

        // Create an OSSClient instance. 
        // Call the shutdown method to release the OSSClient when it is no longer in use.
        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);
            // Create an intelligent document rephrasing instruction. 
            styleFormatter.format("doc/rephrase,tone_straightforward,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, which means your request made it to OSS, "
                    + "but was rejected with an error response for some reason.");
            System.out.println("Error Message:" + 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 an ClientException, which means the client encountered "
                    + "a serious internal problem while trying to communicate with OSS, "
                    + "such as not being able to access the network.");
            System.out.println("Error Message:" + ce.getMessage());
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (ossClient != null) {
                ossClient.shutdown();
            }
        }
    }
}

PHP

OSS SDK for PHP V2.7.0 or later is required.

<?php
// Obtain a credential from the 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. Example: examplebucket. 
$bucket = 'examplebucket';
// Specify the filename, which is used only as a placeholder. Intelligent document rephrasing does not read the content of the file. 
$objectKey = 'example.docx';
// Specify the text content to be rephrased. 
$txt = "yourTxt";

$base64url = str_replace(['+', '/', '='], ['-', '_', ''], base64_encode($txt));
// Create an intelligent document rephrasing instruction. 
$body = sprintf("x-oss-process=doc/rephrase,tone_straightforward,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

OSS SDK for Go V3.0.2 or later is required.

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 a temporary credential from the 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)
	}
	// Create an OSSClient instance. 
	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. Example: examplebucket. 
	bucketName := "examplebucket"
	bucket, err := client.Bucket(bucketName)
	if err != nil {
		fmt.Println("Error:", err)
		os.Exit(-1)
	}
	params := make(map[string]interface{})
	params["x-oss-process"] = nil
        // Specify the text content to be rephrased. 
	txt := "yourTxt"
        // Create an intelligent document rephrasing instruction. 
	data := fmt.Sprintf("x-oss-process=doc/rephrase,tone_straightforward,content_%v", base64.URLEncoding.EncodeToString([]byte(txt)))
        // example.docx is a file in the bucket. It is used as a placeholder. Intelligent document rephrasing does not read the content of the 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)
}