PHPackages                             openeuropa/gpt-at-ec-php-client - 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. openeuropa/gpt-at-ec-php-client

ActiveLibrary

openeuropa/gpt-at-ec-php-client
===============================

PHP API client to interact with European Commission GPT@EC.

1.x-dev(10mo ago)019↑2584.2%1EUPL-1.2PHPPHP ^8.3CI passing

Since Sep 17Pushed 10mo agoCompare

[ Source](https://github.com/openeuropa/gpt-at-ec-php-client)[ Packagist](https://packagist.org/packages/openeuropa/gpt-at-ec-php-client)[ RSS](/packages/openeuropa-gpt-at-ec-php-client/feed)WikiDiscussions 1.x Synced today

READMEChangelog (1)Dependencies (4)Versions (2)Used By (1)

GPT@EC PHP API client
=====================

[](#gptec-php-api-client)

This is an API client written in PHP to interact with the GPT@EC API.

### Important notes

[](#important-notes)

The GPT@EC API is very similar to the Open AI API.
Therefore, in order to ease the development, this library reuses the *openai-client/php* where possible, or extends it if needed.
Since some parts of the *openai-client/php* are marked as internal, this library might become incompatible with future versions of it. Consider locking the *openai-client/php* version, and update it to the latest version reported as compatible in the test builds.

Install
-------

[](#install)

Use [Composer](https://getcomposer.org/) to require the library:

```
composer require openeuropa/gpt-at-ec-php-client
```

Make sure you have a PSR-18 client installed, or install one manually, e.g.:

```
composer require guzzlehttp/guzzle
```

The `php-http/discovery` plugin can also help installing and discovering a compatible PSR-18 client.

Usage
-----

[](#usage)

You can create a new API client using the factory class. All you need is a GPT@EC API key:

```
$api_key = getenv('KEY_AI_GPT_AT_EC');
$factory = new \Openeuropa\GptAtEcPhpClient\Factory();
$client = $factory->withApiKey($key)->make();
```

Now the client can be used to interact with the 3 available endpoints.

### Chat

[](#chat)

The Chat Completions API endpoint will generate a model response from a list of messages comprising a conversation.

`create` method

Create a chat completion. The full model response will be returned at once by the API.

```
$response = $client->chat()->create([
    'model' => 'gpt-4o',
    'messages' => [
    [
        'role' => 'system',
        'content' => 'You are a helpful assistant.',
    ],
    [
        'role' => 'user',
        'content' => 'Hello!',
    ],
]);

echo $response->id; // "chatcmpl-0123456789abcdef0123456789ab"
echo $result->object; // "chat.completion"
echo $result->created; // 1755523764
echo $result->model; // "gpt-4o-2000-01-01"

echo $response->choices[0]->message->role; // "assistant"
echo $response->choices[0]->message->content; // "Hello! How can I assist you today?"
echo $response->choices[0]->index; // 0
echo $response->choices[0]->finishReason; // "stop"

echo $response->usage->promptTokens; // 9
echo $response->usage->completionTokens; // 10
echo $response->usage->totalTokens; // 19
```

`createStreamed` method

Create a chat completion. The response will be streamed back in parts as the model generates it.

```
$stream = $client->chat()->createStreamed([
    'model' => 'gpt-4o',
    'messages' => [
    [
        'role' => 'system',
        'content' => 'You are a helpful assistant.',
    ],
    [
        'role' => 'user',
        'content' => 'Hello!',
    ],
]);

foreach ($stream as $chunk) {
    echo $chunk->id; // "chatcmpl-0123456789abcdef0123456789ab"
    echo $chunk->object; // "chat.completion.chunk"
    echo $chunk->created; // 1755530359
    echo $chunk->model; // "meta-llama/Llama-3.3-70B-Instruct"

    echo $response->choices[0]->message->role; // "assistant"
    echo $response->choices[0]->message->content; // "Hello!", "How", "can", "I", "help", "you", "?"
}
```

### Models

[](#models)

Lists the various models available in the API.
A single method is available, `list`.

```
$response = $client->models()->list();

foreach ($response->data as $model) {
    echo $model->id; // "llama-3.3-70b-instruct"
    echo $model->name; // "LLama 3.3 70b instruct"
    echo $model->description; // "Very powerful open-weights model on par with the capabilities of GPT-4o for many types of tasks."
    print_r($model->sensitivityLevel); // ["PA", "SNC", "CU"]
    print_r($model->defaultFor); // ["SNC"]
    echo $model->created; // 1744201138356
    echo $model->ownedBy; // "meta"
    echo $model->object; // "model"
}
```

### Quota consumption

[](#quota-consumption)

Provides the quota consumption details for a specific AI model. A single method is available, `retrieve`.

```
$response = $client->quotaConsumption()->retrieve('gpt-4o');

echo $response->consumedPromptTokens; // 1234
echo $response->consumedCompletionTokens; // 5678
echo $response->consumedTotalTokens; // 6912
echo $response->quota; // 100000
```

Tests
-----

[](#tests)

The library is full covered by unit tests using the [PHPUnit](https://phpunit.de/) framework. To run the tests, execute:

```
./vendor/bin/phpunit --coverage-html folder-for-coverage-results
```

Versioning
----------

[](#versioning)

We use [SemVer](http://semver.org/) for versioning.

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance54

Moderate activity, may be stable

Popularity9

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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 ~0 days

Total

2

Last Release

309d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d3b1f4079f9a82f6dd88fe6577d1256b4ecbbccbcd4a4ec9bea7c2fd6f72b99a?d=identicon)[DIGIT-CORE](/maintainers/DIGIT-CORE)

---

Top Contributors

[![brummbar](https://avatars.githubusercontent.com/u/8488617?v=4)](https://github.com/brummbar "brummbar (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/openeuropa-gpt-at-ec-php-client/health.svg)

```
[![Health](https://phpackages.com/badges/openeuropa-gpt-at-ec-php-client/health.svg)](https://phpackages.com/packages/openeuropa-gpt-at-ec-php-client)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k9.5M90](/packages/openai-php-laravel)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.7k409.0k6](/packages/theodo-group-llphant)[maestroerror/laragent

Power of AI Agents in your Laravel project

639159.9k](/packages/maestroerror-laragent)[mage-os/module-automatic-translation

Automatic AI content translation for Mage-OS.

3017.9k](/packages/mage-os-module-automatic-translation)[sproutcms/cms

Enterprise content management and framework

242.6k4](/packages/sproutcms-cms)[eliashaeussler/typo3-solver

Solver - Extends TYPO3's exception handling with AI generated solutions. Problems can also be solved from command line. Several OpenAI parameters are configurable and prompts and solution providers can be customized as desired.

302.1k](/packages/eliashaeussler-typo3-solver)

PHPackages © 2026

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