Download the PHP package droath/edenai without Composer
On this page you can find all versions of the php package droath/edenai. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download droath/edenai
More information about droath/edenai
Files in droath/edenai
Package edenai
Short Description Modern, type-safe PHP SDK for the EdenAI API with PSR compliance and immutable DTOs
License MIT
Homepage https://github.com/droath/edenai
Informations about the package edenai
EdenAI PHP SDK
A modern, type-safe PHP SDK for the EdenAI API. Built with strict type safety, immutability, and PSR standards compliance, this SDK provides a robust foundation for integrating AI capabilities into your PHP applications.
Features:
- Fully typed with PHP 8.3+ features (readonly properties, enums, strict types)
- PSR-compliant (PSR-7, PSR-17, PSR-18)
- Extensible middleware pipeline architecture
- Automatic retry logic with exponential backoff
- Comprehensive exception handling
- Immutable DTOs for type-safe request/response handling
Requirements
- PHP 8.3 or higher
- A PSR-18 HTTP client (e.g., Guzzle)
- PSR-17 HTTP factories
Installation
Install the package via Composer:
You'll also need a PSR-18 HTTP client. We recommend Guzzle:
Configuration
Set your EdenAI API credentials as environment variables:
Or configure them directly when instantiating the client (see Basic Usage below).
Basic Usage
Quick Start
The simplest way to get started is to use environment variables:
Explicit Configuration
You can also configure the client explicitly:
Audio Resources
The SDK provides comprehensive support for Eden AI's audio processing endpoints:
Speech-to-Text (Async)
Upload audio files for asynchronous transcription:
Supported Audio Formats: mp3, wav, flac, ogg
Text-to-Speech (Sync)
Generate audio from text synchronously:
Text-to-Speech (Async)
Generate audio from text asynchronously:
AI Service Providers
The ServiceProviderEnum provides type-safe provider selection:
Error Handling for Audio Endpoints
Audio operations include specific exceptions:
Advanced Usage
Custom Middleware
Extend the middleware pipeline with custom middleware:
The middleware pipeline executes in this order:
- Custom middleware (if provided)
- AuthenticationMiddleware (injects API key)
- ErrorHandlingMiddleware (maps HTTP errors to exceptions)
- RetryMiddleware (retries transient failures)
- HTTP client (sends the request)
Exception Handling
The SDK provides typed exceptions for different error scenarios:
Request DTOs
Request DTOs provide validation and type safety for API requests. All audio request DTOs validate their inputs at construction time:
Response DTOs
Response DTOs parse API responses with type transformations:
Response Metadata
Access HTTP metadata separately from business data:
Testing
Running the Test Suite
Run all tests (excluding sandbox tests):
This runs the complete test suite including unit tests, feature tests, integration tests, and architecture tests. Sandbox tests requiring real API credentials are excluded by default.
Running Sandbox Tests
Sandbox tests make real API calls to EdenAI and require valid API credentials. These tests are excluded from CI/CD to control API costs and rate limits.
To run sandbox tests locally:
-
Create a
.env.testingfile in the project root: -
Add your EdenAI API key to
.env.testing: - Run sandbox tests:
Important: Sandbox tests are excluded from automated CI/CD pipelines and must be run manually with your own API credentials. Never commit your .env.testing file to version control.
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Travis Tomka
- All Contributors
License
The MIT License (MIT). Please see License File for more information.
All versions of edenai with dependencies
php-http/discovery Version ^1.20
psr/http-client Version ^1.0
psr/http-factory Version ^1.1
psr/http-message Version ^2.0