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

v1.0.1 2026-02-20 13:44 UTC

This package is auto-updated.

Last update: 2026-02-20 13:44:20 UTC


README

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: