How to Attach and Detach Agent Knowledge Bases

Validated on 28 Apr 2025 • Last edited on 8 Jul 2025

GradientAI Platform lets you build fully-managed AI agents with knowledge bases for retrieval-augmented generation, multi-agent routing, guardrails, and more, or use serverless inference to make direct requests to popular foundation models.

You can [attach knowledge bases](#attach) to give agents access to additional custom data, or detach them if the information is no longer needed. Attaching or detaching knowledge bases triggers an immediate redeployment of the agent.

Attach a Knowledge Base to an Agent Using the Control Panel

To attach a knowledge base using the DigitalOcean Control Panel, in the left menu, click Agent Platform, then click the Agents tab. In the list, click the agent you want to update, then click its Resources tab. In the Knowledge Bases section, click Add Knowledge Bases.

In the Knowledge Bases field, type and then select the knowledge base you want to attach. A knowledge base must have vector embeddings to appear in the list. If it’s created but not yet indexed, you cannot attach it to an agent. After selecting the knowledge bases, click Add Knowledge Bases.

You can view attached knowledge bases in the agent’s Resources tab, along with the last indexing time and attachment date.

Attach a Knowledge Base to an Agent Using the API

To attach a knowledge base using the API, provide the agent’s ID and the knowledge base ID. Retrieve available knowledge bases using the List Knowledge Bases endpoint, and agents using the List Agents endpoint.

A knowledge base must have at least one indexed data source to appear in the list. To index a knowledge base, find its ID in the list, then index its data sources.

How to Attach a Knowledge Base to an Agent Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.
  2. Send a POST request to https://api.digitalocean.com/v2/gen-ai/agents/{agent_uuid}/knowledge_bases.

cURL

Using cURL:

curl -X POST \
 -H "Content-Type: application/json" \
 -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
 "https://api.digitalocean.com/v2/gen-ai/agents/1b418231-b7d6-11ef-bf8f-4e013e2ddde4/knowledge_bases" \
 -d '{
   "agent_uuid": "1b418231-b7d6-11ef-bf8f-4e013e2ddde4",
   "knowledge_base_uuids": [
     "9a6e3975-b0c6-11ef-bf8f-4e013e2ddde4",
     "683c3100-7c18-4c94-aea4-5ac5875cc87c",
     "4887a78b-74af-46b3-98f4-451a48f9cc5e"
   ]
 }'

Once attached, the agent can access and retrieve content from the knowledge base during prompt processing.

Detach a Knowledge Base from an Agent Using the Control Panel

You can detach a knowledge base if it’s no longer needed. This stops the agent from referencing it but doesn’t delete or affect the knowledge base itself. Detaching a knowledge base triggers immediate agent redeployment, which may take a few minutes.

From the DigitalOcean Control Panel, in the left menu, click Agent Platform, then click the Agents tab. In the list, click the agent you need, then click its Resources tab. In the Knowledge Bases section, find the knowledge base to detech. To the right of the knowledge base, click to open the knowledge base menu, then click Detach Knowledge Base. In the confirmation window, type the knowledge base’s name, then click Detach Knowledge Base.

Detach a Knowledge Base from an Agent Using the API

To detach a knowledge base using the API, provide the agent ID and knowledge base ID. Retrieve IDs using the List Agents and List Knowledge Bases endpoints.

How to Detach a Knowledge Base From an Agent Using the DigitalOcean API
  1. Create a personal access token and save it for use with the API.
  2. Send a DELETE request to https://api.digitalocean.com/v2/gen-ai/agents/{agent_uuid}/knowledge_bases/{knowledge_base_uuid}.

cURL

Using cURL:

curl -X DELETE \
  -H "Content-Type: application/json"  \
  -H "Authorization: Bearer $DIGITALOCEAN_TOKEN" \
  "https://api.digitalocean.com/v2/gen-ai/knowledge_bases/9a6e3975-b0c6-11ef-bf8f-4e013e2ddde4/data_sources/bd2a2db5-b8b0-11ef-bf8f-4e013e2ddde4"

We can't find any results for your search.

Try using different keywords or simplifying your search terms.