Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Cohere ai Cohere python SummarizeResponse Model

From Leeroopedia
Knowledge Sources
Domains SDK, Summarization
Last Updated 2026-02-15 14:00 GMT

Overview

SummarizeResponse is a Pydantic model representing the response from the Cohere Summarize API, containing the generated summary text and associated metadata.

Description

The SummarizeResponse model encapsulates the result of a summarization request. It contains three optional fields:

  • id -- A generated identifier for the summary, useful for tracking and logging.
  • summary -- The actual generated summary text produced from the input.
  • meta -- An ApiMeta object containing API usage metadata such as token counts and billing information.

The model extends UncheckedBaseModel and allows extra fields via Pydantic configuration.

Usage

Use SummarizeResponse when working with responses from the Cohere Summarize API endpoint. Access the summary field for the generated text and the meta field for API usage tracking.

Code Reference

Source Location

Signature

class SummarizeResponse(UncheckedBaseModel):
    id: typing.Optional[str] = pydantic.Field(default=None)
    summary: typing.Optional[str] = pydantic.Field(default=None)
    meta: typing.Optional[ApiMeta] = None

Import

from cohere.types import SummarizeResponse

I/O Contract

Fields

Field Type Required Description
id Optional[str] No Generated ID for the summary.
summary Optional[str] No Generated summary text for the input.
meta Optional[ApiMeta] No API metadata including token usage and billing information.

Usage Examples

from cohere.types import SummarizeResponse

# Call the summarize API
response = client.summarize(
    text="Long article text to be summarized...",
    length="medium",
    format="paragraph",
    extractiveness="low"
)

# Access the response fields
print(f"Summary ID: {response.id}")
print(f"Summary: {response.summary}")

# Check API metadata
if response.meta:
    print(f"API meta: {response.meta}")

Related Pages

Page Connections

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