Text Summarization API
Create concise summaries of longer content with customizable modes and lengths. This endpoint helps you extract key information while maintaining context and readability.
Token Usage
This endpoint consumes tokens from your token balance based on the length of the input text and generated summary.
Learn more about billingEndpoint Details
Endpoint
POST /api/summarize
Headers
Content-Type: application/json
X-API-Key: your_api_key_here
Request Body
{
"text": "Your long text to summarize...",
"mode": "general",
"length": "short"
}
Parameter | Type | Required | Description |
---|---|---|---|
text | string | Yes | The text to summarize (must be at least 50 characters). |
mode | string | Yes | The summarization mode to use (e.g., "general"). |
length | string | Yes | Desired summary length: "short" or "long". |
Success Response (200 OK)
{
"id": "summary-id",
"originalText": "Original text that was summarized...",
"summary": "Summarized version of the text...",
"mode": "general",
"length": "short",
"createdAt": "2023-06-15T10:30:00Z",
"wordCount": {
"original": 500,
"summary": 120
},
"tokensUsed": 350
}
Field Descriptions
Field Path | Type | Description |
---|---|---|
id | string | Unique identifier for the summary. |
originalText | string | The original input text. |
summary | string | The generated summary text. |
mode | string | The summarization mode used. |
length | string | The summary length setting used. |
createdAt | string | Timestamp when the summary was generated (ISO 8601). |
wordCount.original | number | Word count of the original text. |
wordCount.summary | number | Word count of the generated summary. |
tokensUsed | number | Number of tokens consumed by this operation. |
Error Responses
Example error for invalid input:
{
"error": "Text must be at least 50 characters long" // Example error
}
Refer to the Error Handling section for details on other potential errors.
Code Examples
Use the following examples to integrate the Text Summarization API.
curl -X POST https://your-api-domain.com/api/summarize \
-H "Content-Type: application/json" \
-H "X-API-Key: your_api_key_here" \
-d '{
"text": "Your long text to summarize...",
"mode": "general",
"length": "short"
}'
Input Requirements
The text must be at least 50 characters long to generate a meaningful summary. For best results with the "long" length option, provide detailed text with multiple paragraphs.