post https://api.ai21.com/studio/v1/summarize
Overview
Summarizes the provided text from that text only, without adding additional information available during the model pre-training. Responses are in 1-2 sentence snippets.
Optionally add a free-text focus
topic, which will limit the summary to information in the source material about the requested topic.
Examples
from ai21 import AI21Client
client = AI21Client(api_key=<<AI21_API_KEY>>)
def summarize():
response = client.summarize.create(
source="https://en.wikipedia.org/wiki/Blue_whale",
source_type="URL",
focus="interbreeding"
)
print(response.summary
# Response
Blue whales are closely related to sei whales, with gene flow between minke whales and blue whales.
Blue whales are known to interbreed with fin whales. A 21-meter (70 ft) pregnant female whale caught off Iceland in 1986 was found to have a blue whale mother and a fin whale father, and its fetus was sired by a blue whale.
In 2024, a genome analysis of North Atlantic blue whales found that 3.5% of their genome was derived from hybridization with fin whales.
Chilean blue whales may overlap with Antarctica blue whales and Eastern North Pacific blue whales in the Eastern Tropical Pacific.
ROOT_URL = "https://api.ai21.com/studio/v1/"
def summarize():
url = ROOT_URL + "summarize"
response = requests.post(
url,
headers={"Authorization": f"Bearer {AI21_API_KEY}"},
json={
"source":"https://en.wikipedia.org/wiki/Blue_whale",
"sourceType":"URL",
"focus":"interbreeding"
}
)
print(response.json()["summary"])
# Response
Blue whales are closely related to sei whales and have significant gene flow with minke whales.
Blue whales are known to interbreed with fin whales. A 21-meter (70 ft) pregnant female whale caught off Iceland in 1986 had a blue whale mother and a fin whale father, and its fetus was sired by a blue whale.
In 2024, a genome analysis of North Atlantic blue whales found that 3.5% of their genome was derived from hybridization with fin whales.
Chilean blue whales may overlap with Antarctica blue whales and Eastern North Pacific blue whales in the Eastern Tropical Pacific.