Skip to main content

Rephrase

The Paraphrase and Rephrase endpoints offer paraphrasing for particular styles. Given an input sentence, the endpoint returns output sentences that preserve meaning but use alternative phrasings or styles.

Try it out

Note that while the paraphrases/rephrases retain the same general meaning, they vary in how much they differ from the input sentence. Put another way, while the syntax and terminology of the input may change, the semantics should be preserved.

Paraphrase POST

DEPRECATED Please instead use the Rephrase endpoint with mapping set to paraphrase.

The paraphrase endpoint provides alternative phrasings of an input text while preserving meaning and intent. An example input might be: "How are you?" with the output paraphrases, "How's it going?", "What's up?", and "How are you doing?".

https://api.sapling.ai/api/v1/paraphrase

HTTP method: POST

Sample Code

curl -X POST https://api.sapling.ai/api/v1/paraphrase \
-H "Content-Type: application/json" \
-d '{
"key":"<api-key>",
"text":"How are you?",
}'

Sample Response

{
"results": [
{
"hash": "26d70b5b-333f-52f2-9abe-7bdac7dfe95f",
"model_version": "v20230414",
"original": "How are you?",
"rephrase_type": "paraphrase",
"replacement": "What is your current state of affairs?"
},
{
"hash": "9db4d831-f526-5ee3-b43a-f4ad02c0e2fa",
"model_version": "v20230414",
"original": "How are you?",
"rephrase_type": "paraphrase",
"replacement": "How are you doing?"
},
{
"hash": "0f100133-1b07-5157-b61e-d25d13cdfa27",
"model_version": "v20230414",
"original": "How are you?",
"rephrase_type": "paraphrase",
"replacement": "What's your current state of affairs?"
}
]
}

Request Parameters

key: String
32-character API key

text: String
Input query to paraphrase.

diversity: Float [Coming soon]
Ranges from 0 to 1. 0 means to not encourage diversity beyond the usual sampling. 1 means to make the outputs as diverse as possible (while still preserving semantics).

num_results: Integer [Coming soon]
Number of results to return. The minimum is 1. The maximum will depend on other settings, but is generally around 8. Contact us if you need additional results. Additional results will incur additional costs.

Response Parameters

results: JSON, array of paraphrases. Sample structure:

Rephrase POST

In addition to the paraphrase endpoint, the rephrase endpoint also offers a few style transformations:

  • Informal to Formal: Given a casual/informal input text, generate a more formal/professional output. You can test the endpoint here.
  • Passive to Active: Generate sentence in active voice given sentence in passive voice. You can test the endpoint here.
  • Long to Short: This is offered by Sapling's summarize endpoint.
  • Split: Given a long sentence, split it into two sentences. You can test the endpoint here.

https://api.sapling.ai/api/v1/rephrase

HTTP method: POST

Sample Code

curl -X POST https://api.sapling.ai/api/v1/rephrase \
-H "Content-Type: application/json" \
-d '{
"key":"<api-key>",
"text":"hey wuts going on",
"mapping":"informal_to_formal"
}'

Sample Response

{
"results": [
{
"hash": "5c09974f-3fae-560d-9982-ba3ff7087fff",
"model_version": "v20220514",
"original": "hey wuts going on",
"rephrase_type": "informal_to_formal",
"replacement": "What is going on, please?"
},
{
"hash": "e8392c8f-c190-58df-84ef-887a29a78d2c",
"model_version": "v20220514",
"original": "hey wuts going on",
"rephrase_type": "informal_to_formal",
"replacement": "I am unaware of what is going on."
},
{
"hash": "e4dd013c-e79c-5031-ab74-4614703c3f16",
"model_version": "v20220514",
"original": "hey wuts going on",
"rephrase_type": "informal_to_formal",
"replacement": "What is going on?"
},
{
"hash": "8b593139-7353-50a9-8c99-e59a82d16031",
"model_version": "v20220514",
"original": "hey wuts going on",
"rephrase_type": "informal_to_formal",
"replacement": "Hey, what is happening?"
}
]
}

Request Parameters

key: String
32-character API key

text: String
Input query to rephrase.

mapping String
The model to use. Available models include paraphrase, informal_to_formal, passive_to_active, active_to_passive, and sentence_split. Additionally, there is a switch_tone option where tone_mapping should also be specified.

tone_mapping String
If mapping is set to switch_tone, then tone_mapping will be used for the target tone. Available options include: straightforward, confident, friendly, and empathetic. Please contact us if you want additional tones to be added.

diversity: Float [Coming soon]
Ranges from 0 to 1. 0 means to not encourage diversity beyond the usual sampling. 1 means to make the outputs as diverse as possible (while still preserving semantics).

num_results: Integer [Coming soon]
Number of results to return. The minimum is 1. The maximum will depend on other settings, but is generally around 8. Contact us if you need additional results. Additional results will incur additional costs.

Response Parameters

results: JSON, array of rephrases. Sample structure: