mazin/replicate-php
最新稳定版本:0.0.1
Composer 安装命令:
composer require mazin/replicate-php
包简介
This is a PHP client for Replicate.
README 文档
README
This is a simple PHP client for the Replicate. It covers the main prediction functionalities of the Replicate HTTP API.
Requirements
- PHP 8.1
Installation
Install the package with composer:
composer require replicate/replicate-php
Usage
Initialize the replicate client with your API token
Get your API token from your Replicate account.
$replicate = new Replicate('token');
Create a prediction
try { $prediction = $replicate->createPrediction( version: 'v1', input: ['text' => 'foo'], ); echo $prediction->id; // take a look at Prediction data class for available fields } catch (ReplicateException|ReplicateWebhookInputException|ResponseException $e) { echo $e->getMessage(); }
Get a prediction
try { $prediction = $this->replicate->prediction(predictionId: 'prediction-id'); echo $prediction->id; } catch (ReplicateException|ResponseException $e) { // log error }
Get a list of predictions
try { $predictions = $this->replicate->predictions(); // if you would like to paginate. if ($predictions->next) { // extract the cursor from the next url $nextUrl = $predictions->next; $query = parse_url($nextUrl, PHP_URL_QUERY); parse_str($query, $params); $cursor = $params['cursor']; $predictions = $this->replicate->predictions(cursor: $cursor); // $predictions->results; } // take a look at the Predictions data class for available fields. } catch (ReplicateException|ResponseException $e) { // log error }
Cancel a prediction
try { $response = $this->replicate->cancelPrediction(predictionId: 'prediction-id'); echo $response->status; } catch (ReplicateException|ResponseException $e) { // log error }
Development
Install dependencies
composer install
Run tests
composer test
License
MIT
统计信息
- 总下载量: 14
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-09