# mirascope.core.anthropic.call_response_chunk
## <ApiType type="Module" path="core/anthropic/call_response_chunk" symbolName="call_response_chunk" /> call_response_chunk
This module contains the `AnthropicCallResponseChunk` class.
<Info title="Usage">
[Streams](/docs/v1/learn/streams#handling-streamed-responses)
</Info>
## <ApiType type="Attribute" path="core/anthropic/call_response_chunk" symbolName="FinishReason" /> FinishReason
**Type:** <TypeLink type={{"type_str": "Message.__annotations__['stop_reason']", "description": null, "kind": "generic", "base_type": {"type_str": "Message.__annotations__", "description": null, "kind": "simple", "doc_identifier": "Message.__annotations__"}, "parameters": [{"type_str": "'stop_reason'", "description": null, "kind": "simple", "doc_identifier": "'stop_reason'"}]}} />
## <ApiType type="Class" path="core/anthropic/call_response_chunk" symbolName="AnthropicCallResponseChunk" /> AnthropicCallResponseChunk
A convenience wrapper around the Anthropic `ChatCompletionChunk` streamed chunks.
When calling the Anthropic API using a function decorated with `anthropic_call` and
`stream` set to `True`, the stream will contain `AnthropicResponseChunk` instances
with properties that allow for more convenient access to commonly used attributes.
Example:
```python
from mirascope.core import prompt_template
from mirascope.core.anthropic import anthropic_call
@anthropic_call("claude-3-5-sonnet-20240620", stream=True)
def recommend_book(genre: str) -> str:
return f"Recommend a {genre} book"
stream = recommend_book("fantasy") # response is an `AnthropicStream`
for chunk, _ in stream:
print(chunk.content, end="", flush=True)
```
**Bases:**
<TypeLink type={{"type_str": "BaseCallResponseChunk[MessageStreamEvent, FinishReason]", "description": null, "kind": "generic", "base_type": {"type_str": "BaseCallResponseChunk", "description": null, "kind": "simple", "doc_url": "/docs/v1/api/core/base/call_response_chunk#basecallresponsechunk"}, "parameters": [{"type_str": "MessageStreamEvent", "description": null, "kind": "simple", "doc_identifier": "MessageStreamEvent"}, {"type_str": "FinishReason", "description": null, "kind": "simple", "doc_url": "/docs/v1/api/core/openai/call_response_chunk#finishreason"}]}} />
<AttributesTable
attributes={[
{
"name": "content",
"type_info": {
"type_str": "str",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/stdtypes.html#str"
},
"description": "Returns the string content of the 0th message."
},
{
"name": "finish_reasons",
"type_info": {
"type_str": "list[FinishReason] | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "list[FinishReason]",
"description": null,
"kind": "generic",
"base_type": {
"type_str": "list",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/stdtypes.html#list"
},
"parameters": [
{
"type_str": "FinishReason",
"description": null,
"kind": "simple",
"doc_url": "/docs/v1/api/core/openai/call_response_chunk#finishreason"
}
]
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Returns the finish reason of the response."
},
{
"name": "model",
"type_info": {
"type_str": "str | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "str",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/stdtypes.html#str"
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Returns the name of the response model."
},
{
"name": "id",
"type_info": {
"type_str": "str | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "str",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/stdtypes.html#str"
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Returns the id of the response."
},
{
"name": "usage",
"type_info": {
"type_str": "Usage | MessageDeltaUsage | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "Usage",
"description": null,
"kind": "simple",
"doc_url": "/docs/v1/api/core/base/types#usage"
},
{
"type_str": "MessageDeltaUsage",
"description": null,
"kind": "simple",
"doc_identifier": "MessageDeltaUsage"
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Returns the usage of the message."
},
{
"name": "input_tokens",
"type_info": {
"type_str": "int | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "int",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/functions.html#int"
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Returns the number of input tokens."
},
{
"name": "cached_tokens",
"type_info": {
"type_str": "int | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "int",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/functions.html#int"
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Returns the number of cached tokens."
},
{
"name": "output_tokens",
"type_info": {
"type_str": "int | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "int",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/functions.html#int"
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Returns the number of output tokens."
},
{
"name": "cost_metadata",
"type_info": {
"type_str": "CostMetadata",
"description": null,
"kind": "simple",
"doc_url": "/docs/v1/api/core/base/types#costmetadata"
},
"description": "Returns the cost metadata."
},
{
"name": "common_finish_reasons",
"type_info": {
"type_str": "list[types.FinishReason] | None",
"description": null,
"kind": "union",
"base_type": {
"type_str": "Union",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/typing.html#typing.Union"
},
"parameters": [
{
"type_str": "list[types.FinishReason]",
"description": null,
"kind": "generic",
"base_type": {
"type_str": "list",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/stdtypes.html#list"
},
"parameters": [
{
"type_str": "types.FinishReason",
"description": null,
"kind": "simple",
"doc_identifier": "types.FinishReason"
}
]
},
{
"type_str": "None",
"description": null,
"kind": "simple",
"doc_url": "https://docs.python.org/3/library/constants.html#None"
}
]
},
"description": "Provider-agnostic finish reasons."
}
]}
/>