Overview
The RawConnectorsClient and AsyncRawConnectorsClient classes provide the low-level HTTP client for connector management operations against the Cohere v1/connectors API endpoint, returning typed HttpResponse wrappers that include both the parsed data and raw HTTP response metadata.
Description
This file is auto-generated by Fern from the Cohere API definition. It contains two classes:
RawConnectorsClient -- The synchronous low-level client (lines 38-1183) that directly issues HTTP requests to the Cohere connectors API. Each method constructs the HTTP request using the underlying SyncClientWrapper, sends it via httpx, parses the JSON response into typed models using construct_type, and returns an HttpResponse[T] wrapper. Error responses are mapped to specific exception types based on HTTP status code.
AsyncRawConnectorsClient -- The asynchronous counterpart (lines 1185-2329) that wraps AsyncClientWrapper and provides the same methods as async coroutines, returning AsyncHttpResponse[T].
The raw client supports six operations: listing connectors, creating connectors, retrieving a connector by ID, deleting a connector, updating a connector, and authorizing a connector for OAuth. Request bodies for create and update are serialized using convert_and_respect_annotation_metadata and sent as JSON POST/PATCH requests. Query parameters for list and o_auth_authorize are passed as URL parameters.
The connector API uses more granular error handling than the batches API, including additional error types for rate limiting, unprocessable entities, gateway timeouts, and invalid tokens.
Usage
The raw client is typically not used directly by end users. Instead, it is wrapped by ConnectorsClient which extracts the .data attribute for convenience. Use the raw client directly when you need access to HTTP response metadata such as status codes and headers, accessible via client.connectors.with_raw_response.
Code Reference
Source Location
Signature
class RawConnectorsClient:
def __init__(self, *, client_wrapper: SyncClientWrapper): ...
def list(
self,
*,
limit: typing.Optional[float] = None,
offset: typing.Optional[float] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> HttpResponse[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,
) -> HttpResponse[CreateConnectorResponse]: ...
def get(
self,
id: str,
*,
request_options: typing.Optional[RequestOptions] = None,
) -> HttpResponse[GetConnectorResponse]: ...
def delete(
self,
id: str,
*,
request_options: typing.Optional[RequestOptions] = None,
) -> HttpResponse[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,
) -> HttpResponse[UpdateConnectorResponse]: ...
def o_auth_authorize(
self,
id: str,
*,
after_token_redirect: typing.Optional[str] = None,
request_options: typing.Optional[RequestOptions] = None,
) -> HttpResponse[OAuthAuthorizeResponse]: ...
class AsyncRawConnectorsClient:
def __init__(self, *, client_wrapper: AsyncClientWrapper): ...
async def list(...) -> AsyncHttpResponse[ListConnectorsResponse]: ...
async def create(...) -> AsyncHttpResponse[CreateConnectorResponse]: ...
async def get(...) -> AsyncHttpResponse[GetConnectorResponse]: ...
async def delete(...) -> AsyncHttpResponse[DeleteConnectorResponse]: ...
async def update(...) -> AsyncHttpResponse[UpdateConnectorResponse]: ...
async def o_auth_authorize(...) -> AsyncHttpResponse[OAuthAuthorizeResponse]: ...
Import
from cohere.connectors.raw_client import RawConnectorsClient, AsyncRawConnectorsClient
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. Encoded into the URL path as v1/connectors/{id}.
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration.
|
delete()
| Name |
Type |
Required |
Description
|
| id |
str |
Yes |
The ID of the connector to delete. Encoded into the URL path as v1/connectors/{id}.
|
| request_options |
typing.Optional[RequestOptions] |
No |
Request-specific configuration.
|
update()
| Name |
Type |
Required |
Description
|
| id |
str |
Yes |
The ID of the connector to update. Encoded into the URL path as v1/connectors/{id}.
|
| 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. Encoded into the URL path as v1/connectors/{id}/oauth/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() |
HttpResponse[ListConnectorsResponse] |
HTTP response wrapper containing parsed connector list data and raw response metadata.
|
create() |
HttpResponse[CreateConnectorResponse] |
HTTP response wrapper containing parsed create response data and raw response metadata.
|
get() |
HttpResponse[GetConnectorResponse] |
HTTP response wrapper containing parsed connector details and raw response metadata.
|
delete() |
HttpResponse[DeleteConnectorResponse] |
HTTP response wrapper containing parsed delete confirmation and raw response metadata.
|
update() |
HttpResponse[UpdateConnectorResponse] |
HTTP response wrapper containing parsed update response data and raw response metadata.
|
o_auth_authorize() |
HttpResponse[OAuthAuthorizeResponse] |
HTTP response wrapper containing parsed OAuth authorization response and raw response metadata.
|
HTTP Endpoints
| Method |
HTTP Verb |
Endpoint
|
list() |
GET |
v1/connectors
|
create() |
POST |
v1/connectors
|
get() |
GET |
v1/connectors/{id}
|
delete() |
DELETE |
v1/connectors/{id}
|
update() |
PATCH |
v1/connectors/{id}
|
o_auth_authorize() |
POST |
v1/connectors/{id}/oauth/authorize
|
Error Handling
| HTTP Status |
Exception Class
|
| 400 |
BadRequestError
|
| 401 |
UnauthorizedError
|
| 403 |
ForbiddenError
|
| 404 |
NotFoundError
|
| 407 |
InvalidTokenError
|
| 422 |
UnprocessableEntityError
|
| 429 |
TooManyRequestsError
|
| 498 |
InvalidTokenError
|
| 499 |
ClientClosedRequestError
|
| 500 |
InternalServerError
|
| 501 |
NotImplementedError
|
| 503 |
ServiceUnavailableError
|
| 504 |
GatewayTimeoutError
|
| Other non-2xx |
ApiError
|
Usage Examples
from cohere import Client
client = Client(
client_name="YOUR_CLIENT_NAME",
token="YOUR_TOKEN",
)
# Access the raw client via the with_raw_response property
raw_response = client.connectors.with_raw_response.list(limit=10)
# Access HTTP metadata
print(raw_response.status_code)
print(raw_response.headers)
# Access the parsed data
connectors_data = raw_response.data
print(connectors_data)
# Create a connector and inspect the raw response
raw_create = client.connectors.with_raw_response.create(
name="My Connector",
url="https://search-api.example.com/search",
)
print(raw_create.status_code)
print(raw_create.data)
Related Pages