Skip to documentation
Documentation navigation

Documentation navigation

Documentation / guides

Overview

Read complete provider-neutral assistant output and terminal metadata.

developer

inference.Response is the complete result of Client.Invoke. It keeps the assistant message separate from normalized usage and terminal metadata so callers do not need to parse provider envelopes.

API surface

type Response struct {
	Message      *content.AIMessage
	Usage        *content.Usage
	Model        string
	FinishReason stream.FinishReason
	Attempts     int
}
FieldMeaning
MessageAssistant turn with ordered text, thinking, and tool-use blocks
UsageOptional normalized token counts
ModelResolved provider model name returned by the serving path
FinishReasonProvider-neutral terminal reason
AttemptsRetry establishment count; zero if uncounted, one for first-try success
response, err := client.Invoke(ctx, req)
if err != nil {
	return err
}
if response.Message != nil {
	for _, block := range response.Message.Blocks {
		if text, ok := block.(*content.TextBlock); ok {
			fmt.Println(text.Text)
		}
	}
}

A nil message or unknown finish reason is representable and should be handled explicitly. Structured-output helpers apply additional representation checks before returning data.

Proof

Related: Assistant messages, Finish reasons, Response usage.

← back to documentation