sharpapi / laravel-content-summarize
AI Text Summarization for Laravel powered by SharpAPI.com
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/sharpapi/laravel-content-summarize
Requires
- php: ^8.1
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- kongulov/interact-with-enum: ^1.0
- laravel/framework: ^9.0|^10.0|^11.0|^12.0
- sharpapi/php-core: ^1.0
- spatie/url: ^2.4
Requires (Dev)
- laravel/pint: ^1.0
This package is auto-updated.
Last update: 2026-01-09 16:32:12 UTC
README
Content Summarize API for Laravel
🚀 Powerful AI text summarization capabilities for your Laravel applications.
Check the details at SharpAPI's Content Summarize API page.
Requirements
- PHP >= 8.1
- Laravel >= 9.0
Installation
Follow these steps to install and set up the SharpAPI Laravel Content Summarize API package.
- Install the package via
composer:
composer require sharpapi/laravel-content-summarize
-
Register at SharpAPI.com to obtain your API key.
-
Set the API key in your
.envfile:
SHARP_API_KEY=your_api_key_here
- [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
- 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) { $result = $this->summarizeService->summarize($text); return response()->json($result); } /** * @throws GuzzleException */ public function summarizeWithOptions(string $text) { $options = [ 'max_length' => 200, 'language' => 'en', ]; $result = $this->summarizeService->summarize($text, $options); return response()->json($result); } }
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 { $result = $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!"
}
}
}
}
Support & Feedback
For issues or suggestions, please:
Changelog
Please see CHANGELOG for a detailed list of changes.
Credits
- A2Z WEB LTD
- Dawid Makowski
- Enhance your Laravel AI capabilities!
License
The MIT License (MIT). Please see License File for more information.
Follow Us
Stay updated with news, tutorials, and case studies: