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

From Leeroopedia
Knowledge Sources
Domains SDK, Tool Use, Function Calling, Pydantic Models
Last Updated 2026-02-15 14:00 GMT

Overview

Pydantic model representing a single parameter specification within a tool's parameter definitions map.

Description

ToolParameterDefinitionsValue defines the schema for an individual parameter in a tool definition. Each instance describes one parameter via its description (optional human-readable text), type (required string specifying the Python type), and required (optional boolean indicating whether the parameter must always be present). This model extends UncheckedBaseModel and supports extra fields via Pydantic's extra="allow" configuration, ensuring forward compatibility with API changes. It is used as the value type in Dict[str, ToolParameterDefinitionsValue] mappings within legacy (V1) tool definitions.

Usage

Use ToolParameterDefinitionsValue when constructing tool parameter definitions for the legacy Cohere chat API (V1). Each key in the parameter definitions dictionary maps a parameter name to a ToolParameterDefinitionsValue instance that describes that parameter's type, description, and whether it is required. For V2 API tool definitions, use JSON Schema-based parameters on ToolV2Function instead.

Code Reference

Source Location

  • Repository: Cohere Python SDK
  • File: src/cohere/types/tool_parameter_definitions_value.py Lines L1-32

Signature

class ToolParameterDefinitionsValue(UncheckedBaseModel):
    description: typing.Optional[str] = pydantic.Field(default=None)
    type: str = pydantic.Field()
    required: typing.Optional[bool] = pydantic.Field(default=None)

Import

from cohere.types import ToolParameterDefinitionsValue

I/O Contract

Fields

Field Type Required Default Description
description Optional[str] No None The description of the parameter.
type str Yes (none) The type of the parameter. Must be a valid Python type.
required Optional[bool] No None Denotes whether the parameter is always present (required) or not. Defaults to not required.

Configuration

Setting Value Description
extra "allow" Permits additional fields not defined in the schema, ensuring forward compatibility.
smart_union True Pydantic V1 only: enables smart union type resolution.

Usage Examples

from cohere.types import ToolParameterDefinitionsValue

# Define parameter definitions for a tool
parameter_definitions = {
    "location": ToolParameterDefinitionsValue(
        description="The city and state, e.g. San Francisco, CA",
        type="str",
        required=True,
    ),
    "unit": ToolParameterDefinitionsValue(
        description="The temperature unit to use: celsius or fahrenheit",
        type="str",
        required=False,
    ),
}

Related Pages

Page Connections

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