Download the PHP package sungithubid/coze-php-sdk without Composer

On this page you can find all versions of the php package sungithubid/coze-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package coze-php-sdk

Coze PHP SDK

License: MIT PHP Version

⚠️ Note: This is an unofficial third-party PHP SDK. Currently, only the commonly used Chat and Datasets APIs are implemented. Other APIs will be added gradually.

A PHP SDK for the Coze API. This SDK provides a convenient way to integrate Coze's AI capabilities into your PHP applications.

Features

Requirements

Installation

Or add to your composer.json:

Quick Start

Initialize the Client

Chat Examples

Example Method Description
chat_stream.php $client->chat->stream() Streaming chat using PHP Generator (yield), memory-efficient for large responses
chat_no_stream.php $client->chat->create() Non-streaming chat, returns complete response
chat_poll.php $client->chat->createAndPoll() Auto-polling until chat completion
chat_with_conversation.php $client->chat->create() Chat with conversation context

Conversation & Message Examples

Example Description
conversation_crud.php Create, retrieve, list, and clear conversations
message_crud.php Create, retrieve, list, update, and delete messages

Dataset Examples

Example Description
dataset_crud.php Create, list, update, and delete datasets (knowledge bases)
document_crud.php Create, list, update, and delete documents in datasets

Workflow Examples

Example Description
workflow_run.php Execute a workflow with non-streaming output
workflow_stream.php Execute a workflow with streaming output (SSE)

API Reference

CozeClient

The main entry point for the SDK.

Chat API

$client->chat->create(array $request): array

Create a non-streaming chat.

Parameters:

$client->chat->stream(array $request): Generator

Create a streaming chat that yields ChatEvent objects.

$client->chat->createAndPoll(array $request, int $pollInterval = 1, int $timeout = 300): Chat

Create a chat and poll until completion.

$client->chat->retrieve(string $conversationId, string $chatId): array

Retrieve chat status.

$client->chat->cancel(string $conversationId, string $chatId): array

Cancel a chat.

Conversations API

$client->conversations->create(array $request): array

Create a new conversation.

Parameters:

$client->conversations->retrieve(string $conversationId): array

Retrieve conversation details.

$client->conversations->list(array $request): array

List conversations for a bot.

Parameters:

$client->conversations->clear(string $conversationId): array

Clear conversation context/history.

Messages API

$client->conversations->messages->create(array $request): array

Create a message in a conversation.

Parameters:

$client->conversations->messages->list(array $request): array

List messages in a conversation.

Parameters:

$client->conversations->messages->retrieve(string $conversationId, string $messageId): array

Retrieve a specific message.

$client->conversations->messages->update(array $request): array

Update a message.

Parameters:

$client->conversations->messages->delete(string $conversationId, string $messageId): array

Delete a message.

Datasets API (Knowledge Base)

$client->datasets->create(array $request): array

Create a new dataset (knowledge base).

Parameters:

$client->datasets->list(array $request): array

List datasets in a space.

Parameters:

$client->datasets->update(string $datasetId, array $request): array

Update a dataset.

$client->datasets->delete(string $datasetId): array

Delete a dataset.

Documents API (Knowledge Base Files)

$client->datasets->documents->create(array $request): array

Create documents in a dataset.

$client->datasets->documents->list(array $request): array

List documents in a dataset.

Parameters:

$client->datasets->documents->update(array $request): array

Update a document.

Parameters:

$client->datasets->documents->delete(array $documentIds): array

Delete documents.

DocumentBase Helper Methods

Message Helper Methods

Event Types

Error Handling

Environment Variables

You can configure the SDK using environment variables:

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

TODO

Related Links


All versions of coze-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
guzzlehttp/guzzle Version ^7.0
psr/http-message Version ^1.0|^2.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package sungithubid/coze-php-sdk contains the following files

Loading the files please wait ...