Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Cohere ai Cohere python AssistantMessageV2ContentOneItem Model

From Leeroopedia
Revision as of 12:16, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Cohere_ai_Cohere_python_AssistantMessageV2ContentOneItem_Model.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains SDK, Chat
Last Updated 2026-02-15 14:00 GMT

Overview

The AssistantMessageV2ContentOneItem is a discriminated union type representing individual content items for V2 assistant messages, which can be either text or thinking content.

Description

AssistantMessageV2ContentOneItem is a type alias defined as an annotated union of two Pydantic model classes: TextAssistantMessageV2ContentOneItem and ThinkingAssistantMessageV2ContentOneItem. The union is discriminated on the type field. The TextAssistantMessageV2ContentOneItem variant has type="text" and a text string field containing the generated text. The ThinkingAssistantMessageV2ContentOneItem variant has type="thinking" and a thinking string field containing the model's internal reasoning. Both variants extend UncheckedBaseModel and are auto-generated from the Cohere API definition by Fern. This type is structurally identical to AssistantMessageResponseContentItem but is used specifically for V2 assistant message content in request-side message construction.

Usage

Use this type when constructing or inspecting the content field of an AssistantMessage in V2 chat conversations. Each item in the content list uses the type discriminant to indicate whether it represents generated text or internal reasoning.

Code Reference

Source Location

  • Repository: Cohere Python SDK
  • File: src/cohere/types/assistant_message_v2content_one_item.py

Signature

class TextAssistantMessageV2ContentOneItem(UncheckedBaseModel):
    type: typing.Literal["text"] = "text"
    text: str

class ThinkingAssistantMessageV2ContentOneItem(UncheckedBaseModel):
    type: typing.Literal["thinking"] = "thinking"
    thinking: str

AssistantMessageV2ContentOneItem = typing_extensions.Annotated[
    typing.Union[
        TextAssistantMessageV2ContentOneItem,
        ThinkingAssistantMessageV2ContentOneItem,
    ],
    UnionMetadata(discriminant="type"),
]

Import

from cohere.types import AssistantMessageV2ContentOneItem
from cohere.types.assistant_message_v2content_one_item import (
    TextAssistantMessageV2ContentOneItem,
    ThinkingAssistantMessageV2ContentOneItem,
)

I/O Contract

TextAssistantMessageV2ContentOneItem

Field Type Required Default Description
type Literal["text"] No "text" Discriminant field identifying this as a text content item.
text str Yes - The text content generated by the assistant.

ThinkingAssistantMessageV2ContentOneItem

Field Type Required Default Description
type Literal["thinking"] No "thinking" Discriminant field identifying this as a thinking content item.
thinking str Yes - The internal reasoning or thought process of the assistant.

Usage Examples

from cohere.types.assistant_message_v2content_one_item import (
    TextAssistantMessageV2ContentOneItem,
    ThinkingAssistantMessageV2ContentOneItem,
)
from cohere.types import AssistantMessage

# Construct text content for an assistant message
text_item = TextAssistantMessageV2ContentOneItem(
    text="The Eiffel Tower is located in Paris, France."
)

# Construct thinking content for an assistant message
thinking_item = ThinkingAssistantMessageV2ContentOneItem(
    thinking="The user is asking about the Eiffel Tower location. I know it is in Paris."
)

# Use in an AssistantMessage for multi-turn chat history
assistant_msg = AssistantMessage(
    content=[text_item],
)

# Process content items by checking the type discriminant
import cohere

client = cohere.ClientV2(api_key="YOUR_API_KEY")

response = client.chat(
    model="command-r-plus",
    messages=[
        {"role": "user", "content": "Where is the Eiffel Tower?"},
    ],
)

for item in response.message.content or []:
    if item.type == "text":
        print(f"Text: {item.text}")
    elif item.type == "thinking":
        print(f"Thinking: {item.thinking}")

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment