Documentation / guides
Overview
Read complete provider-neutral assistant output and terminal metadata.
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
}
| Field | Meaning |
|---|---|
Message | Assistant turn with ordered text, thinking, and tool-use blocks |
Usage | Optional normalized token counts |
Model | Resolved provider model name returned by the serving path |
FinishReason | Provider-neutral terminal reason |
Attempts | Retry 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.