partitech / llamacloud
Simple php client for LamaCloud, LlamaParse and LlamaExtract services
Requires
- symfony/http-client: ^6.4 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
This PHP client provides a simple interface to interact with the LlamaParse API service, allowing you to perform a variety of tasks such as uploading files, retrieving job details, and obtaining results in different formats. Currently, this package only supports LlamaParse, but LlamaCloud and LlamaExtract services will be added as soon as we have time for it :).
Features
- Upload files to the LlamaParse service
- Retrieve job statuses and details
- Access job results in various formats (text, raw text, JSON, Markdown, images)
- Generate presigned URLs for downloading results
- Monitor usage and retrieve parsing history
Installation
Install the package via composer:
composer require partitech/llamacloud
Usage
- Get Supported File Extensions Retrieve a list of supported file extensions.
$client = new Partitech\LlamaCloud\Client($apiKey); $parse = new Partitech\LlamaCloud\Parse($client); $extensions = $parse->getSupportedFileExtensions(); print_r($extensions);
$extensions = $parse->getSupportedFileExtensions(); print_r($extensions);
- Upload File Upload a file to LlamaParse and create a job.
$parameters = ['language' => 'en']; $response = $parse->uploadFile('/path/to/your/file.pdf', $parameters); print_r($response);
- Get Usage Data Retrieve usage data for the parsing service.
$usage = $parse->getUsage(); print_r($usage);
- Get Job By ID Retrieve details of a job using its ID.
$jobDetails = $parse->getJobById('job_id'); print_r($jobDetails);
- Get Parsing Job Details Get detailed information about a specific parsing job.
$jobDetails = $parse->getParsingJobDetails('job_id'); print_r($jobDetails);
- Get Job Text Result Retrieve the parsed text result of a job.
$textResult = $parse->getJobTextResult('job_id'); print_r($textResult);
- Get Job Raw Text Result Retrieve the raw text result of a parsing job.
$rawTextResult = $parse->getJobRawTextResult('job_id'); print_r($rawTextResult);
- Get Job JSON Result Retrieve the parsed JSON result of a job.
$jsonResult = $parse->getJobJsonResult('job_id'); print_r($jsonResult);
- Generate Presigned URL Generate a presigned URL for downloading a file associated with a job.
$presignedUrl = $parse->generatePresignedUrl('job_id', 'filename.pdf'); print_r($presignedUrl);
- Get Job Image Result Retrieve the image result of a parsing job.
$imageResult = $parse->getJobImageResult('job_id', 'image_name.jpg'); header('Content-Type: image/jpeg'); echo $imageResult->getContent();
- Get Parsing History Retrieve the parsing history.
$history = $parse->getParsingHistoryResult(); print_r($history);
Contributions
We welcome contributions to this project! Feel free to fork the repository, submit pull requests, or report any issues. Contributions to support LlamaCloud and LlamaExtract services will be highly appreciated.
License This project is licensed under the MIT License.