PHPackages                             coze/api - 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. coze/api

ActiveLibrary[API Development](/categories/api)

coze/api
========

COZE SDK for PHP

1.1(1y ago)11.1k↓50%MITPHPPHP &gt;=8.2

Since Apr 25Pushed 1y ago1 watchersCompare

[ Source](https://github.com/longfeiRen/coze-api)[ Packagist](https://packagist.org/packages/coze/api)[ RSS](/packages/coze-api/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Coze SDK for PHP
================

[](#coze-sdk-for-php)

[Coze API 官方文档](https://www.coze.cn/open/docs/developer_guides/coze_api_overview)Coze SDK for PHP 是 Coze API 的 PHP 语言 SDK，提供了对 Coze API 的封装，方便开发者在 PHP 中使用 Coze API。

安装
--

[](#安装)

```
composer require coze/api
```

准备工作
----

[](#准备工作)

1. 创建新应用； 客户端类型 一定选 “服务类应用”、“服务类应用”、“服务类应用”
2. 获取 公钥、私钥 和应用ID
3. 创建工作流，并发布；获取工作流ID

### 获取Token

[](#获取token)

```
use GuzzleHttp\Client;
use Coze\Auth\OAuthClient;

$appId = 'your_app_id'; // 应用ID
$publicKey = 'your_app_public_key'; // 公钥指纹
$privateKey = file_get_contents('./private_key.pem'); // 私钥

$client = new Client([
            'base_uri' => 'https://api.coze.cn',
            'timeout' => 5,
        ]);

$oauth = new OAuthClient($clientId, $publicKey, $clientSecret, $client);

$oauth->getAccessToken();
/**
 * [
 *  'expires_in' => 1000000000, 过期时间戳
 *  'access_token' => 'xxxxx'
 * ]
 */
```

### 工作流调用

[](#工作流调用)

[详细文档](https://www.coze.cn/open/docs/developer_guides/workflow_run)

```
use Coze\Workflow\Run;

$workflowId = 10002312312; // 工作流ID

$run = new Run($client, $workflowId);

$params = []; // 工作流中自定义的传参内容
$run->handle($params)
```

###  Health Score

34

—

LowBetter than 77% of packages

Maintenance49

Moderate activity, may be stable

Popularity20

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

2

Last Release

370d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/922971da07426372e3cf8f4d07ad078381a4165af6bdcaa9e1927bafe7abc5a2?d=identicon)[longfeiRen](/maintainers/longfeiRen)

---

Top Contributors

[![Rlf-sys](https://avatars.githubusercontent.com/u/76700101?v=4)](https://github.com/Rlf-sys "Rlf-sys (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/coze-api/health.svg)

```
[![Health](https://phpackages.com/badges/coze-api/health.svg)](https://phpackages.com/packages/coze-api)
```

###  Alternatives

[get-stream/stream

A PHP client for Stream (https://getstream.io)

1451.3M8](/packages/get-stream-stream)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[agence104/livekit-server-sdk

Server-side SDK for LiveKit.

79189.9k1](/packages/agence104-livekit-server-sdk)[packbackbooks/lti-1p3-tool

A library used for building IMS-certified LTI 1.3 tool providers in PHP.

51438.3k2](/packages/packbackbooks-lti-1p3-tool)[hoels/app-store-server-library-php

The PHP server library for the App Store Server API and App Store Server Notifications.

44162.2k](/packages/hoels-app-store-server-library-php)[tamara-solution/php-sdk

Tamara PHP Client Library

10259.4k1](/packages/tamara-solution-php-sdk)

PHPackages © 2026

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