Text Generator > Blog > New Summarization API with Max Length Control
Precise Control Over Summary Length
New Parameter: max_length
We're excited to announce a new feature in our summarization API that gives you precise control over the length of your summaries.
The API now accepts a max_length
parameter, allowing you to specify the maximum number of characters in the generated summary.
Key Features
- Control summary length up to 15,000 characters
- Maintain coherence and key information density
- Perfect for content adaptation across different platforms
Step 1 - Get an API Key
Sign Up to Text-Generator.io then get your API key
Step 2 - Start Summarizing
import requests
import os
API_KEY = os.getenv("TEXT_GENERATOR_API_KEY")
if API_KEY is None:
raise Exception(
"Please set TEXT_GENERATOR_API_KEY environment variable, login to https://text-generator.io to get your API key")
headers = {"secret": API_KEY}
def generate_summary(text, max_length=1000):
params = {
"text": text,
"max_length": max_length
}
response = requests.post(
"https://api.text-generator.io/api/v1/summarization",
json=params,
headers=headers
)
return response.json()["summary"]
# Example usage
long_text = """
Climate change is one of the most pressing challenges facing our world today.
It affects everything from weather patterns to agriculture, from sea levels to biodiversity.
Scientists have observed numerous indicators of climate change, including rising global temperatures,
melting ice caps, and increasing frequency of extreme weather events. These changes have far-reaching
implications for human society, ecosystems, and the planet's future...
"""
# Generate a brief summary (300 characters)
short_summary = generate_summary(long_text, max_length=300)
print("Short summary:", short_summary)
# Generate a detailed summary (1000 characters)
detailed_summary = generate_summary(long_text, max_length=1000)
print("Detailed summary:", detailed_summary)
Use Cases
- Social media content adaptation (Twitter, LinkedIn, etc.)
- News article summarization
- Document abstract generation
- Content briefs and executive summaries
Under the Hood
Our summarization API uses advanced natural language processing techniques to:
- Identify key information and main topics
- Maintain context and coherence while reducing length
- Adapt the summary style based on the target length
- Ensure grammatical correctness and readability
Pricing
Access to the summarization API is included in all our standard plans. Start summarizing today with our flexible pricing options.
Future Developments
We're continuously working on improving our summarization capabilities. Upcoming features include:
- Multi-language support
- Topic-focused summarization
- Customizable summary styles
- Batch processing capabilities
Try examples yourself at: Text Generator Docs
Sign up