Implementation:Cohere ai Cohere python ChatConnector Model
| Knowledge Sources | |
|---|---|
| Domains | SDK, Connectors |
| Last Updated | 2026-02-15 14:00 GMT |
Overview
The ChatConnector class is a Pydantic model representing a connector configuration for fetching documents from external sources during chat.
Description
The ChatConnector model configures a connector used for fetching documents from external data sources in the context of a Cohere chat request. It specifies the connector's id, an optional user_access_token that overrides the Cohere-generated authorization token, a continue_on_failure flag that determines whether the request should proceed if the connector returns an error, and an options dictionary for connector-specific settings at request time. For example, the web-search connector supports the site option to limit search results to a specified domain. This model extends UncheckedBaseModel and is auto-generated from the Cohere API definition by Fern.
Usage
Use this model when configuring connectors for the Cohere chat API. Connectors enable the model to access external data sources such as web search or enterprise knowledge bases, allowing for retrieval-augmented generation (RAG) without manually passing documents.
Code Reference
Source Location
- Repository: Cohere Python SDK
- File:
src/cohere/types/chat_connector.py
Signature
class ChatConnector(UncheckedBaseModel):
id: str = pydantic.Field()
user_access_token: typing.Optional[str] = pydantic.Field(default=None)
continue_on_failure: typing.Optional[bool] = pydantic.Field(default=None)
options: typing.Optional[typing.Dict[str, typing.Any]] = pydantic.Field(default=None)
Import
from cohere.types import ChatConnector
I/O Contract
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
id |
str |
Yes | - | The identifier of the connector. |
user_access_token |
Optional[str] |
No | None |
When specified, this user access token will be passed to the connector in the Authorization header instead of the Cohere generated one. |
continue_on_failure |
Optional[bool] |
No | None |
Defaults to false. When true, the request will continue if this connector returned an error.
|
options |
Optional[Dict[str, Any]] |
No | None |
Provides the connector with different settings at request time. The key/value pairs are specific to each connector. For example, the web-search connector supports the site option to limit results to a specific domain.
|
Usage Examples
import cohere
from cohere.types import ChatConnector
client = cohere.Client(api_key="YOUR_API_KEY")
# Basic web search connector
response = client.chat(
model="command-r-plus",
message="What are the latest developments in quantum computing?",
connectors=[
ChatConnector(id="web-search"),
],
)
# Web search connector with domain restriction
response = client.chat(
model="command-r-plus",
message="What are the latest AI research papers?",
connectors=[
ChatConnector(
id="web-search",
options={"site": "arxiv.org"},
),
],
)
# Connector with custom access token and failure tolerance
response = client.chat(
model="command-r-plus",
message="Find relevant documents about our project.",
connectors=[
ChatConnector(
id="my-custom-connector",
user_access_token="user-token-abc123",
continue_on_failure=True,
options={"filter": "project:alpha"},
),
],
)