GitHub Copilot with the Langfuse AI Gateway
Beta. The Langfuse AI Gateway is in public beta and can still change.
Both Copilot surfaces support bring-your-own-key (BYOK) model providers. Only those models go through the gateway. GitHub-hosted models in the same picker are not traced.
For tracing GitHub Copilot without the gateway, see the GitHub Copilot integration.
- Copilot CLI:
ANTHROPICorOPENAIprovider credential. - GitHub Copilot app:
OPENAIprovider credential. BYOK in the app is in public preview.
Copilot CLI
Create a gateway API key
Create a gateway API key under Organization settings → AI Gateway → Gateway keys. See API keys.
Point Copilot CLI at the gateway
Copilot CLI reads its BYOK provider from environment variables. See GitHub's BYOK guide.
export COPILOT_PROVIDER_BASE_URL="https://gateway.cloud.langfuse.com/anthropic"
export COPILOT_PROVIDER_TYPE="anthropic"
export COPILOT_PROVIDER_API_KEY="<your-gateway-key>"
export COPILOT_MODEL="<model-id>" # an Anthropic model ID from /models
copilotexport COPILOT_PROVIDER_BASE_URL="https://gateway.cloud.langfuse.com/openai/v1"
export COPILOT_PROVIDER_TYPE="openai"
export COPILOT_PROVIDER_WIRE_API="responses"
export COPILOT_PROVIDER_API_KEY="<your-gateway-key>"
export COPILOT_MODEL="<model-id>" # an OpenAI model ID from /models
copilotTo keep the setup across sessions, add the export lines to ~/.zshrc.
- The Anthropic base URL has no
/v1. The OpenAI base URL includes/v1. - Set
COPILOT_PROVIDER_WIRE_API="responses"on the OpenAI route. Copilot defaults tocompletions(Chat Completions), which has not been verified with Copilot. - If
~/.copilot/providers.json(or the file inCOPILOT_PROVIDERS_CONFIG) already lists providers or models, it takes precedence and these variables have no effect. - Copilot CLI cannot send custom headers to a BYOK provider, so request headers such as
langfuse-tagscannot be set. Use key metadata instead.
Verify
Send a prompt in copilot. If Copilot replies, it runs through the gateway.
GitHub Copilot app
Create a gateway API key
Create a gateway API key under Organization settings → AI Gateway → Gateway keys. See API keys.
Add the gateway as a model provider
See GitHub's guide to adding models to the Copilot app.
-
Open Settings → Model providers, select Add provider, then choose Custom endpoint.
-
Set Display name to
Langfuse. -
Set Base URL to
https://gateway.cloud.langfuse.com/openai/v1. -
Set Wire API to
responses. Withcompletions, requests to OpenAI's GPT-5 models fail. -
Paste your gateway key as API key. The app stores it in your OS keychain.
-
Optional: add request headers under Custom headers, for example:
{ "langfuse-tags": "github-copilot,<team>" } -
Select Add provider. The models of your
OPENAIprovider credential appear in the model picker alongside the GitHub-hosted models. Select one to start a session.
Verify
Select a gateway model and send a prompt. If Copilot replies, it runs through the gateway.
Troubleshooting and FAQ
Why does every call have its own trace without a session?
The gateway does not infer a session or turn from Copilot requests. In the app, set langfuse-session-id under Custom headers to group calls into one session.
Can the Copilot app use the Anthropic route?
No. The Anthropic route is CLI only. The app's custom endpoint speaks the OpenAI API only.
Last updated on