---
title: Set Up a Self-Managed Agent
latest-operator-version: v26.2.6
latest-console-tag: v3.14.0
latest-connect-version: 4.118.0
latest-redpanda-tag: v26.2.7
docname: self-managed-agents
page-component-name: agentic-data-plane
page-version: master
page-component-version: master
page-component-title: Agentic Data Plane
page-relative-src-path: self-managed-agents.adoc
page-edit-url: https://github.com/redpanda-data/adp-docs/edit/main/modules/connect/pages/self-managed-agents.adoc
description: Register a self-managed agent, issue it a client credential, and route its LLM and tool calls through the AI Gateway for spend, traces, and transcripts.
page-topic-type: how-to
personas: agent_builder, platform_engineer
learning-objective-1: Choose a self-managed agent over a managed agent for your use case
learning-objective-2: Register a self-managed agent and issue it an OAuth client credential
learning-objective-3: Route an agent's LLM and MCP calls through the AI Gateway and stream transcripts
page-git-created-date: "2026-06-17"
page-git-modified-date: "2026-11-03"
page-generated-content: none
---

# Set Up a Self-Managed Agent

> For the complete documentation index, see [llms.txt](https://docs.redpanda.com/llms.txt). Component-specific: [agentic-data-plane-full.txt](https://docs.redpanda.com/agentic-data-plane-full.txt)

<!-- Source: https://docs.redpanda.com/agentic-data-plane/connect/self-managed-agents.md -->

A self-managed agent is an agent you build and run yourself, registered with Redpanda Agentic Data Plane as an identity. You keep your runtime, framework, and hosting. Agentic Data Plane gives the agent a [service account](https://docs.redpanda.com/home/glossary/#service-account) and a client credential, and the [AI Gateway](https://docs.redpanda.com/home/glossary/#ai-gateway) becomes the agent’s LLM and MCP endpoint. Because every model call and tool call flows through the gateway, Agentic Data Plane attributes spend, tokens, latency, and traces back to the agent. To view each session as a transcript, the agent also streams its own OpenTelemetry spans to Agentic Data Plane. Agentic Data Plane does not host or run your agent.

After reading this page, you will be able to:

-   Choose a self-managed agent over a managed agent for your use case

-   Register a self-managed agent and issue it an OAuth client credential

-   Route an agent’s LLM and MCP calls through the AI Gateway and stream transcripts


## Self-managed compared to managed agents

The two agent types differ in who runs the agent and how it is defined. They coexist in the same registry, the same governance views, and the same cost-attribution queries.

| Question | Self-managed | Managed |
| --- | --- | --- |
| Who runs the agent? | You do. Agentic Data Plane registers the agent and proxies its LLM and tool calls, but the runtime is yours. | Redpanda deploys, runs, and observes the agent for you. |
| How is the agent defined? | It is already coded in your own framework, for example, LangChain, CrewAI, or a custom runtime. | You configure it declaratively through the create form, with no runtime code to maintain. |
| What connects it to Agentic Data Plane? | A client credential the agent exchanges for a gateway token. Your code points its LLM and MCP clients at the gateway. | The managed runtime wires the gateway for you. |

For the declarative path, see [Create an agent](https://docs.redpanda.com/agentic-data-plane/connect/create-agent/).

## Prerequisites

-   Access to create an agent, from an [access policy](https://docs.redpanda.com/agentic-data-plane/control/access-policies/) granting `Action::"Agent.create"`, or from the Admin role. See [Agent management permissions](https://docs.redpanda.com/agentic-data-plane/control/permissions-reference/#agent-management-permissions).

-   Access to author access policies, because registering a self-managed agent also creates one. Get it from an access policy granting the `Policy` actions, or from the Admin role, the only built-in role that has it. See [Access policy permissions](https://docs.redpanda.com/agentic-data-plane/control/permissions-reference/#access-policy-permissions).

-   At least one [LLM provider configured](https://docs.redpanda.com/agentic-data-plane/gateway/configure-provider/) in Agentic Data Plane. The agent calls the model through this provider. The **Setup** tab’s generated samples support OpenAI, Anthropic, Google Gemini API, and Gemini Enterprise Agent Platform providers only.

-   If the agent calls tools: One or more [MCP servers](https://docs.redpanda.com/agentic-data-plane/connect/mcp-overview/) registered in Agentic Data Plane.

-   An agent built in your own framework. The **Setup** tab generates ready-to-paste samples for ai-sdk-go (the Redpanda AI SDK), ADK Go, Vercel AI SDK, Mastra, LangChain, CrewAI, ADK Python, and ADK Java.


## Register the agent

1.  Open **Agents** in the sidebar.

2.  Click **Create agent**.

3.  Click **Self-managed**, so Agentic Data Plane registers the agent as an identity and leaves the runtime to you.

    ![Choose Managed by Redpanda or Self-managed in the agent runtime picker.](https://docs.redpanda.com/agentic-data-plane/shared/_images/create-agent-runtime-choice.png)

4.  Under Identity on the Register self-managed agent canvas, fill in the fields that name the agent:

    -   **Name**: Required. Human-readable name shown in the agent list and detail header. The form opens with a suggested name, and **Suggest a name** replaces it with another one. Agentic Data Plane derives the agent’s resource ID from this name when you register the agent. You don’t enter the ID directly. The derived ID is used in URLs, in cost-attribution queries, and as the agent’s resource identifier, and it can’t be changed after creation.

    -   **Description**: Optional. Up to 1024 characters. An internal note shown on the agent’s detail page.


5.  Under Access, choose what the agent may call. This section is required. **Create agent** stays disabled until you link a policy template or add at least one permission, and until then the footer reads _Choose a policy template or add at least one permission_. If something else in the policy is still missing, such as a specific resource you haven’t named, the footer names that instead. If you cleared the suggested name, the footer asks for a name first.

    The section embeds the access policy editor with the principal locked to this agent, so you choose what the grant reaches rather than who gets it, and you don’t name the policy. Agentic Data Plane names it after the agent’s resource ID. For the fields, see [Create a policy](https://docs.redpanda.com/agentic-data-plane/control/access-policies/#create-a-policy).

    The policy follows the agent’s ID. If the name you chose is already taken, Agentic Data Plane adds a suffix to the ID, and the policy takes the suffixed ID too.

6.  Optional: expand **Advanced** to add Tags, key/value pairs that organize and filter agents and that break down [cost and usage](https://docs.redpanda.com/agentic-data-plane/control/cost-usage/).

7.  Click **Create agent**.


Agentic Data Plane registers the agent, writes its access policy, and opens the agent’s **Permissions** tab, where the new policy is listed. The agent carries a Self-managed type badge. A self-managed agent carries no provider, model, or tool configuration of its own. It is an identity that calls the organization’s shared gateway resources.

To add more policies for the agent, including forbids, work from that tab. See [Grant an agent its own permissions](https://docs.redpanda.com/agentic-data-plane/control/access-policies/#grant-an-agent-its-own-permissions).

If the agent is registered but its access policy can’t be saved, the Access section reports which agent was created and why the write failed, and offers **Retry** and **Open Permissions**. Use either one to finish the policy. The agent doesn’t need to be registered again.

## Issue a client secret

Agentic Data Plane provisions a service account for the agent at registration. To authenticate the agent’s calls, issue an OAuth 2.0 client secret on the agent’s **Credentials** tab.

1.  Open the agent’s **Credentials** tab.

    ![Agent credentials with the Client ID, authorized scope, and Create secret action.](https://docs.redpanda.com/agentic-data-plane/connect/_images/self-managed-agent-credentials.png)

2.  Note the Client ID. It has the form `serviceaccounts/<agent-name>`, where `<agent-name>` is the agent’s resource ID, derived from its name. The Client ID is public and stable. Every secret on the agent shares it.

3.  Click **Create secret**.

4.  Optionally enter a `Name` to identify the secret in the list and in audit logs, for example, `production`. If you leave it blank, Agentic Data Plane assigns a default name such as `secret-1`.

5.  Click **Generate secret**.

    The Secret created dialog shows the secret one time. Click **Copy secret** to copy it.

    ![Secret created dialog with a masked client secret and Copy secret action.](https://docs.redpanda.com/agentic-data-plane/connect/_images/self-managed-agent-secret-created.png)

6.  Store the secret in your secret manager or container environment variables, then click **I’ve saved it**.


> ❗ **IMPORTANT**
>
> The client secret is shown only at creation. Agentic Data Plane stores a hash and cannot show the plaintext again.

### Set the secret lifetime and rotate secrets

A secret created on the **Credentials** tab expires 90 days after creation. That is the default lifetime, not a fixed limit. To set a different one, create the secret with `rpk ai agent credential create <agent-name> --ttl <duration>` (for example, `--ttl 8760h` for one year). No maximum is enforced, and every secret has an expiry. A long lifetime trades rotation work for exposure if the secret leaks, so still plan to rotate.

To rotate without downtime, create a new secret, deploy it, and then revoke the old one with **Revoke** on its row in the secrets list. The old secret keeps working until you revoke it or it expires, and all of an agent’s secrets share the same Client ID, so only the secret value changes in your deployment. An agent can have up to 10 unexpired secrets at a time. Expired secrets do not count toward that cap.

## Connect your agent to the AI Gateway

The agent’s **Setup** tab generates everything your code needs: the gateway endpoints, an environment-variable block, a copy-paste SDK sample for your framework, and the commands to install its dependencies and run it. The install command lists every package the sample imports, so the sample runs without your adding any by hand.

Open the **Setup** tab, pick your framework, then work through the tab’s steps in order:

1.  Create a credential: The same client secret you issued on the **Credentials** tab, embedded in the step. One credential authorizes the agent’s LLM calls through the gateway, its tool calls to MCP servers, and its span exports.

2.  Wire up your framework: Copy the environment-variable block and the generated sample. Select the LLM provider the sample connects through, and optionally the MCP servers it uses. Your selection fills in the values without changing the agent. The same block configures the OpenTelemetry exporter that streams the agent’s spans (see [Stream transcripts](#stream-transcripts)).

3.  Check it works: Run the generated shell request. It mints a token and calls the gateway, so a failure here is the wiring and not your program. The step’s validation log reports what happened to any spans the agent exported.


If your environment doesn’t run the trace-ingestion endpoint, step 2 says so. The gateway half of the setup works as written, but exported spans have nowhere to land until transcripts are available there.

![Setup credential step with the Client ID and Create secret action.](https://docs.redpanda.com/agentic-data-plane/connect/_images/self-managed-agent-setup-credential.png)

Figure 1. The Setup tab starts with the agent credential

![Setup environment variables for agent authentication, gateway URLs, and OpenTelemetry export.](https://docs.redpanda.com/agentic-data-plane/connect/_images/self-managed-agent-setup-env.png)

In the endpoint URLs on this page, `<cluster-id>` is your cluster’s identifier and `<gateway-base>` is `https://aigw.<cluster-id>.clusters.rdpa.co`. Copy the exact values from the **Setup** tab.

### Authenticate with the client credential

The gateway runs its own OAuth 2.0 identity provider. Unlike model providers that issue one static, long-lived API key, the gateway issues short-lived access tokens, so your code mints a token and refreshes it as it runs rather than reading a key from an environment variable. Exchange the Client ID and client secret for an access token with the `client_credentials` grant against the token endpoint:

```text
<gateway-base>/oauth/idp/token
```

Send the resulting token as an `Authorization: Bearer` header on every LLM and MCP request. The gateway authenticates on this token and injects the real upstream provider key itself, so your SDK’s own API-key field is a placeholder. Your client is responsible for refreshing the token before it expires.

### Route LLM calls through the gateway

Point your SDK’s base URL at the provider’s gateway endpoint instead of the upstream API:

```text
<gateway-base>/llm/v1/providers/<provider-name>
```

In this URL, `<provider-name>` is the name of an LLM provider you configured in Agentic Data Plane. The gateway forwards each provider’s native API to the upstream, so you keep using the provider’s own SDK. If the provider has a model allowlist, pick a model on it, or the gateway rejects the call with `403 model_not_allowed`. For the full proxy contract and per-SDK setup, see [Connect your app to AI Gateway](https://docs.redpanda.com/agentic-data-plane/gateway/connect-agent/).

### Route MCP tool calls through the gateway

Point your MCP client at each server’s gateway URL, with the same bearer token:

```text
<gateway-base>/mcp/v1/<server-name>
```

In this URL, `<server-name>` is the name of an MCP server registered in Agentic Data Plane. Routing tool calls through the gateway keeps them under the same identity, governance, and observability as the model calls.

### Group a session’s calls with a conversation ID

Conversations group on the `gen_ai.conversation.id` attribute carried by the spans your agent exports. See [Stream transcripts](#stream-transcripts). Also send the `X-Redpanda-Genai-Conversation` header on every gateway call in the session, set to the same identifier. The gateway stamps that conversation ID on its own record of each call. The header does not affect authentication or whether calls succeed, and it is not a substitute for instrumenting your agent. A transcript is built only from the spans your agent exports.

### Stream transcripts

Agentic Data Plane assembles the agent’s **Transcripts** tab from OpenTelemetry spans your agent exports itself, not from the gateway calls alone. The **Setup** tab’s environment block and generated sample wire this up: a standard OpenTelemetry exporter pointed at the environment’s OTLP endpoint (`https://otlp.<cluster-id>.clusters.rdpa.co`), authorized by minting short-lived tokens from the same client credential your code already uses. The sample also stamps a stable `gen_ai.conversation.id` attribute on every span in the session.

Agentic Data Plane reads the OpenTelemetry [semantic conventions for generative AI](https://github.com/open-telemetry/semantic-conventions-genai/blob/main/docs/gen-ai/gen-ai-spans.md), so a framework whose instrumentation already emits `gen_ai.*` attributes needs no mapping of its own. For the span attributes transcripts require, the ingestion limits, and the validation log, see [Self-Managed Agent Telemetry Reference](https://docs.redpanda.com/agentic-data-plane/connect/self-managed-telemetry/).

Each distinct `gen_ai.conversation.id` becomes one conversation on the **Transcripts** tab, grouping the exported spans that carry it into one row.

![Conversations table with user, status, duration, turns, tokens, and sorting controls.](https://docs.redpanda.com/agentic-data-plane/connect/_images/self-managed-agent-transcripts.png)

## Framework samples

The **Setup** tab generates a ready-to-paste sample for your framework that already includes your selected provider and MCP servers, together with the environment-variable block and install commands it needs. Copy them from the tab rather than from another agent or an older note, so you always get the current wiring. Samples are available for ai-sdk-go (the Redpanda AI SDK), ADK Go, Vercel AI SDK, Mastra, LangChain, CrewAI, ADK Python, and ADK Java.

Some frameworks' instrumentation limits what a transcript can show. See [Framework caveats](https://docs.redpanda.com/agentic-data-plane/connect/self-managed-telemetry/#framework-caveats).

> 📝 **NOTE**
>
> ADK Go ships only Gemini-shaped models, so the ADK Go sample works against a Google provider only. For an OpenAI or Anthropic provider, use one of the other frameworks.

> 📝 **NOTE**
>
> For a Gemini Enterprise Agent Platform provider, the **Setup** tab generates only the LangChain sample, and only for a Claude or Gemini model on the provider. For any other framework, the tab says it has no sample yet and points to LangChain. See [Set up Gemini Enterprise Agent Platform as an LLM provider](https://docs.redpanda.com/agentic-data-plane/gateway/vertex-setup/).

## Observe the agent

Because the agent’s traffic flows through the gateway, Agentic Data Plane attributes its cost and usage without any instrumentation in your code. Spend, tokens, and latency roll up to the agent, from the calls routed through the gateway. See them on the agent’s **Cost & Usage** tab and in [budgets](https://docs.redpanda.com/agentic-data-plane/control/budgets/).

Transcripts take one more step. Routing calls through the gateway records their cost and usage, but Agentic Data Plane assembles the **Transcripts** tab from the OpenTelemetry spans your agent exports (wired by the **Setup** tab, described in [Stream transcripts](#stream-transcripts)). When the agent streams its own spans, each session appears on the agent’s **Transcripts** tab. [See what your agent did](https://docs.redpanda.com/agentic-data-plane/monitor/transcripts/).

A transcript always shows token usage, latency, and tool calls. It shows prompt and response text only when the agent’s own instrumentation captures message content. The generated environment block enables capture for the frameworks that support it. See [Message content capture](https://docs.redpanda.com/agentic-data-plane/connect/self-managed-telemetry/#message-content-capture).

## Troubleshooting

| Symptom | What to check |
| --- | --- |
| `401` on the token request | The Client ID or client secret is wrong, or the secret expired or was revoked. The Client ID must be the full `serviceaccounts/<agent-name>` value. Issue a new secret on the **Credentials** tab. |
| `resource_exhausted` with `secret cap exceeded` when you create a secret | The agent already has 10 unexpired secrets. Revoke one you no longer use, on the **Credentials** tab or with `rpk ai agent credential delete <credential-name>`, and try again. Run `rpk ai agent credential list <agent-name>` to find the credential’s full name, for example `agents/my-agent/credentials/abc123`. Expired secrets do not count toward the cap. |
| `403` with `model_not_allowed` | The model is not on the provider’s allowlist. Pick a model the provider serves. The **Setup** tab fills in a valid model for you. |
| `404` from the LLM endpoint | The provider name in the URL does not match a configured provider. Confirm the segment after `/providers/` matches the provider’s name exactly. |
| The **Setup** tab reports _Model catalog unavailable_ | On a Gemini Enterprise Agent Platform provider, the tab reads the provider’s model metadata to choose a sample and a verification call. A catalog it can’t load leaves the verification call without content, and also the sample when you chose LangChain, the one framework with a sample for this provider. Click **Try again**. The other provider types don’t read the catalog and aren’t affected. |
| The **Transcripts** tab stays empty | The agent is not exporting its OpenTelemetry spans, or the spans fail validation. Transcripts are assembled only from the spans the agent exports, with a stable `gen_ai.conversation.id` on every span. Sending the `X-Redpanda-Genai-Conversation` header on gateway calls is not a substitute for exporting spans. Check the validation log on the **Setup** tab, then work through the exporter-side checks in [Validate ingestion](https://docs.redpanda.com/agentic-data-plane/connect/self-managed-telemetry/#validate-ingestion). |
| A transcript shows usage but no message text | The agent’s instrumentation is not capturing message content. Enable capture in the agent’s instrumentation (see [Message content capture](https://docs.redpanda.com/agentic-data-plane/connect/self-managed-telemetry/#message-content-capture)). Capture applies only to spans exported after the change. |

## Next steps

-   [Self-managed agent telemetry reference](https://docs.redpanda.com/agentic-data-plane/connect/self-managed-telemetry/)

-   [Connect your app to AI Gateway](https://docs.redpanda.com/agentic-data-plane/gateway/connect-agent/)

-   [See what your agent did](https://docs.redpanda.com/agentic-data-plane/monitor/transcripts/)

-   [Create an agent](https://docs.redpanda.com/agentic-data-plane/connect/create-agent/)