immitranslate/datalab-sdk-laravel

Laravel SDK for Datalab API

Maintainers

Package info

github.com/immitranslate/datalab-sdk-laravel

pkg:composer/immitranslate/datalab-sdk-laravel

Fund package maintenance!

ImmiTranslate

Statistics

Installs: 126

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 2

v1.0.0 2026-02-14 19:59 UTC

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

To obtain an API key for Datalab, go to the API keys page once you've created an account.

Installation

You can install the package via composer:

composer require immitranslate/datalab-sdk-laravel

You can publish the config file with:

php artisan vendor:publish --tag="datalab-sdk-laravel-config"

Usage

Marker API

use ImmiTranslate\Datalab\Enums\DatalabMode;
use ImmiTranslate\Datalab\Enums\DatalabOutput;
use ImmiTranslate\Datalab\Facades\Datalab;
use ImmiTranslate\Datalab\FormField;

$response = Datalab::marker()
    ->fileUrl('https://r2.aws.com/test.pdf')
    ->mode(DatalabMode::Fast)
    ->outputFormat(DatalabOutput::Json)
    ->webhookUrl('https://testwebhook.com/test123') // optional; overrides account-level webhook for this request
    ->execute(); // alias of executeSync(), polls /marker/{request_id}

if ($response->isSuccess()) {
    // $response->markdown, $response->html, $response->json, $response->chunks
}

// If you only want the initial request_id response (no polling):
$queued = Datalab::marker()->executeAsync();
// $queued->requestId, $queued->requestCheckUrl, $queued->isValidationError()

Schema API

use ImmiTranslate\Datalab\Facades\Datalab;

$schemaResponse = Datalab::generateSchemas()
    ->checkpoint('asdf123')
    ->webhookUrl('https://test.com') // optional; overrides account-level webhook for this request
    ->generate(); // alias of generateSync(), polls request_check_url

if ($schemaResponse->isSuccess()) {
    // $schemaResponse->suggestions['simple_schema'], moderate_schema, complex_schema
}

Form Filling API

use ImmiTranslate\Datalab\Facades\Datalab;
use ImmiTranslate\Datalab\FormField;

$fillResponse = Datalab::formFilling()
    ->fields([
        new FormField(fieldKey: 'title', description: 'The title of the movie'),
        new FormField(fieldKey: 'director', description: 'The name of the director of the movie'),
    ])
    ->context('This is the form each Oscar nomination should fill out')
    ->confidenceThreshold(0.5)
    ->pageRange('1-15')
    ->file('/absolute/path/to/form.pdf') // optional local file upload
    ->execute(); // alias of executeSync(), polls request_check_url

if ($fillResponse->isSuccess()) {
    // Access full payload via $fillResponse->raw
}

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.