PHPackages                             demonyka/eden-ai-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. demonyka/eden-ai-sdk

ActiveLibrary[API Development](/categories/api)

demonyka/eden-ai-sdk
====================

Unofficial API SDK for Eden AI

v1.0.3(1y ago)018MITPHPPHP &gt;=8.0

Since Feb 22Pushed 1y ago1 watchersCompare

[ Source](https://github.com/demonyka/eden-ai-sdk)[ Packagist](https://packagist.org/packages/demonyka/eden-ai-sdk)[ RSS](/packages/demonyka-eden-ai-sdk/feed)WikiDiscussions 1.x Synced 1mo ago

READMEChangelogDependencies (6)Versions (6)Used By (0)

EdenAI SDK
==========

[](#edenai-sdk)

[![project-image](https://camo.githubusercontent.com/455506135266a377710ed13187741f88217409444462fb41e06b22e51a3245e7/68747470733a2f2f736f6369616c6966792e6769742e63692f64656d6f6e796b612f6564656e2d61692d73646b2f696d6167653f637573746f6d5f6465736372697074696f6e3d556e6f6666696369616c2b4150492b53444b2b666f722b4564656e2b414925304168747470732533412532462532467777772e6564656e61692e636f253246266465736372697074696f6e3d3126666f726b733d31266973737565733d31266c616e67756167653d31266e616d653d31266f776e65723d31267061747465726e3d506c75732670756c6c733d31267374617267617a6572733d31267468656d653d4175746f)](https://camo.githubusercontent.com/455506135266a377710ed13187741f88217409444462fb41e06b22e51a3245e7/68747470733a2f2f736f6369616c6966792e6769742e63692f64656d6f6e796b612f6564656e2d61692d73646b2f696d6167653f637573746f6d5f6465736372697074696f6e3d556e6f6666696369616c2b4150492b53444b2b666f722b4564656e2b414925304168747470732533412532462532467777772e6564656e61692e636f253246266465736372697074696f6e3d3126666f726b733d31266973737565733d31266c616e67756167653d31266e616d653d31266f776e65723d31267061747465726e3d506c75732670756c6c733d31267374617267617a6572733d31267468656d653d4175746f)

EdenAI SDK Documentation
========================

[](#edenai-sdk-documentation)

Introduction
------------

[](#introduction)

The EdenAI SDK is an unofficial PHP library that provides a convenient interface to interact with the Eden AI platform. Eden AI is a platform that aggregates multiple AI service providers, allowing developers to access various AI capabilities through a unified API.

This SDK makes it easy to integrate Eden AI services into your PHP applications, especially in Laravel projects.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Configuration](#configuration)
- [Basic Usage](#basic-usage)
- [Available Features](#available-features)
    - [Image Processing](#image-processing)
        - [Explicit Content Detection](#explicit-content-detection)
        - [Deepfake Detection](#deepfake-detection)
        - [Object Detection](#object-detection)
        - [Face Comparison](#face-comparison)
    - [Text Processing](#text-processing)
        - [Text Moderation](#text-moderation)
        - [Code Generation](#code-generation)
    - [Audio Processing](#audio-processing)
        - [Text to Speech](#text-to-speech)
- [Laravel Integration](#laravel-integration)
- [Advanced Usage](#advanced-usage)
    - [Working with Providers](#working-with-providers)
    - [Error Handling](#error-handling)
    - [Custom HTTP Clients](#custom-http-clients)
- [API Reference](#api-reference)

Installation
------------

[](#installation)

You can install the SDK using Composer:

```
composer require demonyka/eden-ai-sdk
```

Configuration
-------------

[](#configuration)

### Direct Usage

[](#direct-usage)

When using the SDK directly, you can provide the API token when creating an instance:

```
use EdenAI\Api;

// Method 1: Provide token directly
$api = new Api('your-api-token-here');

// Method 2: Use environment variable
// Set the EDEN_AI_TOKEN environment variable
// $api = new Api();
```

### Laravel Integration

[](#laravel-integration)

If you're using Laravel, publish the configuration file:

```
php artisan vendor:publish --tag="edenai-config"
```

This will create a `config/edenai.php` file where you can configure the SDK. Add your API token to your `.env` file:

```
EDEN_AI_TOKEN=your-api-token-here

```

Basic Usage
-----------

[](#basic-usage)

### Creating an API Instance

[](#creating-an-api-instance)

```
use EdenAI\Api;

// Initialize with API token
$api = new Api('your-api-token-here');
```

### Making API Requests

[](#making-api-requests)

Each API method corresponds to a specific Eden AI endpoint. Here's a basic example:

```
// Check for explicit content in an image
$result = $api->checkExplicitContent([
    'file_url' => 'https://example.com/image.jpg',
    'providers' => 'google,clarifai'
]);

// Check if the image is NSFW
if ($result->isNSFW()) {
    echo "This image contains explicit content";
} else {
    echo "This image is safe";
}
```

Available Features
------------------

[](#available-features)

The SDK provides access to various AI capabilities offered by Eden AI:

### Image Processing

[](#image-processing)

#### Explicit Content Detection

[](#explicit-content-detection)

Detect explicit or NSFW content in images:

```
$result = $api->checkExplicitContent([
    'file_url' => 'https://example.com/image.jpg',
    'providers' => 'clarifai,google' // Optional, defaults to config
]);

// Get the average NSFW score across providers
$score = $result->getAverageScore();

// Check if the image is considered NSFW
$isNSFW = $result->isNSFW();
```

#### Deepfake Detection

[](#deepfake-detection)

Detect if an image has been manipulated or artificially generated:

```
$result = $api->detectDeepfake([
    'file_url' => 'https://example.com/image.jpg',
    'providers' => 'sightengine' // Optional, defaults to config
]);

// Get the average deepfake score
$score = $result->getAverageScore();

// Check if the image is likely a deepfake
$isDeepfake = $result->isDeepfake();
```

#### Object Detection

[](#object-detection)

Detect and identify objects in images:

```
$result = $api->detectObject([
    'file_url' => 'https://example.com/image.jpg',
    'providers' => 'google,amazon' // Optional, defaults to config
]);

// Get all detected items with confidence scores
$items = $result->getItems();

// Check for a specific object
$hasCar = $result->hasItem('car');

// Get confidence score for a specific object
$carConfidence = $result->item('car');
```

#### Face Comparison

[](#face-comparison)

Compare faces in two different images:

```
$result = $api->compareFace([
    'file1_url' => 'https://example.com/face1.jpg',
    'file2_url' => 'https://example.com/face2.jpg',
    'providers' => 'amazon' // Optional, defaults to config
]);

// Get average confidence of face matching
$confidence = $result->getAverageConfidence();

// Check if faces are considered the same person
$isMatched = $result->isCompared();
```

### Text Processing

[](#text-processing)

#### Text Moderation

[](#text-moderation)

Detect inappropriate or harmful content in text:

```
$result = $api->moderateText([
    'text' => 'Text to be moderated',
    'language' => 'en', // Optional, defaults to config
    'providers' => 'google' // Optional, defaults to config
]);

// Similar to explicit content detection for images
$score = $result->getAverageScore();
$isInappropriate = $result->isNSFW();
```

#### Code Generation

[](#code-generation)

Generate code based on natural language instructions:

```
$result = $api->generateCode([
    'instruction' => 'Create a function that calculates the factorial of a number',
    'temperature' => 0.1, // Optional, defaults to config
    'max_tokens' => 500, // Optional, defaults to config
    'providers' => 'openai' // Optional, defaults to config
]);

// Get generated code from a specific provider
$code = $result->getResult('openai');

// Or get code from all providers
$allCode = $result->getResult();
```

### Audio Processing

[](#audio-processing)

#### Text to Speech

[](#text-to-speech)

Convert text to spoken audio:

```
$result = $api->textToSpeech([
    'text' => 'Hello, this is a test of text to speech',
    'language' => 'en', // Optional, defaults to config
    'option' => 'MALE', // Optional, defaults to config (MALE/FEMALE)
    'providers' => 'openai' // Optional, defaults to config
]);

// Get audio URL from a specific provider
$audioUrl = $result->getAudioResourceUrl('openai');

// Or get audio URLs from all providers
$allAudioUrls = $result->getAudioResourceUrl();
```

Laravel Integration
-------------------

[](#laravel-integration-1)

The SDK includes Laravel integration for easier usage:

### Facade

[](#facade)

After publishing the config file, you can use the EdenAI facade:

```
use EdenAI\Laravel\Facades\EdenAI;

// Use the facade
$result = EdenAI::checkExplicitContent([
    'file_url' => 'https://example.com/image.jpg'
]);
```

### Configuration

[](#configuration-1)

The published `config/edenai.php` file allows you to set default configurations for each feature:

```
// config/edenai.php example
return [
    'token' => env('EDEN_AI_TOKEN', ''),
    'exclipt_content' => [
        'providers' => 'clarifai,google',
        'threshold' => 0.8
    ],
    'deepfake_detection' => [
        'providers' => 'sightengine',
        'threshold' => 0.8
    ],
    // Other configurations...
];
```

Advanced Usage
--------------

[](#advanced-usage)

### Working with Providers

[](#working-with-providers)

Each method can work with multiple providers. The SDK will combine results from all providers to give you more accurate results:

```
// Using multiple providers
$result = $api->detectObject([
    'file_url' => 'https://example.com/image.jpg',
    'providers' => 'google,amazon,microsoft'
]);

// Access individual provider results
$providers = $result->getProviders();
foreach ($providers as $providerName => $provider) {
    echo "Provider: $providerName\n";
    echo "Status: " . $provider['status'] . "\n";

    if ($provider['status'] === 'success') {
        // Access provider-specific data
        print_r($provider->getRawResponse());
    } else {
        // Handle error
        echo "Error: " . $provider['error']['message'] . "\n";
    }
}

// Get total cost of the operation
$cost = $result->getCost();
```

### Error Handling

[](#error-handling)

The SDK uses exceptions to handle errors:

```
use EdenAI\Exceptions\EdenAIException;

try {
    $result = $api->checkExplicitContent([
        'file_url' => 'https://example.com/image.jpg'
    ]);
} catch (EdenAIException $e) {
    echo "Error: " . $e->getMessage() . "\n";
    echo "Code: " . $e->getCode() . "\n";
}
```

### Custom HTTP Clients

[](#custom-http-clients)

You can customize the HTTP client used by the SDK:

```
use EdenAI\Api;
use EdenAI\HttpClients\GuzzleHttpClient;
use GuzzleHttp\Client;

// Create custom Guzzle client with specific options
$guzzleClient = new Client([
    'proxy' => 'http://proxy.example.com:8125',
    'verify' => false,
]);

$httpClient = new GuzzleHttpClient($guzzleClient);

// Pass to API
$api = new Api('your-token', $httpClient);

// Or set after instantiation
$api->setHttpClientHandler($httpClient);

// Configure timeouts
$api->setTimeOut(120); // in seconds
$api->setConnectTimeOut(30); // in seconds
```

API Reference
-------------

[](#api-reference)

### Main API Class

[](#main-api-class)

`EdenAI\Api` is the main entry point for interacting with the SDK.

#### Constructor

[](#constructor)

```
public function __construct(
    ?string $token = null,
    ?HttpClientInterface $httpClientHandler = null,
    ?string $baseUrl = null
)
```

- `$token`: Your Eden AI API token
- `$httpClientHandler`: Custom HTTP client implementation
- `$baseUrl`: Custom API base URL (defaults to Eden AI's API)

#### HTTP Methods

[](#http-methods)

```
public function setTimeOut(int $timeOut): self
public function setConnectTimeOut(int $connectTimeOut): self
public function getLastResponse(): ?EdenAIResponse
```

### Response Objects

[](#response-objects)

All API methods return specific response objects that extend `EdenAI\Objects\BaseObject`.

Common methods available on all response objects:

```
public function getCost(): float
public function getProviders(): array
public function getRawResponse(): mixed
```

### Feature-Specific Methods

[](#feature-specific-methods)

Each feature has its own methods and responses as documented in the [Available Features](#available-features) section.

License
-------

[](#license)

The EdenAI SDK is open-source software licensed under the MIT license.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance44

Moderate activity, may be stable

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

439d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f5b6ef7cb2923aa10918c3033be034e3d582a0af219bde5f70eee9d861063e7?d=identicon)[demonyka](/maintainers/demonyka)

---

Top Contributors

[![demonyka](https://avatars.githubusercontent.com/u/37048571?v=4)](https://github.com/demonyka "demonyka (19 commits)")

### Embed Badge

![Health badge](/badges/demonyka-eden-ai-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/demonyka-eden-ai-sdk/health.svg)](https://phpackages.com/packages/demonyka-eden-ai-sdk)
```

###  Alternatives

[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6939.5M343](/packages/drupal-core-recommended)[eslazarev/wildberries-sdk

Wildberries OpenAPI clients (generated).

101.2k](/packages/eslazarev-wildberries-sdk)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
