Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

feat(ai-gateway): add GitHub Copilot CLI and app setup instructions (#19462)

Tobias Wochinger8f1f7b464098
diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/ClaudeSetupTabs.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/AgentVariantTabs.tsx
similarity index 55%
rename from web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/ClaudeSetupTabs.tsx
rename to web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/AgentVariantTabs.tsx
index 200bcb2424..56920883e3 100644
--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/ClaudeSetupTabs.tsx
+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/AgentVariantTabs.tsx
@@ -2,37 +2,37 @@ import { Tabs } from "@/src/components/design-system/Tabs/Tabs";
import type { AgentSetupInstructions } from "@/src/features/ai-gateway/types/agentSetupInstructions";
import { AgentInstructionsPanel } from "./AgentInstructionsPanel";
-const CLAUDE_VARIANTS: { id: ClaudeAgentId; label: string }[] = [
- { id: "claude-code", label: "Code" },
- { id: "claude-desktop", label: "Desktop" },
-];
+type AgentId = AgentSetupInstructions["id"];
-function isClaudeAgentId(value: string): value is ClaudeAgentId {
- return CLAUDE_VARIANTS.some((variant) => variant.id === value);
-}
+export type AgentVariant = { id: AgentId; label: string };
-type ClaudeSetupTabsProps = {
+type AgentVariantTabsProps = {
organizationId: string;
instructions: AgentSetupInstructions[];
- value: ClaudeAgentId;
- onValueChange: (value: ClaudeAgentId) => void;
+ variants: AgentVariant[];
+ ariaLabel: string;
+ value: AgentId;
+ onValueChange: (value: AgentId) => void;
};
-/** Claude Code and Claude Desktop share one tab, with a switch between them. */
-export function ClaudeSetupTabs({
+/** Variants of one tool, e.g. Claude Code and Claude Desktop, share one tab with a switch between them. */
+export function AgentVariantTabs({
organizationId,
instructions,
+ variants,
+ ariaLabel,
value,
onValueChange,
-}: ClaudeSetupTabsProps) {
+}: AgentVariantTabsProps) {
const handleValueChange = (next: string) => {
- if (isClaudeAgentId(next)) onValueChange(next);
+ const variant = variants.find((v) => v.id === next);
+ if (variant) onValueChange(variant.id);
};
return (
<Tabs value={value} onValueChange={handleValueChange}>
- <Tabs.List variant="inset" size="sm" aria-label="Claude app">
- {CLAUDE_VARIANTS.map((variant) => (
+ <Tabs.List variant="inset" size="sm" aria-label={ariaLabel}>
+ {variants.map((variant) => (
<Tabs.Trigger
key={variant.id}
value={variant.id}
@@ -40,7 +40,7 @@ export function ClaudeSetupTabs({
/>
))}
</Tabs.List>
- {CLAUDE_VARIANTS.map((variant) => {
+ {variants.map((variant) => {
const entry = instructions.find((e) => e.id === variant.id);
return entry ? (
<Tabs.Content key={variant.id} value={variant.id}>
@@ -56,8 +56,3 @@ export function ClaudeSetupTabs({
</Tabs>
);
}
-
-export type ClaudeAgentId = Extract<
- AgentSetupInstructions["id"],
- "claude-code" | "claude-desktop"
->;
diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.tsx b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.tsx
index 4de312bd13..ed4d2177d6 100644
--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.tsx
+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/SetupInstructionsTabs/SetupInstructionsTabs.tsx
@@ -1,17 +1,44 @@
import { useState } from "react";
import { Braces, SquareTerminal, type IconComponent } from "@langfuse/icons";
-import { SiClaude, SiOpenai } from "@langfuse/icons/si";
+import { SiClaude, SiGithubcopilot, SiOpenai } from "@langfuse/icons/si";
import { Button } from "@/src/components/design-system/Button/Button";
import { Tabs } from "@/src/components/design-system/Tabs/Tabs";
import type { AgentSetupInstructions } from "@/src/features/ai-gateway/types/agentSetupInstructions";
import { AgentInstructionsPanel } from "@/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/AgentInstructionsPanel";
import {
- ClaudeSetupTabs,
- type ClaudeAgentId,
-} from "@/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/ClaudeSetupTabs";
+ AgentVariantTabs,
+ type AgentVariant,
+} from "@/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/components/AgentVariantTabs";
-type TabId = Exclude<AgentSetupInstructions["id"], ClaudeAgentId> | "claude";
+type AgentId = AgentSetupInstructions["id"];
+type VariantTabId = "claude" | "copilot";
+type TabId =
+ | Exclude<
+ AgentId,
+ "claude-code" | "claude-desktop" | "copilot-cli" | "copilot-desktop"
+ >
+ | VariantTabId;
+
+const VARIANT_TABS: Record<
+ VariantTabId,
+ { ariaLabel: string; variants: AgentVariant[] }
+> = {
+ claude: {
+ ariaLabel: "Claude app",
+ variants: [
+ { id: "claude-code", label: "Code" },
+ { id: "claude-desktop", label: "Desktop" },
+ ],
+ },
+ copilot: {
+ ariaLabel: "GitHub Copilot app",
+ variants: [
+ { id: "copilot-cli", label: "CLI" },
+ { id: "copilot-desktop", label: "Desktop" },
+ ],
+ },
+};
const DEFAULT_TAB: TabId = "api";
@@ -20,8 +47,13 @@ const TABS: { id: TabId; label: string; icon: IconComponent }[] = [
{ id: "claude", label: "Claude", icon: SiClaude },
{ id: "codex", label: "Codex", icon: SiOpenai },
{ id: "opencode", label: "OpenCode", icon: SquareTerminal },
+ { id: "copilot", label: "GitHub Copilot", icon: SiGithubcopilot },
];
+function isVariantTabId(value: string): value is VariantTabId {
+ return value in VARIANT_TABS;
+}
+
type SetupInstructionsTabsProps = {
organizationId: string;
instructions: AgentSetupInstructions[];
@@ -32,14 +64,16 @@ export function SetupInstructionsTabs({
instructions,
}: SetupInstructionsTabsProps) {
const [activeTab, setActiveTab] = useState<string>(DEFAULT_TAB);
- const [claudeVariant, setClaudeVariant] =
- useState<ClaudeAgentId>("claude-code");
+ const [activeVariants, setActiveVariants] = useState<
+ Record<VariantTabId, AgentId>
+ >({ claude: "claude-code", copilot: "copilot-cli" });
const findEntry = (id: string) =>
instructions.find((entry) => entry.id === id);
const activeEntry =
- findEntry(activeTab === "claude" ? claudeVariant : activeTab) ??
- instructions[0];
+ findEntry(
+ isVariantTabId(activeTab) ? activeVariants[activeTab] : activeTab,
+ ) ?? instructions[0];
return (
<div className="flex flex-col gap-2">
@@ -79,15 +113,22 @@ export function SetupInstructionsTabs({
</Tabs.List>
</div>
{TABS.map((tab) => {
- if (tab.id === "claude") {
+ if (isVariantTabId(tab.id)) {
+ const variantTabId = tab.id;
return (
<Tabs.Content key={tab.id} value={tab.id}>
<div className="pt-4">
- <ClaudeSetupTabs
+ <AgentVariantTabs
organizationId={organizationId}
instructions={instructions}
- value={claudeVariant}
- onValueChange={setClaudeVariant}
+ {...VARIANT_TABS[variantTabId]}
+ value={activeVariants[variantTabId]}
+ onValueChange={(next) =>
+ setActiveVariants((current) => ({
+ ...current,
+ [variantTabId]: next,
+ }))
+ }
/>
</div>
</Tabs.Content>
diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/AGENTS.md b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/AGENTS.md
index 66f23ebf65..be6905f1aa 100644
--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/AGENTS.md
+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/AGENTS.md
@@ -10,6 +10,10 @@ The Langfuse docs own this content. These builders are a condensed copy:
- Claude Code: https://langfuse.com/docs/ai-gateway/coding-agents/claude-code
- Codex: https://langfuse.com/docs/ai-gateway/coding-agents/codex
- OpenCode: https://langfuse.com/docs/ai-gateway/coding-agents/opencode
+- Copilot CLI (no Langfuse page yet, follows GitHub's docs):
+ https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models
+- GitHub Copilot app (no Langfuse page yet, follows GitHub's docs):
+ https://docs.github.com/en/copilot/how-tos/github-copilot-app/add-llm-models
Change the docs first (`langfuse/langfuse-docs`), then mirror the change here.
Do not add steps, paths or env vars that the docs do not describe.
diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/__tests__/agentSetupInstructions.clienttest.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/__tests__/agentSetupInstructions.clienttest.ts
index 6fc48b4257..f667fef47e 100644
--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/__tests__/agentSetupInstructions.clienttest.ts
+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/__tests__/agentSetupInstructions.clienttest.ts
@@ -41,8 +41,12 @@ describe("agent setup instructions", () => {
it("puts the key placeholder into the commands of every terminal setup", () => {
for (const instructions of buildAgentSetupInstructions(context)) {
- // Claude Desktop takes the key in a settings field, not a command.
- if (instructions.id === "claude-desktop") continue;
+ // Desktop apps take the key in a settings field, not a command.
+ if (
+ instructions.id === "claude-desktop" ||
+ instructions.id === "copilot-desktop"
+ )
+ continue;
const code = instructions.steps.flatMap((s) => s.code ?? []).join("\n");
expect(code).toContain(GATEWAY_KEY_PLACEHOLDER);
@@ -55,8 +59,8 @@ describe("agent setup instructions", () => {
expect(markdown).toMatch(/^# /);
expect(markdown).not.toContain("undefined");
- expect(markdown.trimEnd()).toMatch(
- new RegExp(`Docs: ${instructions.docsUrl}$`),
+ expect(markdown.trimEnd().endsWith(`Docs: ${instructions.docsUrl}`)).toBe(
+ true,
);
}
});
diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildAgentSetupInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildAgentSetupInstructions.ts
index cd031d5644..f4b1d0a54f 100644
--- a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildAgentSetupInstructions.ts
+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildAgentSetupInstructions.ts
@@ -3,6 +3,8 @@ import { buildApiInstructions } from "./buildApiInstructions";
import { buildClaudeCodeInstructions } from "./buildClaudeCodeInstructions";
import { buildClaudeDesktopInstructions } from "./buildClaudeDesktopInstructions";
import { buildCodexInstructions } from "./buildCodexInstructions";
+import { buildCopilotCliInstructions } from "./buildCopilotCliInstructions";
+import { buildCopilotDesktopInstructions } from "./buildCopilotDesktopInstructions";
import { buildOpenCodeInstructions } from "./buildOpenCodeInstructions";
/** One entry per tool in the "Gateway key created" dialog. */
@@ -13,5 +15,7 @@ export function buildAgentSetupInstructions(context: AgentSetupContext) {
buildClaudeDesktopInstructions(context),
buildCodexInstructions(context),
buildOpenCodeInstructions(context),
+ buildCopilotCliInstructions(context),
+ buildCopilotDesktopInstructions(context),
];
}
diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotCliInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotCliInstructions.ts
new file mode 100644
index 0000000000..fb88390aae
--- /dev/null
+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotCliInstructions.ts
@@ -0,0 +1,69 @@
+import {
+ AGENT_SETUP_DOCS_URLS,
+ GATEWAY_KEY_PLACEHOLDER,
+} from "@/src/features/ai-gateway/constants/agentSetupInstructions";
+import type {
+ AgentSetupContext,
+ AgentSetupInstructions,
+} from "@/src/features/ai-gateway/types/agentSetupInstructions";
+import type { GatewayProvider } from "@/src/features/ai-gateway/types/gatewayProvider";
+
+/** The Anthropic provider type appends `/v1/messages` itself, so its base URL omits `/v1`. */
+const COPILOT_PROVIDERS: Record<
+ GatewayProvider,
+ { path: string; env: string[] }
+> = {
+ ANTHROPIC: {
+ path: "/anthropic",
+ env: ['export COPILOT_PROVIDER_TYPE="anthropic"'],
+ },
+ OPENAI: {
+ path: "/openai/v1",
+ env: [
+ 'export COPILOT_PROVIDER_TYPE="openai"',
+ 'export COPILOT_PROVIDER_WIRE_API="responses"',
+ ],
+ },
+};
+
+export function buildCopilotCliInstructions(
+ context: AgentSetupContext,
+): AgentSetupInstructions {
+ const provider: GatewayProvider = context.providers.includes("ANTHROPIC")
+ ? "ANTHROPIC"
+ : "OPENAI";
+ const { path, env } = COPILOT_PROVIDERS[provider];
+
+ return {
+ id: "copilot-cli",
+ label: "GitHub Copilot CLI",
+ heading: "Route GitHub Copilot CLI through the Langfuse AI Gateway",
+ summary:
+ "Use the gateway as Copilot CLI's model provider so every model call is recorded in Langfuse.",
+ docsUrl: AGENT_SETUP_DOCS_URLS["copilot-cli"],
+ warning:
+ context.providers.length === 0
+ ? "Copilot CLI needs an Anthropic or OpenAI provider connection, and none is enabled yet."
+ : undefined,
+ steps: [
+ {
+ title: "Point Copilot CLI at the gateway",
+ description:
+ "Replace the placeholders with your gateway key and a model from your provider connection. If ~/.copilot/providers.json lists providers, it takes precedence over these variables.",
+ language: "sh",
+ code: [
+ ...env,
+ `export COPILOT_PROVIDER_BASE_URL="${context.gatewayOrigin}${path}"`,
+ `export COPILOT_PROVIDER_API_KEY="${GATEWAY_KEY_PLACEHOLDER}"`,
+ 'export COPILOT_MODEL="<model>"',
+ ].join("\n"),
+ },
+ {
+ title: "Start Copilot CLI",
+ description: "Each model call appears in Langfuse as a trace.",
+ language: "sh",
+ code: "copilot",
+ },
+ ],
+ };
+}
diff --git a/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotDesktopInstructions.ts b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotDesktopInstructions.ts
new file mode 100644
index 0000000000..27d623b0e8
--- /dev/null
+++ b/web/src/features/ai-gateway/components/GatewayApiKeysPage/components/GeneratedKeyContent/fns/agentSetupInstructions/buildCopilotDesktopInstructions.ts
@@ -0,0 +1,44 @@
+import { AGENT_SETUP_DOCS_URLS } from "@/src/features/ai-gateway/constants/agentSetupInstructions";
+import type {
+ AgentSetupContext,
+ AgentSetupInstructions,
+} from "@/src/features/ai-gateway/types/agentSetupInstructions";
+
+export function buildCopilotDesktopInstructions(
+ context: AgentSetupContext,
+): AgentSetupInstructions {
+ return {
+ id: "copilot-desktop",
+ label: "GitHub Copilot app",
+ heading: "Route the GitHub Copilot app through the Langfuse AI Gateway",
+ summary:
+ "Add the gateway as a custom model provider in the GitHub Copilot app so every model call is recorded in Langfuse.",
+ docsUrl: AGENT_SETUP_DOCS_URLS["copilot-desktop"],
+ warning: context.providers.includes("OPENAI")
+ ? undefined
+ : "The GitHub Copilot app needs an OpenAI provider connection, and none is enabled yet.",
+ steps: [
+ {
+ title: "Add a custom endpoint",
+ description:
+ "Open Settings → Model providers, select Add provider, then choose Custom endpoint. Set Display name to Langfuse.",
+ },
+ {
+ title: "Set the gateway base URL",
+ description: "Paste this URL exactly as shown.",
+ language: "text",
+ code: `${context.gatewayOrigin}/openai/v1`,
+ },
+ {
+ title: "Choose the wire API and add your gateway key",
+ description:
+ "Set Wire API to responses, paste your gateway key as API key, leave Custom headers empty, then select Add provider.",
+ },
+ {
+ title: "Pick a model",
+ description:
+ "The models of your OpenAI provider connection appear in the model picker alongside the GitHub-hosted models. Select one to start a session.",
+ },
+ ],
+ };
+}
diff --git a/web/src/features/ai-gateway/constants/agentSetupInstructions.ts b/web/src/features/ai-gateway/constants/agentSetupInstructions.ts
index e368d2d19d..991d2ea5e7 100644
--- a/web/src/features/ai-gateway/constants/agentSetupInstructions.ts
+++ b/web/src/features/ai-gateway/constants/agentSetupInstructions.ts
@@ -8,4 +8,8 @@ export const AGENT_SETUP_DOCS_URLS = {
"claude-code": `${GATEWAY_DOCS_URL}/coding-agents/claude-code#claude-code-cli`,
codex: `${GATEWAY_DOCS_URL}/coding-agents/codex`,
opencode: `${GATEWAY_DOCS_URL}/coding-agents/opencode`,
+ "copilot-cli":
+ "https://docs.github.com/en/copilot/how-tos/copilot-cli/customize-copilot/use-byok-models",
+ "copilot-desktop":
+ "https://docs.github.com/en/copilot/how-tos/github-copilot-app/add-llm-models",
} as const;
diff --git a/web/src/features/ai-gateway/types/agentSetupInstructions.ts b/web/src/features/ai-gateway/types/agentSetupInstructions.ts
index 2e93bcf4cc..c0848b23dd 100644
--- a/web/src/features/ai-gateway/types/agentSetupInstructions.ts
+++ b/web/src/features/ai-gateway/types/agentSetupInstructions.ts
@@ -20,7 +20,14 @@ export type AgentSetupStep = {
);
export type AgentSetupInstructions = {
- id: "api" | "claude-desktop" | "claude-code" | "codex" | "opencode";
+ id:
+ | "api"
+ | "claude-desktop"
+ | "claude-code"
+ | "codex"
+ | "opencode"
+ | "copilot-cli"
+ | "copilot-desktop";
label: string;
/** First line of the "Copy for agent" Markdown. */
heading: string;