Skip to contents

Returned by gr_call(). Designed so a caller can never be handed NULL or character(0) where a string is expected.

Fields

ok

Logical(1). FALSE for transport failures, HTTP errors, and successful calls that returned no text (a refusal or content filter).

text

Character(1), always. "" when ok is FALSE. Never NULL, never character(0), and newlines are preserved.

error

Character or NULL. What went wrong, including the HTTP body for API-side errors.

usage

List with input and output token counts as reported by the API.

status, finish_reason, retryable, model, raw

HTTP status, the API's stop reason, whether a retry could help, the model id, and the parsed response body.

Methods

print() shows ok, the model, the token usage and either the text or the error.

Examples

res <- gr_call(gr_mock_client(function(m, p) "hello"), "hi")
c(ok = res$ok, text = res$text)
#>      ok    text 
#>  "TRUE" "hello"