Jibu.Response (Jibu v0.2.1)

Copy Markdown View Source

A Messages API response.

The fields mirror the API's JSON with string keys. body holds the complete decoded body, including fields Jibu does not lift.

Summary

Functions

Decodes the text of a structured output as JSON.

Returns the text of all text blocks, joined without a separator.

Types

t()

@type t() :: %Jibu.Response{
  body: map(),
  content: [map()],
  id: String.t() | nil,
  model: String.t() | nil,
  stop_reason: String.t() | nil,
  usage: map() | nil
}

Functions

json(response)

@spec json(t()) :: {:ok, term()} | {:error, Jibu.Error.t()}

Decodes the text of a structured output as JSON.

A refusal returns an error instead of a result. Output cut off at max_tokens or at the context window returns an error, never partial JSON. See the structured output guide.

text(response)

@spec text(t()) :: String.t()

Returns the text of all text blocks, joined without a separator.