PHPackages                             hudhaifas/silverstripe-gpt-actions - 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. hudhaifas/silverstripe-gpt-actions

ActiveSilverstripe-vendormodule[API Development](/categories/api)

hudhaifas/silverstripe-gpt-actions
==================================

Expose secure server-side actions to ChatGPT via OpenAPI and expirable API keys.

0351PHP

Since Aug 2Pushed 9mo agoCompare

[ Source](https://github.com/hudhaifas/silverstripe-gpt-actions)[ Packagist](https://packagist.org/packages/hudhaifas/silverstripe-gpt-actions)[ RSS](/packages/hudhaifas-silverstripe-gpt-actions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

SilverStripe GPT Actions Module
===============================

[](#silverstripe-gpt-actions-module)

*Expose your custom server-side logic to GPTs and AI clients via secure, structured endpoints.*

The **silverstripe-gpt-actions** module allows you to define and expose server-side actions through a secure HTTP interface for integration with custom GPTs (ChatGPT plugins) or other AI tools.

It supports:

- Custom GET endpoints per action
- OpenAPI schema generation (`/gpt/openapi`) for easy GPT integration
- Secure access using expirable API keys
- CMS management of API keys
- Google Analytics 4 (GA4) usage tracking (optional)
- Developer-friendly action registration and manifest system

> ✅ Requires SilverStripe 4.10+ or 5.x

---

📦 Installation
--------------

[](#-installation)

```
composer require hudhaifas/silverstripe-gpt-actions
```

Enable the module in your SilverStripe project, then run:

```
vendor/bin/sake dev/build flush=1
```

---

🧠 Use Cases
-----------

[](#-use-cases)

This module is ideal for:

- Enabling GPTs to access domain-specific actions directly
- Exposing structured data and tools to AI models
- Creating secure and discoverable AI endpoints
- Tracking GPT usage analytics via GA4

---

🧩 Defining Actions
------------------

[](#-defining-actions)

Create a PHP class implementing a `run()` static function and a `describe()` static method:

```
namespace MyApp\GPTActions;

use Exception;

class GetEntityByIDAction {
    public static function run(array $parameters) {
        if (!isset($parameters['EntityID'])) {
            throw new Exception("Missing parameter: EntityID");
        }

        $entity = MyEntity::get_by_id($parameters['EntityID']);

        return [
            'ID' => $entity->ID,
            'Name' => $entity->Name,
            'Details' => $entity->Details
        ];
    }

    public static function describe(): array {
        return [
            'name' => 'GetEntityByID',
            'description' => 'Retrieve an entity by its unique ID.',
            'parameters' => [
                'EntityID' => [
                    'type' => 'integer',
                    'required' => true,
                    'description' => 'The numeric ID of the entity'
                ],
            ],
        ];
    }
}
```

> The `describe()` method is used to auto-generate OpenAPI documentation.

---

⚙️ Registering Actions
----------------------

[](#️-registering-actions)

Register actions in your YAML config (e.g., `app/_config/gpt-actions.yml`):

```
GptActions\Util\GPTActionRegistry:
  available_actions:
    GetEntityByID: MyApp\GPTActions\GetEntityByIDAction
    SearchEntities: MyApp\GPTActions\SearchEntitiesAction
```

---

🌐 Available Endpoints
---------------------

[](#-available-endpoints)

### `GET /gpt/action/{ActionName}?param1=value1&...`

[](#get-gptactionactionnameparam1value1)

Invokes a specific action. Example:

```
GET /gpt/action/GetEntityByID?EntityID=123
Authorization: Bearer YOUR_API_KEY

```

### `GET /gpt/openapi`

[](#get-gptopenapi)

Returns a dynamic OpenAPI 3.1 JSON schema for all registered actions.

---

🔐 API Key Authentication
------------------------

[](#-api-key-authentication)

Manage API keys from the CMS under the **GPT Keys** section.

Each key:

- Is a 64-character token
- Can be linked to a `Member`
- Can expire and/or be deactivated
- Inherits the same **permissions and access scope as the linked `Member`**

**Authentication Methods**:

- ✅ Recommended: `Authorization: Bearer YOUR_KEY`
- 🧪 Testing only: `?key=YOUR_KEY`

---

🛡️ Request Authentication
-------------------------

[](#️-request-authentication)

The module uses the `GPTAuthenticator` class to validate incoming requests.

Internally, each request to `/gpt/*` is authenticated via the controller’s `init()` method:

```
if (!GPTAuthenticator::authenticate($this->getRequest())) {
    return $this->httpError(401, 'Unauthorized GPT access');
}
```

You may reuse the `GPTAuthenticator::authenticate()` method anywhere in your project.

---

⚙️ SiteConfig Integration
-------------------------

[](#️-siteconfig-integration)

To customize OpenAPI schema metadata and enable analytics, the module extends `SiteConfig` with:

FieldPurpose`GPTActionTitle`Appears in OpenAPI `info.title``GPTActionDescription`Appears in OpenAPI `info.description``GPTAnalyticsMeasurementID`GA4 Measurement ID`GPTAnalyticsAPISecret`GA4 API SecretAll can be set from the CMS Settings UI.

---

📈 GPT Usage Analytics (Optional)
--------------------------------

[](#-gpt-usage-analytics-optional)

If configured via `SiteConfig`, the module will send usage events to **Google Analytics 4 (GA4)** using the \[Measurement Protocol\].

Tracked event: `gpt_action_called`

Event parameters:

ParamExampleDescription`action_name`GetEntityByIDName of the called action`success``true/false`Whether the action succeeded---

📋 Example OpenAPI Output
------------------------

[](#-example-openapi-output)

```
{
  "openapi": "3.1.0",
  "info": {
    "title": "My Custom GPT",
    "description": "Custom actions exposed for GPT integration.",
    "version": "1.0.0"
  },
  "paths": {
    "/gpt/action/GetEntityByID": {
      "get": {
        "summary": "Retrieve an entity by ID.",
        "parameters": [
          {
            "name": "EntityID",
            "in": "query",
            "required": true,
            "schema": { "type": "integer" }
          }
        ]
      }
    }
  }
}
```

---

🧪 Testing Endpoints
-------------------

[](#-testing-endpoints)

```
fetch('https://yourdomain.com/gpt/action/GetEntityByID?EntityID=123', {
  headers: {
    Authorization: 'Bearer YOUR_KEY'
  }
})
  .then(res => res.json())
  .then(console.log);
```

---

🤖 Creating a Custom GPT
-----------------------

[](#-creating-a-custom-gpt)

You can easily create a ChatGPT plugin (Custom GPT) that consumes the OpenAPI spec exposed at `/gpt/openapi`.

👉 See [docs/CustomGPT.md](docs/CustomGPT.md) for a walkthrough on publishing your GPT on ChatGPT.com.

---

📜 License
---------

[](#-license)

MIT

---

✍️ Maintainer
-------------

[](#️-maintainer)

Hudhaifa – [amlineage.com](https://amlineage.com)

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance41

Moderate activity, may be stable

Popularity14

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/2b63db0734b5a637e6eb015db44fa334a181f5e0ed8e776ab57d0232dbfc3944?d=identicon)[hudhaifas](/maintainers/hudhaifas)

### Embed Badge

![Health badge](/badges/hudhaifas-silverstripe-gpt-actions/health.svg)

```
[![Health](https://phpackages.com/badges/hudhaifas-silverstripe-gpt-actions/health.svg)](https://phpackages.com/packages/hudhaifas-silverstripe-gpt-actions)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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