<?php
use Cognesy\Messages\Messages;
use Cognesy\Polyglot\BatchInference\BatchInference;
use Cognesy\Polyglot\BatchInference\Collections\BatchItems;
use Cognesy\Polyglot\BatchInference\Data\BatchItem;
use Cognesy\Polyglot\Inference\Data\InferenceRequest;
$batches = BatchInference::using('openai');
$job = $batches->submit(BatchItems::of(
BatchItem::of('row-1', new InferenceRequest(messages: Messages::fromString('A'))),
BatchItem::of('row-2', new InferenceRequest(messages: Messages::fromString('B'))),
));
$json = json_encode($job->reference()->toArray(), JSON_THROW_ON_ERROR);
// Write $json to durable application storage before this process exits.
// @doctest id="b845"