sharpapi/php-custom-workflow
Composer 安装命令:
composer require sharpapi/php-custom-workflow
包简介
PHP SDK for SharpAPI Custom AI Workflow - build and execute no-code AI API endpoints
README 文档
README
SharpAPI PHP Custom Workflow SDK
🎯 Build and execute no-code AI API endpoints — powered by SharpAPI Custom AI Workflows.
Check the full documentation on the Custom AI Workflows page.
Quick Links
| Resource | Link |
|---|---|
| Product Details | SharpAPI.com |
| SDK Libraries | GitHub - SharpAPI SDKs |
Requirements
- PHP >= 8.1
- A SharpAPI account with an API key
Installation
Step 1. Install the package via Composer:
composer require sharpapi/php-custom-workflow
Step 2. Visit SharpAPI to get your API key.
Laravel Integration
Building a Laravel application? Check the Laravel package version: https://github.com/sharpapi/laravel-custom-workflow
What it does
This package provides a PHP SDK for SharpAPI Custom AI Workflows — user-built, no-code AI API endpoints. It lets you:
- List your custom workflows
- Describe a workflow's schema (params, input mode, output schema)
- Execute workflows with JSON or form-data payloads (including file uploads)
- Validate payloads client-side before execution
- Poll for async results
Usage
<?php require __DIR__ . '/vendor/autoload.php'; use SharpAPI\CustomWorkflow\CustomWorkflowClient; use GuzzleHttp\Exception\GuzzleException; $client = new CustomWorkflowClient(apiKey: 'your_api_key_here'); try { // Execute a JSON workflow $statusUrl = $client->executeWorkflow('my-sentiment-analyzer', [ 'text' => 'Great product!', 'score' => 4.5, ]); // Optional: adjust polling settings $client->setApiJobStatusPollingInterval(10); // seconds $client->setApiJobStatusPollingWait(180); // seconds total wait // Fetch results when ready $result = $client->fetchResults($statusUrl)->toArray(); print_r($result); } catch (GuzzleException $e) { echo $e->getMessage(); }
Execute a form-data workflow with file upload
$statusUrl = $client->executeWorkflow('document-analyzer', params: ['description' => 'Annual report'], files: ['document' => '/path/to/file.pdf'], ); $result = $client->fetchResults($statusUrl);
Discover available workflows
$workflows = $client->listWorkflows(); foreach ($workflows->workflows as $wf) { echo "{$wf->name} — /api/v1/custom/{$wf->slug}\n"; }
Inspect a workflow's schema
$wf = $client->describeWorkflow('my-sentiment-analyzer'); echo $wf->inputMode->label(); // "JSON" echo count($wf->requiredParams()); // 1 echo json_encode($wf->outputSchema); // {"sentiment":"string","confidence":"number"}
Client-side validation before execution
use SharpAPI\CustomWorkflow\Exceptions\ValidationException; try { // Fetches schema, validates params, then executes — one call $statusUrl = $client->validateAndExecute('my-analyzer', ['text' => 'hello']); } catch (ValidationException $e) { print_r($e->getErrors()); // ["unknown_field" => ["Unknown parameter"]] }
API Reference
CustomWorkflowClient extends SharpApiClient from sharpapi/php-core, inheriting fetchResults(), ping(), quota(), rate limiting, etc.
| Method | Returns | Description |
|---|---|---|
listWorkflows($page, $perPage) |
WorkflowListResult |
Paginated list of your workflows |
describeWorkflow($slug) |
WorkflowDefinition |
Schema, params, input mode, output schema |
executeWorkflow($slug, $params, $files) |
string (status URL) |
Execute a workflow |
validateAndExecute($slug, $params, $files) |
string (status URL) |
Validate client-side, then execute |
fetchResults($statusUrl) |
SharpApiJob |
Poll for results (inherited) |
DTOs
WorkflowDefinition—slug,name,inputMode,outputSchema,params[],requiredParams(),optionalParams()WorkflowParam—key,label,type,required,defaultValueWorkflowListResult—workflows[],total,perPage,currentPage,totalPages
Enums
InputMode—JSON/FORM_DATAParamType—JSON_STRING,JSON_NUMBER,JSON_BOOLEAN,JSON_OBJECT,JSON_ARRAY,FORM_DATA_TEXT,FORM_DATA_FILE
Do you think our API is missing some obvious functionality?
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
- A2Z WEB LTD
- Dawid Makowski
- Boost your PHP AI capabilities!
License
The MIT License (MIT). Please see License File for more information.
Social Media
🚀 For the latest news, tutorials, and case studies, don't forget to follow us on:
统计信息
- 总下载量: 42
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-02-20