Skip to content

AiPayload & AiResponse

Fomvasss\AiTasks\DTO\AiPayload — the request a task builds in toPayload(). All properties are readonly.

ParameterTypeDefaultDescription
modalitystring—Must match modality() of the task
messagesarray[]Laravel\Ai\Messages\Message objects, strings or ['role' => ..., 'content' => ...]. The last user message is the prompt
systemPrompt?stringnullInstructions
optionsarray[]See below
metaarray[]Arbitrary data, stored in ai_runs.request
toolsarray[]Declare tools in AiTask::tools() instead — when the task defines tools, a schema or a tool choice, the payload is rebuilt from the task’s methods
jsonModeboolfalseSee JSON mode
providerOverride?arraynullPer-request credentials, see Provider override
schema?ClosurenullDeclare in AiTask::schema() instead
toolChoiceToolChoice|string|array|nullnullDeclare in AiTask::toolChoice() instead
decisionsDecisions|array|nullnullResume a run paused for tool approval, see Tool approval
KeyModalityDescription
modelallModel instead of the driver’s default
timeouttext, imageHTTP timeout in seconds; text default 60
temperature, max_tokens, top_ptextGeneration options
max_stepstext with toolsStep budget of the tool loop; wins over AiTask::maxSteps(), see Step budget
attachmentstextFiles for vision
path, storage, disk, diarizetranscriptionAudio source and speaker separation
provider_optionstext with schema()Raw provider fields keyed by driver, see Provider-specific options
size, qualityimageSee Modalities
voice, female, instructionsaudioSee Modalities

Fomvasss\AiTasks\DTO\AiResponse. All properties are readonly.

PropertyTypeDescription
okboolWhether the call succeeded
content?stringText; base64 for image/audio
usagearraydriver, model, tokens_in, tokens_out, cache_read_tokens, cache_write_tokens, cost, cost_rates; audio_seconds for transcription
structured?arrayDecoded output of schema() tasks
toolCallsarrayTools the model invoked, ToolCall::toArray() per entry
finishReason?stringstop, length, tool_calls, content_filter, error, unknown
pendingApprovalsarrayTool calls waiting for approval: id, tool, arguments, reason
runId?stringThe ai_runs row of this call (since 3.35), also when postprocess() returned an array; null from AI::fake()
resumeMessagesarrayThe paused turn as stored for AI::resume(); internal
error?stringError message
rawarrayReserved; currently always empty

Methods: paused(): bool — the run waits for a tool decision; pendingToolCalls(): array — the waiting calls in full ToolCall::toArray() form.

Fomvasss\AiTasks\DTO\AiContext — returned by AiTask::context(): tenantId, taskName, subjectType, subjectId, meta, userId.