API Reference
A simple, powerful REST API to summarize any text in seconds. Supports 10+ languages, multiple output styles, and real-time streaming.
Overview
SummarizeAPI provides a single HTTP endpoint that accepts raw text and returns a concise, high-quality summary. The API is designed to be minimal and predictable — one endpoint, JSON in, JSON out.
Base URL
Key capabilities
- Multi-language — Summarize and optionally translate to 10+ languages
- Output control — Short, medium, long, or extensive; paragraph, bullets, or mixed
- Writing styles — Professional, casual, academic, technical, simple
- Keyword extraction — Optionally extract 5–7 key terms from the source text
- Streaming — Real-time token-by-token output via Server-Sent Events
Authentication
All requests must include a valid API key in the Authorization header using the Bearer scheme.
Authorization: Bearer YOUR_API_KEY
API key format
API keys follow the format sk_live_xxxxxxxxxxxxxxxxxxxxxxxx (production) or sk_test_xxxxxxxxxxxxxxxxxxxxxxxx (test environment). Keep your key secret — treat it like a password.
Quick Start
Send a POST request to /api/summarize with your text. You'll get a summary back in under 10 seconds.
# Install: curl is available on all platforms curl -X POST https://summarizeapi.com/api/summarize \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{"text": "Your text here..."}'
const summarize = async (text) => { const res = await fetch('https://summarizeapi.com/api/summarize', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ text }) }); const data = await res.json(); console.log(data.summary); }; summarize('Your text here...');
import requests response = requests.post( "https://summarizeapi.com/api/summarize", headers={"Authorization": "Bearer YOUR_API_KEY"}, json={"text": "Your text here..."} ) data = response.json() print(data["summary"])
<?php $response = file_get_contents('https://summarizeapi.com/api/summarize', false, stream_context_create(['http' => [ 'method' => 'POST', 'header' => "Authorization: Bearer YOUR_API_KEY\r\nContent-Type: application/json", 'content' => json_encode(['text' => 'Your text here...']) ]]) ); $data = json_decode($response, true); echo $data['summary'];
Example response
{
"success": true,
"summary": "A concise summary of your text.",
"keywords": null,
"original_length": 1234,
"summary_length": 287,
"processing_time": 3.14,
"requests_remaining": 98
}
Endpoint
The API exposes a single summarization endpoint.
Summarizes the provided text and returns a structured JSON response.
Request headers
| Header | Value | Required |
|---|---|---|
| Authorization | Bearer YOUR_API_KEY |
Required |
| Content-Type | application/json |
Required |
Request Parameters
Send a JSON body with the following fields. Only text is required.
| Parameter | Type | Default | Description |
|---|---|---|---|
| text required |
string | — | Text to summarize. Minimum 50 characters, maximum 50,000 characters. |
| length optional |
string | medium |
Output length.short — 2–3 sentencesmedium — 1 paragraphlong — 2–3 paragraphsextensive — 4–5 paragraphs
|
| style optional |
string | professional |
Writing style.professional casual academic technical simple
|
| format optional |
string | paragraph |
Output format.paragraph — flowing prosebullets — bullet point listmixed — short paragraph + key bullets
|
| outputLang optional |
string | auto |
Output language. Use auto to match the source language, or specify:en fr es de it pt ar zh ja ru
|
| includeKeywords optional |
boolean | false |
When true, extracts 5–7 key terms and returns them in the keywords field. |
Full request example
{
"text": "Artificial intelligence is transforming industries...",
"length": "medium",
"style": "professional",
"format": "paragraph",
"outputLang": "en",
"includeKeywords": true
}
Response Format
All responses are JSON. A successful request returns HTTP 200.
{
"success": true,
"summary": "Generated summary text.",
"keywords": "AI, machine learning, automation, data, neural networks",
"original_length": 1842,
"summary_length": 312,
"processing_time": 2.85,
"requests_remaining": 4997
}
Response fields
| Field | Type | Description |
|---|---|---|
| success | boolean | Always true on success. |
| summary | string | The generated summary text. |
| keywords | string | null | Comma-separated key terms. null when includeKeywords is false. |
| original_length | integer | Character count of the input text. |
| summary_length | integer | Character count of the summary. |
| processing_time | float | Request duration in seconds. |
| requests_remaining | integer | Remaining requests in the current billing period. |
Streaming (SSE)
Append ?stream=1 to receive the summary as a real-time stream of Server-Sent Events. Useful for displaying output progressively in a UI.
Event format
The stream emits data: lines. Each chunk has a type field:
| type | Fields | Description |
|---|---|---|
summary | content | Incremental text token. Append these to build the full summary. |
done | summary | Stream complete. The summary field contains the full text. |
error | error | An error occurred. The stream will close after this event. |
JavaScript streaming example
const streamSummary = async (text, onChunk, onDone) => { const res = await fetch('https://summarizeapi.com/api/summarize?stream=1', { method: 'POST', headers: { 'Authorization': 'Bearer YOUR_API_KEY', 'Content-Type': 'application/json' }, body: JSON.stringify({ text }) }); const reader = res.body.getReader(); const decoder = new TextDecoder(); while (true) { const { done, value } = await reader.read(); if (done) break; const lines = decoder.decode(value).split('\n'); for (const line of lines) { if (!line.startsWith('data: ')) continue; const event = JSON.parse(line.slice(6)); if (event.type === 'summary') onChunk(event.content); if (event.type === 'done') onDone(event.summary); } } }; // Usage streamSummary( 'Your text here...', chunk => process.stdout.write(chunk), full => console.log('\n\nDone. Full summary:', full) );
Errors
Error responses include an error field describing what went wrong. HTTP status codes follow standard conventions.
{
"error": "Invalid API key"
}
| Status | Error | Description |
|---|---|---|
| 400 | Invalid parameters | Missing text, text too short (<50 chars), or malformed JSON body. |
| 401 | Unauthorized | Missing, expired, or invalid API key. Check the Authorization header. |
| 405 | Method not allowed | Only POST requests are accepted. |
| 429 | Rate limit exceeded | Monthly request quota reached. Upgrade your plan or wait until the next billing period. |
| 500 | Server error | An unexpected error occurred. Retry with exponential backoff. If the problem persists, contact support. |
cURL Examples
Complete examples using curl — available on Linux, macOS, and Windows.
Standard request
curl -X POST https://summarizeapi.com/api/summarize \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "text": "Artificial intelligence is reshaping modern industries. From predictive analytics in finance to computer vision in healthcare, AI applications are becoming integral to business strategy. Natural language processing enables machines to understand and generate human text, while reinforcement learning allows systems to optimize complex decisions through trial and error.", "length": "short", "style": "professional", "format": "paragraph", "outputLang": "en", "includeKeywords": true }'
With streaming
curl -X POST "https://summarizeapi.com/api/summarize?stream=1" \ -H "Authorization: Bearer YOUR_API_KEY" \ -H "Content-Type: application/json" \ --no-buffer \ -d '{"text": "Your long text here..."}' # Output (streamed): # data: {"type":"summary","content":"AI is"} # data: {"type":"summary","content":" transform"} # ... # data: {"type":"done","summary":"Full summary text."} # data: [DONE]
JavaScript Examples
Works in browsers and Node.js (v18+). For Node.js <18, install node-fetch.
class SummarizeAPI { constructor(apiKey) { this.apiKey = apiKey; this.baseURL = 'https://summarizeapi.com/api'; } async summarize(text, options = {}) { const res = await fetch(`${this.baseURL}/summarize`, { method: 'POST', headers: { 'Authorization': `Bearer ${this.apiKey}`, 'Content-Type': 'application/json' }, body: JSON.stringify({ text, ...options }) }); if (!res.ok) { const err = await res.json(); throw new Error(err.error); } return res.json(); } } // Usage const client = new SummarizeAPI('YOUR_API_KEY'); const result = await client.summarize( 'Your long text here...', { length: 'medium', style: 'professional', includeKeywords: true } ); console.log('Summary:', result.summary); console.log('Keywords:', result.keywords); console.log('Compression:', Math.round((1 - result.summary_length / result.original_length) * 100) + '%');
// npm install axios const axios = require('axios'); const client = axios.create({ baseURL: 'https://summarizeapi.com/api', headers: { 'Authorization': 'Bearer YOUR_API_KEY' } }); async function summarize(text, options = {}) { const { data } = await client.post('/summarize', { text, ...options }); return data; } summarize('Your long text here...', { length: 'short' }) .then(r => console.log(r.summary)) .catch(e => console.error(e.response?.data?.error));
Python Examples
Requires Python 3.7+ and the requests library (pip install requests).
import requests class SummarizeAPI: BASE_URL = "https://summarizeapi.com/api" def __init__(self, api_key: str): self.session = requests.Session() self.session.headers.update({"Authorization": f"Bearer {api_key}"}) def summarize(self, text: str, **kwargs) -> dict: response = self.session.post( f"{self.BASE_URL}/summarize", json={"text": text, **kwargs} ) response.raise_for_status() return response.json() # Usage client = SummarizeAPI("YOUR_API_KEY") result = client.summarize( text="Artificial intelligence is reshaping industries...", length="medium", style="academic", output_lang="en", include_keywords=True ) print(f"Summary: {result['summary']}") print(f"Keywords: {result['keywords']}") print(f"Reduced by {100 - round(result['summary_length'] / result['original_length'] * 100)}%")
# pip install httpx import asyncio import httpx async def summarize(api_key: str, text: str, **kwargs) -> dict: async with httpx.AsyncClient() as client: response = await client.post( "https://summarizeapi.com/api/summarize", headers={"Authorization": f"Bearer {api_key}"}, json={"text": text, **kwargs} ) response.raise_for_status() return response.json() # Usage result = asyncio.run(summarize( "YOUR_API_KEY", text="Your long text here...", length="short" )) print(result["summary"])
PHP Examples
Works with PHP 7.4+. Uses cURL (enabled by default in most PHP installations).
<?php class SummarizeAPI { private string $apiKey; private string $baseUrl = 'https://summarizeapi.com/api'; public function __construct(string $apiKey) { $this->apiKey = $apiKey; } public function summarize(string $text, array $options = []): array { $payload = json_encode(array_merge(['text' => $text], $options)); $ch = curl_init($this->baseUrl . '/summarize'); curl_setopt_array($ch, [ CURLOPT_RETURNTRANSFER => true, CURLOPT_POST => true, CURLOPT_POSTFIELDS => $payload, CURLOPT_HTTPHEADER => [ 'Authorization: Bearer ' . $this->apiKey, 'Content-Type: application/json' ], CURLOPT_TIMEOUT => 60 ]); $body = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); curl_close($ch); if ($httpCode !== 200) { $err = json_decode($body, true); throw new \RuntimeException($err['error'] ?? 'API error'); } return json_decode($body, true); } } // Usage $client = new SummarizeAPI('YOUR_API_KEY'); $result = $client->summarize( text: 'Artificial intelligence is reshaping industries...', options: ['length' => 'medium', 'includeKeywords' => true] ); echo $result['summary'] . PHP_EOL; echo $result['keywords'] . PHP_EOL;
<?php // composer require guzzlehttp/guzzle use GuzzleHttp\Client; $client = new Client([ 'base_uri' => 'https://summarizeapi.com/api/', 'headers' => ['Authorization' => 'Bearer YOUR_API_KEY'] ]); $response = $client->post('summarize', [ 'json' => [ 'text' => 'Your long text here...', 'length' => 'medium', 'includeKeywords' => true ] ]); $data = json_decode($response->getBody(), true); echo $data['summary'];
Rate Limits
Request limits are enforced per calendar month and reset on the 1st of each month.
| Plan | Requests / month | API access |
|---|---|---|
| Free | 100 | Full API access |
| Professional — €4.99/mo | 5,000 | Full API access + priority queue |
| Business — €19/mo | Unlimited | Full API access + dedicated support + SLA 99.9% |
When you exceed your monthly limit, the API returns HTTP 429. The requests_remaining field in every successful response lets you track usage programmatically.
Changelog
- Initial public release
- REST API with JSON request/response
- Real-time SSE streaming
- 10 output languages
- 5 writing styles, 4 output formats
- API key authentication
- Free tier — 100 requests/month
Have a feature request or found a bug? Contact us — we read every message.