Overview
The ConnectorsClient and AsyncConnectorsClient classes provide a high-level interface for managing connectors in the Cohere API, supporting listing, creating, retrieving, updating, deleting connectors, and authorizing OAuth for connectors.
Description
This file is auto-generated by Fern from the Cohere API definition. It contains two classes:
ConnectorsClient -- The synchronous high-level client for connector management. Wraps RawConnectorsClient and exposes six methods: list, create, get, delete, update, and o_auth_authorize. Each method delegates to the corresponding raw client method and extracts the .data attribute from the HttpResponse wrapper.
AsyncConnectorsClient -- The asynchronous counterpart that wraps AsyncRawConnectorsClient and provides the same methods as async coroutines.
Connectors in the Cohere ecosystem are external data sources that can be used during chat and search operations to provide additional context. They support OAuth and service-to-service authentication, and can be configured with field exclusion rules and failure behavior settings.
Both classes expose a with_raw_response property that gives access to the underlying raw client for cases where the caller needs the full HTTP response metadata.
Usage
Use ConnectorsClient when you need to manage connectors for retrieval-augmented generation (RAG) workflows. It is accessed as a sub-client via client.connectors on a cohere.Client instance and is not typically instantiated directly.
Code Reference
Source Location
Signature
class ConnectorsClient:
def __init__(self, *, client_wrapper: SyncClientWrapper): ...
@property
def with_raw_response(self) -> RawConnectorsClient: ...
def list(
self,
*,
limit: typing.Optional[float] = None,
offset: typing.Optional[float] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> ListConnectorsResponse: ...
def create(
self,
*,
name: str,
url: str,
description: typing.Optional[str] = OMIT,
excludes: typing.Optional[typing.Sequence[str]] = OMIT,
oauth: typing.Optional[CreateConnectorOAuth] = OMIT,
active: typing.Optional[bool] = OMIT,
continue_on_failure: typing.Optional[bool] = OMIT,
service_auth: typing.Optional[CreateConnectorServiceAuth] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> CreateConnectorResponse: ...
def get(
self,
id: str,
*,
request_options: typing.Optional[RequestOptions] = None,
) -> GetConnectorResponse: ...
def delete(
self,
id: str,
*,
request_options: typing.Optional[RequestOptions] = None,
) -> DeleteConnectorResponse: ...
def update(
self,
id: str,
*,
name: typing.Optional[str] = OMIT,
url: typing.Optional[str] = OMIT,
excludes: typing.Optional[typing.Sequence[str]] = OMIT,
oauth: typing.Optional[CreateConnectorOAuth] = OMIT,
active: typing.Optional[bool] = OMIT,
continue_on_failure: typing.Optional[bool] = OMIT,
service_auth: typing.Optional[CreateConnectorServiceAuth] = OMIT,
request_options: typing.Optional[RequestOptions] = None,
) -> UpdateConnectorResponse: ...
def o_auth_authorize(
self,
id: str,
*,
after_token_redirect: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> OAuthAuthorizeResponse: ...
class AsyncConnectorsClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper): ...
@property
def with_raw_response(self) -> AsyncRawConnectorsClient: ...
async def list(...) -> ListConnectorsResponse: ...
async def create(...) -> CreateConnectorResponse: ...
async def get(...) -> GetConnectorResponse: ...
async def delete(...) -> DeleteConnectorResponse: ...
async def update(...) -> UpdateConnectorResponse: ...
async def o_auth_authorize(...) -> OAuthAuthorizeResponse: ...
Import
from cohere.connectors.client import ConnectorsClient, AsyncConnectorsClient
I/O Contract
Inputs
list()
| Name |
Type |
Required |
Description
|
| limit |
typing.Optional[float] |
No |
Maximum number of connectors to return. Range: [0, 100].
|
| offset |
typing.Optional[float] |
No |
Number of connectors to skip before returning results. Range: [0, inf].
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration (timeouts, headers, etc.).
|
create()
| Name |
Type |
Required |
Description
|
| name |
str |
Yes |
A human-readable name for the connector.
|
| url |
str |
Yes |
The URL of the connector used to search for documents.
|
| description |
typing.Optional[str] |
No |
A description of the connector.
|
| excludes |
typing.Optional[typing.Sequence[str]] |
No |
A list of fields to exclude from the prompt (fields remain in the document).
|
| oauth |
typing.Optional[CreateConnectorOAuth] |
No |
The OAuth 2.0 configuration. Cannot be specified if service_auth is specified.
|
| active |
typing.Optional[bool] |
No |
Whether the connector is active or not.
|
| continue_on_failure |
typing.Optional[bool] |
No |
Whether a chat request should continue if the request to this connector fails.
|
| service_auth |
typing.Optional[CreateConnectorServiceAuth] |
No |
The service-to-service authentication configuration. Cannot be specified if oauth is specified.
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration.
|
get()
| Name |
Type |
Required |
Description
|
| id |
str |
Yes |
The ID of the connector to retrieve.
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration.
|
delete()
| Name |
Type |
Required |
Description
|
| id |
str |
Yes |
The ID of the connector to delete.
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration.
|
update()
| Name |
Type |
Required |
Description
|
| id |
str |
Yes |
The ID of the connector to update.
|
| name |
typing.Optional[str] |
No |
A human-readable name for the connector.
|
| url |
typing.Optional[str] |
No |
The URL of the connector used to search for documents.
|
| excludes |
typing.Optional[typing.Sequence[str]] |
No |
A list of fields to exclude from the prompt.
|
| oauth |
typing.Optional[CreateConnectorOAuth] |
No |
The OAuth 2.0 configuration. Cannot be specified if service_auth is specified.
|
| active |
typing.Optional[bool] |
No |
Whether the connector is active or not.
|
| continue_on_failure |
typing.Optional[bool] |
No |
Whether a chat request should continue if the request to this connector fails.
|
| service_auth |
typing.Optional[CreateConnectorServiceAuth] |
No |
The service-to-service authentication configuration. Cannot be specified if oauth is specified.
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration.
|
o_auth_authorize()
| Name |
Type |
Required |
Description
|
| id |
str |
Yes |
The ID of the connector to authorize.
|
| after_token_redirect |
typing.Optional[str] |
No |
The URL to redirect to after the connector has been authorized.
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration.
|
Outputs
| Method |
Type |
Description
|
list() |
ListConnectorsResponse |
A list of connectors ordered by descending creation date.
|
create() |
CreateConnectorResponse |
A response confirming the connector was created. The connector is tested during registration.
|
get() |
GetConnectorResponse |
A response containing the details of the requested connector.
|
delete() |
DeleteConnectorResponse |
A response confirming the connector was deleted.
|
update() |
UpdateConnectorResponse |
A response confirming the connector was updated. Omitted fields are not modified.
|
o_auth_authorize() |
OAuthAuthorizeResponse |
A response containing the OAuth authorization result for the connector.
|
Usage Examples
from cohere import Client
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
# List connectors with pagination
connectors = client.connectors.list(limit=10, offset=0)
# Create a new connector
new_connector = client.connectors.create(
name="My Search Connector",
url="https://my-search-api.example.com/search",
description="Custom search connector for internal docs",
active=True,
continue_on_failure=True,
)
# Get a specific connector
connector = client.connectors.get(id="connector-id-123")
# Update a connector
updated = client.connectors.update(
id="connector-id-123",
name="Updated Connector Name",
active=False,
)
# Delete a connector
client.connectors.delete(id="connector-id-123")
# Authorize a connector for OAuth
auth_response = client.connectors.o_auth_authorize(
id="connector-id-123",
after_token_redirect="https://my-app.example.com/callback",
)
Related Pages