Implementation:Cohere ai Cohere python ToolParameterDefinitionsValue Model
| 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.pyLines 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
- Implementation:Cohere_ai_Cohere_python_ToolV2_Definition -- V2 tool definition model that uses JSON Schema instead
- Implementation:Cohere_ai_Cohere_python_ToolV2Function_Model -- V2 function specification using JSON Schema parameters
- Implementation:Cohere_ai_Cohere_python_Tool_Execution_Pattern -- End-to-end tool execution pattern
- Environment:Cohere_ai_Cohere_python_Python_SDK_Runtime