Search by

sharpapi / laravel-content-summarize

dawid-makowski

AI Text Summarization for Laravel powered by SharpAPI.com

Package info

github.com/sharpapi/laravel-content-summarize

pkg:composer/sharpapi/laravel-content-summarize

Statistics

Installs: 2

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-09-24 15:17 UTC

This package is auto-updated.

Last update: 2026-09-24 15:21:09 UTC


README

SharpAPI GitHub cover

Content Summarize API for Laravel

🚀 Powerful AI text summarization capabilities for your Laravel applications.

Latest Version on Packagist Total Downloads

Check the details at SharpAPI's Content Summarize API page.

Requirements

  • PHP >= 8.1
  • Laravel >= 10.48.29

Installation

Follow these steps to install and set up the SharpAPI Laravel Content Summarize API package.

  1. Install the package via composer:
composer require sharpapi/laravel-content-summarize
  1. Register at SharpAPI.com to obtain your API key.

  2. Set the API key in your .env file:

SHARP_API_KEY=your_api_key_here
  1. [OPTIONAL] Publish the configuration file:
php artisan vendor:publish --tag=sharpapi-content-summarize

Key Features

  • Text Summarization: Generate concise summaries of long-form content
  • Customizable Length: Control the length of the generated summaries
  • Multi-language Support: Summarize content in multiple languages
  • Preserve Key Information: Maintain the most important points from the original text
  • AI-Powered: Leverage advanced AI models for high-quality summarization

Usage

You can inject the ContentSummarizeService class to access the text summarization functionality.

Basic Workflow

  1. Summarize Text: Use the service to generate concise summaries of your content.

Controller Example

Here is an example of how to use ContentSummarizeService within a Laravel controller:

<?php

namespace App\Http\Controllers;

use GuzzleHttp\Exception\GuzzleException;
use SharpAPI\ContentSummarize\ContentSummarizeService;

class SummarizeController extends Controller
{
    protected ContentSummarizeService $summarizeService;

    public function __construct(ContentSummarizeService $summarizeService)
    {
        $this->summarizeService = $summarizeService;
    }

    /**
     * @throws GuzzleException
     */
    public function summarizeText(string $text)
    {
        // summarize() returns a status URL; fetchResults() polls until the job is done.
        // In production, run this in a queued job rather than an HTTP request.
        $statusUrl = $this->summarizeService->summarize($text);
        $job = $this->summarizeService->fetchResults($statusUrl);

        return response()->json(['summary' => $job->result->summary ?? null]);
    }

    /**
     * @throws GuzzleException
     */
    public function summarizeWithOptions(string $text)
    {
        // Options are positional: language (full name), max length, voice tone, context
        $statusUrl = $this->summarizeService->summarize($text, 'English', 200, 'neutral');
        $job = $this->summarizeService->fetchResults($statusUrl);

        return response()->json(['summary' => $job->result->summary ?? null]);
    }
}

Handling Guzzle Exceptions

All requests are managed by Guzzle, so it's helpful to be familiar with Guzzle Exceptions.

Example:

use GuzzleHttp\Exception\ClientException;

try {
    $statusUrl = $this->summarizeService->summarize($longText);
} catch (ClientException $e) {
    echo $e->getMessage();
}

Optional Configuration

You can customize the configuration by setting the following environment variables in your .env file:

SHARP_API_KEY=your_api_key_here
SHARP_API_BASE_URL=https://sharpapi.com/api/v1

Response Format

{
    "data": {
        "type": "api_job_result",
        "id": "5fa45f0e-6680-4f64-8528-3f085a87bd2f",
        "attributes": {
            "status": "success",
            "type": "content_summarize",
            "result": {
                "summary": "Max Verstappen thinks the Las Vegas Grand Prix is more showbiz than sport, while Lewis Hamilton and Fernando Alonso are soaking up the glitz. Expect hydraulic platforms, light shows, and maybe some racing. Don't knock it 'til you try it!"
            }
        }
    }
}

AI agents (Laravel Boost)

This package ships a Laravel Boost skill, sharpapi-content-summarize. It teaches AI coding agents the async submit-then-fetchResults() flow, the queued-job recipe, the result shape and the testing approach. Boost 2 or newer is required. In your app:

composer require laravel/boost --dev
php artisan boost:install          # first time
php artisan boost:update --discover # already using Boost

Select sharpapi/laravel-content-summarize when Boost lists the packages it found. The skill loads on demand; no always-on guideline is added.

Support & Feedback

For issues or suggestions, please:

Changelog

Please see CHANGELOG for a detailed list of changes.

Credits

License

The MIT License (MIT). Please see License File for more information.

Follow Us

Stay updated with news, tutorials, and case studies: