PHPackages                             clouddark/cloudflare-ai-worker-php - 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. clouddark/cloudflare-ai-worker-php

ActiveLibrary[API Development](/categories/api)

clouddark/cloudflare-ai-worker-php
==================================

A PHP library to interact with Cloudflare AI Workers or other AI models.

06PHP

Since Jan 3Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Cloud-Dark/cloudflare-ai-worker-php)[ Packagist](https://packagist.org/packages/clouddark/cloudflare-ai-worker-php)[ RSS](/packages/clouddark-cloudflare-ai-worker-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Cloudflare AI Worker PHP Library
================================

[](#cloudflare-ai-worker-php-library)

This is a simple PHP wrapper to interact with Cloudflare's AI Worker API. The wrapper allows you to send messages to the Cloudflare AI model and get responses in both **streaming** and **non-streaming** modes.

Requirements
------------

[](#requirements)

- PHP 7.4 or higher
- Composer

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

[](#installation)

To get started, you can install the package via Composer.

1. Clone the repository or initialize it in your project:

    ```
    composer require clouddark/cloudflare-ai-worker-php:dev-main
    ```
2. Upgrade dependencies using Composer:

    ```
    composer upgrade && composer update
    ```

    This will install the necessary dependencies and set up the autoloader.

Usage
-----

[](#usage)

Once installed, you can use the `CloudflareAiWorker` class to send requests to the Cloudflare AI API.

### Example PHP Code

[](#example-php-code)

#### 1. **Non-Streaming (Standard Request)**

[](#1-non-streaming-standard-request)

```

```

#### 2. **Streaming (Real-time Request)**

[](#2-streaming-real-time-request)

```

```

### Expected Response

[](#expected-response)

The expected response from the Cloudflare AI Worker can vary based on the mode.

#### Non-Streaming Response:

[](#non-streaming-response)

The response for non-streaming will be a complete JSON object, similar to:

```
{
    "result": {
        "response": "Hello! It's nice to meet you. I'm here to help answer any questions, provide information, or just chat if you'd like. How can I assist you today?"
    },
    "success": true,
    "errors": [],
    "messages": []
}
```

#### Streaming Response:

[](#streaming-response)

In the case of streaming, the data will be received and output in real-time. The response will be directly displayed as it is processed, which could look like:

```
"Hello! It's nice to meet you. I'm here to help answer any questions..."
```

The output will be displayed as chunks of data in the browser as they are received from the API.

Customization
-------------

[](#customization)

You can customize the `CloudflareAiWorker` class by adjusting the URL, token, or model that you're using to interact with the Cloudflare AI API.

- **Set URL:** `setUrl('your-api-url')`
- **Set API Token:** `setToken('your-api-token')`
- **Set Model:** `setModel('your-model-id')`
- **Enable/Disable Streaming:** `setStream(true)` or `setStream(false)`

License
-------

[](#license)

This project is open-source and available under the [MIT License](LICENSE).

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity16

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c0106141a074a85e83bf91039cd19e07f1c2adae184a92b014b70e6099e7d9c?d=identicon)[Cloud-Dark](/maintainers/Cloud-Dark)

---

Top Contributors

[![Cloud-Dark](https://avatars.githubusercontent.com/u/28920412?v=4)](https://github.com/Cloud-Dark "Cloud-Dark (9 commits)")

### Embed Badge

![Health badge](/badges/clouddark-cloudflare-ai-worker-php/health.svg)

```
[![Health](https://phpackages.com/badges/clouddark-cloudflare-ai-worker-php/health.svg)](https://phpackages.com/packages/clouddark-cloudflare-ai-worker-php)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

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

A PHP wrapper for Twilio's API

1.6k92.9M270](/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.1M453](/packages/google-gax)

PHPackages © 2026

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