Skip to content

Commit 9aef822

Browse files
committed
configure AI Gateway LLM & MCP endpoints in Claude Code & similar tools
1 parent 697652e commit 9aef822

1 file changed

Lines changed: 197 additions & 7 deletions

File tree

modules/ai-agents/pages/ai-gateway.adoc

Lines changed: 197 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,13 @@ NOTE: AI Gateway is supported on BYOC clusters running Redpanda version 25.3 and
66

77
The Redpanda AI Gateway is a production-grade proxy that provides unified access to multiple Large Language Model (LLM) providers and Model Context Protocol (MCP) servers through a single endpoint. It maintains centralized control over routing, rate limiting, cost optimization, security, and observability.
88

9+
Common gateway patterns:
10+
11+
* *Team isolation*: Create separate gateways for each team to track usage and enforce budgets independently.
12+
* *Environment separation*: Use different gateways for staging and production with appropriate rate limits.
13+
* *Failover*: Configure a primary provider pool with a fallback pool for high availability.
14+
* *A/B testing*: Distribute traffic across providers to compare performance and cost.
15+
916
== Prerequisites
1017

1118
* Access to the AI Gateway UI (provided by your administrator)
@@ -20,7 +27,7 @@ Before a gateway owner can create a gateway, an administrator must enable LLM pr
2027

2128
Providers represent upstream services (Anthropic, OpenAI) and associated credentials. Providers are disabled by default. An administrator must enable them explicitly by adding credentials.
2229

23-
. Navigate to *Providers*.
30+
. In AI Gateways, navigate to *Providers*.
2431
. Select a provider (for example, Anthropic).
2532
. On the *Configuration* tab, enter your API Key.
2633

@@ -106,7 +113,7 @@ You can aggregate multiple MCP servers behind a single endpoint. For example:
106113
* The gateway presents a single aggregated MCP surface to the agent.
107114
* Agents can list/search tools and call them through the gateway.
108115

109-
*MCP orchestrator*
116+
*MCP orchestrator:*
110117

111118
The orchestrator is a built-in MCP server that enables programmatic tool calling. The agent can generate JavaScript to call multiple tools in a single orchestrated step, which reduces the number of round trips. For example, a workflow requiring 47 file reads can be reduced from 49 round trips to just 1.
112119

@@ -177,9 +184,192 @@ Guard for field existence:
177184
has(request.body.max_tokens) && request.body.max_tokens > 1000
178185
----
179186

180-
== Common gateway patterns
187+
== Integrate with AI agents and tools
181188

