Skip to main content
Cohere

Search documentation

Type to search this documentation.

On this pageOverview

How to Manage a Cohere Connector

Once your connector is deployed and registered, there are a couple of features that will help you to manage it.

You can see all the connectors registered under your organization through the Cohere dashboard. Alternatively, you can make a GET request like the one below:

CURL
curl --request GET  
  --url 'https://api.cohere.ai/v1/connectors'  
  --header 'Authorization: Bearer {Cohere API key}'
TYPESCRIPT
const { CohereClient } = require("cohere-ai");
const cohere = new CohereClient({
    token: "Your API key",
});
(async () => {
  const connectors = await cohere.connectors.list();
  console.log(connectors);
})();
PYTHON
import cohere

# initialize the Cohere Client with an API Key

co = cohere.Client("YOUR_API_KEY")
connectors = co.list_connectors()

If your connector is set up using OAuth 2.0, a user in your organization can authorize the connector through the dashboard by clicking on “connect your account”. Alternatively, you can make a request to the /oauth/authorize endpoint in your application. This will provide a redirect URL that the user can follow to authorize the OAuth application.

CURL
curl --request POST  
  --url 'https://api.cohere.ai/v1/connectors/{connector-id}/oauth/authorize' 
  --header 'Authorization: Bearer {Cohere API key for user wishing to authorize}'
TYPESCRIPT
const { CohereClient } = require("cohere-ai");
const cohere = new CohereClient({
    token: "Your API key",
});
(async () => {
  const connector = await cohere.connectors.oAuthAuthorize("connector-id", {
    redirect_uri: "https://example.com/oauth/callback",
  });
  console.log(connector);
})();

You can enable and disable a connector through the dashboard. Additionally, you can update the connector name, URL, auth settings, and handle similar sorts of tasks through the API, as follows:

CURL
curl --request PATCH  
  --url 'https://api.cohere.ai/v1/connectors/{id}' 
  --header 'Authorization: Bearer {Cohere API key}'  
  --header 'Content-Type: application/json'  
  --data '{  
        "name": "new connector name",  
        "url": "https://new-connector-example.com/search",  
        "auth_type": "oauth",  
        "oauth": {  
            "authorize_url": "https://new.com/authorize",  
            "token_url": "https://new.com/access",  
            "scope": "new_scope"  
        },  
        "active": true,  
    }'
PYTHON
import cohere

# initialize the Cohere Client with an API Key
co = cohere.Client("YOUR_API_KEY")
connectors = co.update_connector(
    connector_id, name="new name", url="new_url"
)
TYPESCRIPT
const { CohereClient } = require("cohere-ai");
const cohere = new CohereClient({
    token: "Your API key",
});
(async () => {
  const connector = await cohere.connectors.update(connector.id, {
    name: "test-connector-renamed",
    description: "A test connector renamed"
  });
  console.log(connector);
})();

To debug issues with a registered connector, you can follow the steps in this section.

Step 1: Make a streaming request to the connector using the Chat API and check the search results for the error. Here's an example request:

PYTHON
import cohere

co = cohere.Client("Your API key")
response = co.chat(
    message="What is the chemical formula for glucose?",
    stream=True,
    connectors=[
        {"id": "example_connector_id"}
    ],  # this is from the create step
)
CURL
curl --request POST  \
--url <https://api.cohere.ai/chat>  \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {Your API key}' \
--data '
{
    "stream" : true,  
    "message": "What is the chemical formula for glucose?",
    "connectors": [{"id": "example_connector_id"}]
}
TYPESCRIPT
import { CohereClient } from "cohere-ai";
const cohere = new CohereClient({
    token: "YOUR_API_KEY",
});
(async () => {
    const response = await cohere.chat({
      message:"What is the chemical formula for glucose?", 
      stream:True,
      connectors:[{"id": "web-search"}],  
    });
    console.log("Received response", response);
})();
GO
import (
  "context"
  
  cohere       "github.com/cohere-ai/cohere-go/v2"
  cohereclient "github.com/cohere-ai/cohere-go/v2/client"
)
client := cohereclient.NewClient(cohereclient.WithToken("<YOUR_AUTH_TOKEN>"))
response, err := client.Chat(
  context.TODO(),
  &cohere.ChatRequest{
    Stream: true,
    Message: "What is the chemical formula for glucose?",
    Connectors:[]*cohereclient.ChatConnector{{Id: "web-search"}}, 
  } 
)

The response in the search results array should contain the error message from the connector:

Example
 "search_results": [  
    {  
        "connector": {  
            "id": "connector_id"  
        },  
        "error_message":"connector error message"  
    }

Step 2: In Cohere’s dashboard you can view and filter the logs from calling your connector. Change the response filter to “error” to see the error messages returned from your connector.

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu