PHP code example of runapi-ai / core

1. Go to this page and download the library: Download runapi-ai/core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

runapi-ai / core example snippets


use RunApi\Core\RequestOptions;

$options = new RequestOptions(headers: [
    'X-Client-Request-Id' => 'order-123',
    'Idempotency-Key' => 'opaque-logical-task-123',
]);

$file = $client->files->createFile(['file' => './knowledge.pdf']);
$content = $client->files->content($file->id);

$upload = $client->uploads->create([
    'bytes' => 1048576,
    'filename' => 'archive.bin',
    'mime_type' => 'application/octet-stream',
]);
$part = $client->uploads->addPart($upload->id, './archive.part-01');
$completed = $client->uploads->complete($upload->id, [$part->id]);

$schedule = $client->pricing->list(service: 'flux');
$quote = $client->pricing->quote('flux', 'text_to_image', 'flux-2-klein', ['prompt' => 'A glass observatory']);