class TextResponse implements Stringable

Traits

Properties

Response|null $raw

The raw HTTP response, if available for the provider.

from  HasRawResponse
Message> $messages
ToolCall> $toolCalls
ToolResult> $toolResults
Step> $steps
PendingApproval> $pendingApprovals
string $reasoning

Methods

withRawResponse(Response|null $response)

Set the raw HTTP response.

array
__serialize()

Prepare the instance for serialization, discarding the unserializable raw HTTP response.

__construct(string $text, TextUsage $usage, Meta $meta)

Create a new text response instance.

withMessages(Collection $messages)

Provide the message context for the response.

withToolCallsAndResults(Collection $toolCalls, Collection $toolResults)

Provide the tool calls and results for the message.

withReasoning(string $reasoning)

Provide the reasoning emitted across every step of the response.

withSteps(Collection $steps)

Provide the steps taken to generate the response.

withPendingApprovals(Collection $pendingApprovals)

Mark the response as waiting for tool approval.

bool
hasPendingApprovals()

Determine whether the response has tool calls pending approval.

string
__toString()

Get the string representation of the object.

Details

in HasRawResponse at line 19
HasRawResponse withRawResponse(Response|null $response)

Set the raw HTTP response.

Parameters

Response|null $response

Return Value

HasRawResponse

in HasRawResponse at line 29
array __serialize()

Prepare the instance for serialization, discarding the unserializable raw HTTP response.

Return Value

array

at line 44
__construct(string $text, TextUsage $usage, Meta $meta)

Create a new text response instance.

Parameters

string $text
TextUsage $usage
Meta $meta

at line 58
TextResponse withMessages(Collection $messages)

Provide the message context for the response.

Parameters

Collection $messages

Return Value

TextResponse

at line 85
TextResponse withToolCallsAndResults(Collection $toolCalls, Collection $toolResults)

Provide the tool calls and results for the message.

Parameters

Collection $toolCalls
Collection $toolResults

Return Value

TextResponse

at line 100
TextResponse withReasoning(string $reasoning)

Provide the reasoning emitted across every step of the response.

Parameters

string $reasoning

Return Value

TextResponse

at line 112
TextResponse withSteps(Collection $steps)

Provide the steps taken to generate the response.

Parameters

Collection $steps

Return Value

TextResponse

at line 124
TextResponse withPendingApprovals(Collection $pendingApprovals)

Mark the response as waiting for tool approval.

Parameters

Collection $pendingApprovals

Return Value

TextResponse

at line 134
bool hasPendingApprovals()

Determine whether the response has tool calls pending approval.

Return Value

bool

at line 142
string __toString()

Get the string representation of the object.

Return Value

string