Check the full documentation on the Custom AI Workflows page.
| Resource | Link |
|---|---|
| Product Details | SharpAPI.com |
| SDK Libraries | GitHub - SharpAPI SDKs |
- PHP >= 8.1
- A SharpAPI account with an API key
composer require sharpapi/php-custom-workflowStep 2. Visit SharpAPI to get your API key.
Building a Laravel application? Check the Laravel package version: https://github.com/sharpapi/laravel-custom-workflow
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
<?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();
}$statusUrl = $client->executeWorkflow('document-analyzer',
params: ['description' => 'Annual report'],
files: ['document' => '/path/to/file.pdf'],
);
$result = $client->fetchResults($statusUrl);$workflows = $client->listWorkflows();
foreach ($workflows->workflows as $wf) {
echo "{$wf->name} β /api/v1/custom/{$wf->slug}\n";
}$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"}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"]]
}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) |
WorkflowDefinitionβslug,name,inputMode,outputSchema,params[],requiredParams(),optionalParams()WorkflowParamβkey,label,type,required,defaultValueWorkflowListResultβworkflows[],total,perPage,currentPage,totalPages
InputModeβJSON/FORM_DATAParamTypeβJSON_STRING,JSON_NUMBER,JSON_BOOLEAN,JSON_OBJECT,JSON_ARRAY,FORM_DATA_TEXT,FORM_DATA_FILE
Please see CHANGELOG for more information on what has changed recently.
- A2Z WEB LTD
- Dawid Makowski
- Boost your PHP AI capabilities!
The MIT License (MIT). Please see License File for more information.
π For the latest news, tutorials, and case studies, don't forget to follow us on:
