AnthropicResponse
Defined in: adapters/anthropic.ts:186
Anthropic Messages API response structure.
Contains the complete response from Claude including the generated content, stop reason, and token usage. Content is always returned as an array of structured blocks, even for simple text responses.
- AnthropicRequest
- AnthropicContentBlock
- https://docs.anthropic.com/en/api/messages
Example
Section titled “Example”const response: AnthropicResponse = { id: 'msg_123', type: 'message', role: 'assistant', content: [ { type: 'text', text: 'Hello! How can I help you today?' } ], model: 'claude-3-5-sonnet-20241022', stop_reason: 'end_turn', usage: { input_tokens: 12, output_tokens: 8 }};Properties
Section titled “Properties”content
Section titled “content”content:
AnthropicContentBlock[]
Defined in: adapters/anthropic.ts:197
Array of content blocks (even for simple text responses)
id:
string
Defined in: adapters/anthropic.ts:188
Unique identifier for this message
model:
string
Defined in: adapters/anthropic.ts:200
Model that generated the response
role:
"assistant"
Defined in: adapters/anthropic.ts:194
Role of the responder - always ‘assistant’
stop_reason
Section titled “stop_reason”stop_reason:
"tool_use"|"end_turn"|"max_tokens"|"stop_sequence"|null
Defined in: adapters/anthropic.ts:203
Reason generation stopped: ‘end_turn’ (natural), ‘max_tokens’, ‘stop_sequence’, ‘tool_use’, or null
stop_sequence?
Section titled “stop_sequence?”
optionalstop_sequence:string|null
Defined in: adapters/anthropic.ts:206
The actual stop sequence matched (if stop_reason is ‘stop_sequence’)
type:
"message"
Defined in: adapters/anthropic.ts:191
Object type - always ‘message’ for Messages API
usage:
object
Defined in: adapters/anthropic.ts:209
Token usage statistics
input_tokens
Section titled “input_tokens”input_tokens:
number
Number of tokens in the input/prompt
output_tokens
Section titled “output_tokens”output_tokens:
number
Number of tokens in the output/completion