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 Image Model

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

Overview

Image is a Pydantic model that represents image metadata including dimensions, format, and bit depth.

Description

The Image class extends UncheckedBaseModel and contains fields describing the properties of an image. It stores the image's width and height in pixels, its format (e.g., PNG, JPEG), and the bit depth. All four fields are required (non-optional) and must be provided when constructing an instance. The model supports extra fields via Pydantic's extra="allow" configuration.

Usage

Use the Image model when working with image data returned from Cohere API responses. This type provides structured access to image properties such as dimensions, format type, and bit depth for downstream processing or validation.

Code Reference

Source Location

Signature

class Image(UncheckedBaseModel):
    width: int = pydantic.Field()
    height: int = pydantic.Field()
    format: str = pydantic.Field()
    bit_depth: int = pydantic.Field()

Import

from cohere.types import Image

I/O Contract

Fields

Field Type Required Default Description
width int Yes -- Width of the image in pixels.
height int Yes -- Height of the image in pixels.
format str Yes -- Format of the image (e.g., PNG, JPEG).
bit_depth int Yes -- Bit depth of the image.

Usage Examples

from cohere.types import Image

# Construct an Image instance directly
image = Image(
    width=1024,
    height=768,
    format="PNG",
    bit_depth=24,
)

# Access image metadata
print(f"Dimensions: {image.width}x{image.height}")
print(f"Format: {image.format}")
print(f"Bit depth: {image.bit_depth}")

# Image objects are typically returned by API responses
# and can be serialized to dict
image_dict = image.dict()
print(image_dict)
# {'width': 1024, 'height': 768, 'format': 'PNG', 'bit_depth': 24}

Related Pages

Page Connections

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