182-
* *Team isolation*: Create separate gateways for each team to track usage and enforce budgets independently.
183-
* *Environment separation*: Use different gateways for staging and production with appropriate rate limits.
184-
* *Failover*: Configure a primary provider pool with a fallback pool for high availability.
185-
* *A/B testing*: Distribute traffic across providers to compare performance and cost.
189+
The AI Gateway provides standardized endpoints that work with various AI development tools and agents. This section shows how to configure popular tools to use your AI Gateway endpoints.
190+
191+
=== MCP server endpoint
192+
193+
If you've configured MCP tools in your gateway, AI agents can connect to the aggregated MCP endpoint:
194+
195+
* MCP endpoint URL: `https://gw.ai.panda.com/mcp`
196+
197+
* Headers required:
198+
** `Authorization: Bearer your-api-key`
199+
** `rp-aigw-id: your-gateway-id`
200+
201+
This endpoint aggregates all MCP servers configured in your gateway, providing a unified interface for tool discovery and execution.
202+
203+
=== Environment variables
204+
205+
For consistent configuration across tools, set these environment variables:
206+
207+
[source,bash]
208+
----
209+
export REDPANDA_GATEWAY_URL="https://gw.ai.panda.com"
210+
export REDPANDA_GATEWAY_ID="your-gateway-id"
211+
export REDPANDA_API_KEY="your-api-key"
212+
----
213+
214+
Many tools and SDKs can automatically use these environment variables when configured appropriately.
215+
216+
=== Claude Code
217+
218+
Configure Claude Code to use AI Gateway endpoints by creating or editing your MCP configuration file.
219+
220+
*For Claude Desktop (with VS Code extension):*
221+
222+
Create or edit `.vscode/settings.json`:
223+
224+
[source,json]
225+
----
226+
{
227+
"claude.mcpServers": {
228+
"redpanda-ai-gateway": {
229+
"command": "node",
230+
"args": ["/path/to/mcp-redpanda-gateway/index.js"],
231+
"env": {
232+
"GATEWAY_ENDPOINT": "https://gw.ai.panda.com",
233+
"GATEWAY_ID": "your-gateway-id",
234+
"API_KEY": "your-api-key"
235+
}
236+
}
237+
}
238+
}
239+
----
240+
241+
*For Claude Code CLI:*
242+
243+
Create or edit `~/.claude/config.json`:
244+
245+
[source,json]
246+
----
247+
{
248+
"mcpServers": {
249+
"redpanda-ai-gateway": {
250+
"command": "npx",
251+
"args": ["@redpanda/mcp-ai-gateway"],
252+
"env": {
253+
"REDPANDA_GATEWAY_URL": "https://gw.ai.panda.com",
254+
"REDPANDA_GATEWAY_ID": "your-gateway-id",
255+
"REDPANDA_API_KEY": "your-api-key"
256+
}
257+
}
258+
},
259+
"apiProviders": {
260+
"redpanda": {
261+
"baseURL": "https://gw.ai.panda.com",
262+
"headers": {
263+
"rp-aigw-id": "your-gateway-id"
264+
}
265+
}
266+
}
267+
}
268+
----
269+
270+
=== VS Code extensions
271+
272+
Configure VS Code extensions that support OpenAI-compatible APIs:
273+
274+
*Continue extension:*
275+
276+
Edit your Continue config file (`~/.continue/config.json`):
277+
278+
[source,json]
279+
----
280+
{
281+
"models": [
282+
{
283+
"title": "Redpanda AI Gateway - GPT-4",
284+
"provider": "openai",
285+
"model": "openai/gpt-4",
286+
"apiBase": "https://gw.ai.panda.com",
287+
"apiKey": "your-api-key",
288+
"requestOptions": {
289+
"headers": {
290+
"rp-aigw-id": "your-gateway-id"
291+
}
292+
}
293+
},
294+
{
295+
"title": "Redpanda AI Gateway - Claude",
296+
"provider": "anthropic",
297+
"model": "anthropic/claude-3-5-sonnet-20241022",
298+
"apiBase": "https://gw.ai.panda.com",
299+
"apiKey": "your-api-key",
300+
"requestOptions": {
301+
"headers": {
302+
"rp-aigw-id": "your-gateway-id"
303+
}
304+
}
305+
}
306+
]
307+
}
308+
----
309+
310+
=== Cursor IDE
311+
312+
Configure Cursor to route requests through the AI Gateway:
313+
314+
. Open Cursor Settings (*Cursor* → *Settings* or `Cmd+,`)
315+
. Navigate to *AI* settings
316+
. Add a custom OpenAI-compatible provider:
317+
318+
[source,json]
319+
----
320+
{
321+
"cursor.ai.providers.openai.apiBase": "https://gw.ai.panda.com",
322+
"cursor.ai.providers.openai.defaultHeaders": {
323+
"rp-aigw-id": "your-gateway-id"
324+
}
325+
}
326+
----
327+
328+
=== Custom applications
329+
330+
For custom applications using OpenAI or Anthropic SDKs:
331+
332+
*OpenAI SDK (Python):*
333+
334+
[source,python]
335+
----
336+
from openai import OpenAI
337+
338+
client = OpenAI(
339+
base_url="https://gw.ai.panda.com",
340+
api_key="your-api-key",
341+
default_headers={
342+
"rp-aigw-id": "your-gateway-id"
343+
}
344+
)
345+
----
346+
347+
*Anthropic SDK (Python):*
348+
349+
[source,python]
350+
----
351+
from anthropic import Anthropic
352+
353+
client = Anthropic(
354+
base_url="https://gw.ai.panda.com",
355+
api_key="your-api-key",
356+
default_headers={
357+
"rp-aigw-id": "your-gateway-id"
358+
}
359+
)
360+
----
361+
362+
*Node.js with OpenAI SDK:*
363+
364+
[source,javascript]
365+
----
366+
import OpenAI from 'openai';
367+
368+
const openai = new OpenAI({
369+
baseURL: 'https://gw.ai.panda.com',
370+
apiKey: process.env.OPENAI_API_KEY,
371+
defaultHeaders: {
372+
'rp-aigw-id': 'your-gateway-id'
373+
}
374+
});
375+
----

0 commit comments

Comments
 (0)