BuildsTextRequests
trait BuildsTextRequests
Methods
Build the request body for the xAI Responses API.
Build the request body for the current text generation step.
Build a lightweight continuation body using previous_response_id.
Apply options shared by full requests and previous_response_id continuations.
Extract tool result items from the trailing ToolResultMessage for a continuation request.
Build the text format options for structured output.
Details
at line 21
protected array
buildTextRequestBody(Provider $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options)
Build the request body for the xAI Responses API.
at line 40
protected array
buildStepBody(Provider $provider, string $model, string|null $instructions, array $messages, array $tools, array|null $schema, TextGenerationOptions|null $options, StepContext $stepContext)
Build the request body for the current text generation step.
at line 60
protected array
buildContinuationBody(string $previousResponseId, string $model, array $messages, array $tools, Provider $provider, array|null $schema, TextGenerationOptions|null $options = null)
Build a lightweight continuation body using previous_response_id.
Only sends tool results as input instead of replaying the full conversation.
at line 81
protected array
mergeSharedResponsesRequestOptions(array $body, array $tools, array|null $schema, TextGenerationOptions|null $options, Provider $provider)
Apply options shared by full requests and previous_response_id continuations.
at line 122
protected string|array
mapToolChoice(ToolChoice $choice)
Map a tool choice to the xAI Responses tool_choice shape.
at line 136
protected array
extractToolResultsInput(array $messages)
Extract tool result items from the trailing ToolResultMessage for a continuation request.
at line 158
protected array
buildSchemaFormat(array $schema, bool $strict)
Build the text format options for structured output.