BuildsTextRequests
trait BuildsTextRequests
Methods
Build the request body for the Anthropic Messages API.
Stamp the requested cache breakpoints onto the final request body.
Ensure longer-lived cache breakpoints precede shorter-lived breakpoints.
Build the cache control block for the given TTL.
Determine if the model accepts temperature and top_p.
Determine the tool_choice strategy for the request.
Determine if the provider supports native structured output via output_config.
Build the synthetic tool definition for structured output.
Details
at line 22
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 Anthropic Messages API.
at line 87
protected array
applyPromptCacheBreakpoints(array $body, TextGenerationOptions|null $options)
Stamp the requested cache breakpoints onto the final request body.
at line 118
protected void
ensureValidPromptCacheOrder(array $body, TextGenerationOptions|null $options)
Ensure longer-lived cache breakpoints precede shorter-lived breakpoints.
at line 141
protected array
cacheControl(string|null $ttl)
Build the cache control block for the given TTL.
at line 149
protected bool
supportsSamplingParameters(string $model)
Determine if the model accepts temperature and top_p.
at line 157
protected array
resolveToolChoice(array|null $schema, array $tools, array $providerOptions, ToolChoice|null $toolChoice = null)
Determine the tool_choice strategy for the request.
at line 192
protected bool
supportsNativeStructuredOutput(Provider $provider)
Determine if the provider supports native structured output via output_config.
at line 206
protected array
buildStructuredOutputTool(array $schema)
Build the synthetic tool definition for structured output.