sharpapi / php-custom-workflow
PHP SDK for SharpAPI Custom AI Workflow - build and execute no-code AI API endpoints
Installs: 5
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/sharpapi/php-custom-workflow
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.0|^7.9|^7.10
- sharpapi/php-core: ^1.4.0
Requires (Dev)
- pestphp/pest: ^2.0|^3.0
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: