Adjust the tone of text content to professional, relaxed, straightforward, confident, or friendly — without changing the meaning. The feature processes text passed directly in the request; no file content is read.
Prerequisites
Before you begin, make sure that:
An Object Storage Service (OSS) bucket is associated with an Intelligent Media Management (IMM) project. To associate via the OSS console, see Getting started. To associate via API, see AttachOSSBucket.
You have the required permissions.
Constraints
Supports synchronous processing only (
x-oss-process).Requests must use the POST method.
Anonymous access is not supported.
The
contentparameter accepts up to 19,500 bytes.
Parameters
Action: doc/rephrase
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
tone | string | Yes | Target tone. Valid values: professional, relaxed, straightforward, confident, friendly. |
content | string | Yes | Text to rephrase, encoded in URL-safe Base64. Maximum: 19,500 bytes. |
format | string | No | Response format. json (default): returns a single packet with the complete response. event-stream: returns multiple Server-Sent Events (SSE) packets, each containing the full accumulated text. |
Response parameters
| Parameter | Type | Description |
|---|---|---|
RequestId | string | The request ID. |
Output | struct | The output object. Child nodes: Text, FinishReason. |
Text | string | The rephrased content. Parent node: Output. |
FinishReason | string | Task status. null: task is running. stop: task ended. Parent node: Output. |
Use the RESTful API
Specify any filename in the request URL — it serves as a placeholder only. The feature reads only the content parameter value, not the file.Rephrase in regular mode
Processing details
File (placeholder):
example.docText to rephrase: 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.
Tone:
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 in SSE mode
In SSE mode, the response streams as multiple events. Each event contains the full accumulated text so far. The final event has FinishReason: stop.
Processing details
File (placeholder):
example.docText to rephrase: 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.
Tone:
relaxedResponse 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: 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. All SDK examples use the x-oss-process parameter to submit synchronous tone rephrasing requests. Specify any filename in the request — it is a placeholder only; the feature reads only the content parameter.
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)
}