struct

Arcana::AI::Chat::Response

Inherits Struct < Value < Object

Constructors

from_openai_json(raw : String, provider : String = "openai") : self

Parse from an OpenAI-compatible JSON response body.

Source
new(content : String | Nil = nil, tool_calls : Array(ToolCall) = [] of ToolCall, finish_reason : String | Nil = nil, model : String = "", provider : String = "", raw_request : String = "", raw_json : String = "", thinking_content : String | Nil = nil, server_tool_results : Array(JSON::Any) = [] of JSON::Any, usage : Usage | Nil = nil)
Source

Instance methods

content
Source
content=(content : String | Nil)
Source
cost(at : Time = Time.utc, table : Pricing::Table = Pricing::Table.default) : Pricing::Cost | Pricing::Unpriced

What this call cost; see Pricing. at is when it was made.

Source
finish_reason
Source
finish_reason=(finish_reason : String | Nil)
Source
has_tool_calls?

Did the model return any tool calls?

Source
model
Source
model=(model : String)
Source
provider
Source
provider=(provider : String)
Source
raw_json
Source
raw_json=(raw_json : String)
Source
raw_request
Source
raw_request=(raw_request : String)
Source
retries

Retries the call needed (rate limits, server or network errors) and the time spent waiting between tries. See RetryPolicy.

Source
retries=(retries : Int32)

Retries the call needed (rate limits, server or network errors) and the time spent waiting between tries. See RetryPolicy.

Source
retry_wait
Source
retry_wait=(retry_wait : Time::Span)
Source
server_tool_results

Server-side tool results (e.g. web_search results).

Source
server_tool_results=(server_tool_results : Array(JSON::Any))

Server-side tool results (e.g. web_search results).

Source
thinking_content

The raw reasoning text if the provider surfaces it (Anthropic extended thinking, Gemini with includeThoughts). OpenAI o-series never surfaces the reasoning itself, so this stays nil for OpenAI even when reasoning ran.

Source
thinking_content=(thinking_content : String | Nil)

The raw reasoning text if the provider surfaces it (Anthropic extended thinking, Gemini with includeThoughts). OpenAI o-series never surfaces the reasoning itself, so this stays nil for OpenAI even when reasoning ran.

Source
tool_call(name : String) : ToolCall | Nil

Find the first tool call matching a given function name.

Source
tool_calls
Source
tool_calls=(tool_calls : Array(ToolCall))
Source
usage

What the call used, in the same billing categories for every provider (see Usage); nil when the provider reported none. Pricing prices it.

Source
usage=(usage : Usage | Nil)

What the call used, in the same billing categories for every provider (see Usage); nil when the provider reported none. Pricing prices it.

Source
with_retries(stats : RetryStats) : self

This response with the retry record of the call that produced it.

Source