Skip to content

PHP SDK for SharpAPI Custom AI Workflow - build and execute no-code AI API endpoints

License

Notifications You must be signed in to change notification settings

sharpapi/php-custom-workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SharpAPI GitHub cover

SharpAPI PHP Custom Workflow SDK

🎯 Build and execute no-code AI API endpoints β€” powered by SharpAPI Custom AI Workflows.

Latest Version on Packagist Total Downloads

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, defaultValue
  • WorkflowListResult β€” workflows[], total, perPage, currentPage, totalPages

Enums

  • InputMode β€” JSON / FORM_DATA
  • ParamType β€” 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


License

License: MIT

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:

About

PHP SDK for SharpAPI Custom AI Workflow - build and execute no-code AI API endpoints

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages