Skip to content

/api/ai/summarize

Generate a concise summary for a given block of text.

Examples

English paragraph

curl -s -X POST http://localhost/api/ai/summarize \
  -H 'Content-Type: application/json' \
  -d '{"text":"Artificial intelligence has emerged as one of the most transformative technologies of our time.","target_lang":"en","length":"short","format":"paragraph"}'

Arabic bullets

curl -s -X POST http://localhost/api/ai/summarize \
  -H 'Content-Type: application/json' \
  -d '{"text":"يُعد الذكاء الاصطناعي من التقنيات الثورية في عصرنا","target_lang":"ar","length":"short","format":"bullets"}'

Strategy header

Scenario x-ai-strategy
Cloudflare Gateway cloudflare_gateway
Gateway alias 404 → vendor cloudflare_gateway_fallback
Gateway disabled (direct provider) provider
Edge fallback (400/401/403/404) edge_fallback

Errors

422 Validation

{
  "type": "https://labeeb.example.com/problems/validation-error",
  "title": "Validation Error",
  "status": 422,
  "detail": "One or more fields contain invalid values.",
  "instance": "/ai/summarize",
  "errors": {"length": ["The selected length is invalid."]}
}

429 Rate Limit

{
  "type": "https://labeeb.example.com/problems/rate-limit-exceeded",
  "title": "Rate Limit Exceeded",
  "status": 429,
  "detail": "Rate limit exceeded. Please retry later.",
  "instance": "/ai/summarize"
}

503 Service Unavailable

{
  "type": "https://labeeb.example.com/problems/service-unavailable",
  "title": "Service Unavailable",
  "status": 503,
  "detail": "The summarization service is currently experiencing issues.",
  "instance": "/ai/summarize"
}