PHPackages                             albertcht/notion-ai - 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. albertcht/notion-ai

ActiveLibrary[API Development](/categories/api)

albertcht/notion-ai
===================

Api Client of Notion AI in PHP

v0.1.0(3y ago)28441MITPHPPHP &gt;=7.4

Since Apr 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/albertcht/notion-ai)[ Packagist](https://packagist.org/packages/albertcht/notion-ai)[ Docs](https://github.com/albertcht/notion-ai)[ RSS](/packages/albertcht-notion-ai/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

Notion AI API Client for PHP
============================

[](#notion-ai-api-client-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/09a73d2bcd6660d2c239cc0aa2df1f684ae2f99ceade0d3c232acc62829d422b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c626572746368742f6e6f74696f6e2d61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/albertcht/notion-ai)[![Tests](https://camo.githubusercontent.com/42d618d3b3370d481b57ce0a00d83fa1a93fd214739b5322831b93664d48933c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c626572746368742f6e6f74696f6e2d61692f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/albertcht/notion-ai/actions/workflows/tests.yml)[![Total Downloads](https://camo.githubusercontent.com/7aff321eccd2635e07dd4a47fb0d4e303ca03fb04afa52d15002b9ff5ac05602/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c626572746368742f6e6f74696f6e2d61692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/albertcht/notion-ai)

[![Demo Notion AI](/art/demo.png)](/art/demo.png)

---

About this package
------------------

[](#about-this-package)

Notion AI is a powerful artificial intelligence feature based on GPT-3 that is part of the productivity app Notion. You can use Notion AI within Notion itself, but there is currently no official API available.

This is an unofficial PHP client for the Notion AI API that makes it easy to interact with Notion AI in your PHP projects.

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

[](#installation)

You can install the package via composer:

```
composer require albertcht/notion-ai
```

Usage
-----

[](#usage)

- Initialize a Notion AI instance

```
$notion = new AlbertCht\NotionAi\NotionAi('token', 'spaceId');
```

- Set options of Guzzle client in the third paramter

> See:

```
$notion = new AlbertCht\NotionAi\NotionAi('token', 'spaceId', ['timeout' => 120]);
```

- Replace a PSR Http Client if needed

```
$client = new GuzzleHttp\Client();
$notion->setClient($client);
```

- Send a request with general `sendRequest` function

> If some APIs are not wrapped in this package, you can interact with Notion AI by this function

```
$notion->sendRequest([
    [
        'type' => $promptType,
        'pageTitle' => $pageTitle,
        'selectedText' => $selectedText,
    ]
]);
```

- Send a request with stream response

```
// you can set buffer size of stream in the second parameter
$notion->stream(function ($output) {
    echo $output;
    if (ob_get_length()) {
        ob_get_flush();
        flush();
    }
}, 128);
$notion->sendRequest([
    [
        'type' => $promptType,
        'pageTitle' => $pageTitle,
        'selectedText' => $selectedText,
    ]
]);
```

- Supported APIs

```
public function writeWithPrompt(string $promptType, string $selectedText, string $pageTitle = ''): ?string;

public function continueWriting(string $previousContent, string $pageTitle = '', string $restContent = ''): ?string;

public function helpMeEdit(string $prompt, string $selectedText, string $pageTitle = ''): ?string;

public function helpMeWrite(string $prompt, string $previousContent = '', string $pageTitle = '', string $restContent = ''): ?string;

public function helpMeDraft(string $prompt, string $previousContent = '', string $pageTitle = '', string $restContent = ''): ?string;

public function translate(string $text, string $language): ?string;

public function changeTone(string $text, string $tone): ?string;

public function summarize(string $selectedText, string $pageTitle = ''): ?string;

public function improveWriting(string $selectedText, string $pageTitle = ''): ?string;

public function fixSpellingGrammar(string $selectedText, string $pageTitle = ''): ?string;

public function explainThis(string $selectedText, string $pageTitle = ''): ?string;

public function makeLonger(string $selectedText, string $pageTitle = ''): ?string;

public function makeShorter(string $selectedText, string $pageTitle = ''): ?string;

public function findActionItems(string $selectedText, string $pageTitle = ''): ?string;

public function simplifyLanguage(string $selectedText, string $pageTitle = ''): ?string;

public function writeWithTopic(string $topic, string $prompt): ?string;

public function brainstormIdeas(string $prompt): ?string;

public function outline(string $prompt): ?string;

public function socialMediaPost(string $prompt): ?string;

public function creativeStory(string $prompt): ?string;

public function poem(string $prompt): ?string;

public function essay(string $prompt): ?string;

public function meetingAgenda(string $prompt): ?string;

public function pressRelease(string $prompt): ?string;

public function jobDescription(string $prompt): ?string;

public function salesEmail(string $prompt): ?string;

public function recruitingEmail(string $prompt): ?string;

public function prosConsList(string $prompt): ?string;
```

Enums
-----

[](#enums)

There are enums you can refer to when you call APIs:

- [PromptTypes](/src/Enums/PromptTypes.php)
- [Topics](/src/Enums/Topics.php)
- [Languages](/src/Enums/Languages.php)
- [Tones](/src/Enums/Tones.php)

Testing
-------

[](#testing)

```
composer test
```

How to get token and space id from Notion?
------------------------------------------

[](#how-to-get-token-and-space-id-from-notion)

- Get token from Notion

[![Screenshot of token.](/art/token.jpg)](/art/token.jpg)

- Get space id from Notion

[![Screenshot of spaceId.](/art/spaceid.jpg)](/art/spaceid.jpg)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/SECURITY.md) on how to report security vulnerabilities.

Donation
--------

[](#donation)

[![Buy Me A Coffee](https://camo.githubusercontent.com/9f44ce2dc3b3eecdd02598900866ffc518801df1932849703dae1e5ce5031070/68747470733a2f2f7777772e6275796d6561636f666665652e636f6d2f6173736574732f696d672f637573746f6d5f696d616765732f6f72616e67655f696d672e706e67)](https://www.buymeacoffee.com/albertcht)

You can support me by a cup of coffee. An open-source project also relies on community's contribution. Any PRs are welcome to help maintain this package.

Credits
-------

[](#credits)

- [Albert Chen](https://github.com/albertcht)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity34

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

Unknown

Total

1

Last Release

1123d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d8b4d1f7bf254a37c8fa948495bb20006283adcad2de40d50ac14c0d379ab920?d=identicon)[albertcht](/maintainers/albertcht)

---

Top Contributors

[![albertcht](https://avatars.githubusercontent.com/u/9117929?v=4)](https://github.com/albertcht "albertcht (21 commits)")

---

Tags

phpapiopenaiapi clientgpt3notion-ai

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/albertcht-notion-ai/health.svg)

```
[![Health](https://phpackages.com/badges/albertcht-notion-ai/health.svg)](https://phpackages.com/packages/albertcht-notion-ai)
```

###  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.7k7.6M74](/packages/openai-php-laravel)[theodo-group/llphant

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

1.5k311.5k5](/packages/theodo-group-llphant)[fabian-beiner/todoist-php-api-library

A PHP client library that provides a native interface to the official Todoist REST API.

4810.8k](/packages/fabian-beiner-todoist-php-api-library)

PHPackages © 2026

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