Skip to main content
kRouter
All posts
How kRouter works

Use GitHub Copilot as a native Claude endpoint with kRouter

kRouter sends Claude requests on GitHub Copilot to Copilot's Anthropic-style /v1/messages endpoint, so prompt caching works. How it works, and its limits.

Kodelyth · The team behind kRouter
· Updated
5 min read

If you or your company pays for GitHub Copilot, the plan includes model access that Claude models can draw on -- since June 1, 2026, as monthly AI Credits spent at each model's API rate. The problem is getting that Claude access out of the Copilot UI and into your own tools without losing what makes Claude worth using in an agent: prompt caching and clean tool-use blocks.

Since v0.5.114, kRouter routes Claude models on Copilot through Copilot's Anthropic-style /v1/messages endpoint instead of the generic /chat/completions path. (v0.5.114 got the response conversion backwards; v0.5.116 fixed it, so use 0.5.116 or later.)

Why the endpoint choice matters

Most integrations pipe Copilot's Claude models through /chat/completions because it is the lowest common denominator. For Claude that path is lossy:

  • It does not report prompt-cache token counts for Claude models
  • It is not the path where cache_control markers take effect
  • It accepts only text and image parts, so tool-use, tool-result and thinking blocks have to be flattened into text before they are sent

Copilot's /v1/messages endpoint takes Anthropic's own message format. It is the only Copilot endpoint that reports prompt-cache counts for Claude, and the one where caching works. kRouter routes Claude there.

How kRouter does it

The executor detects Claude models by name (/claude/i) rather than a static registry field -- deliberately, because Copilot's live catalog exposes new claude-* variants ahead of any hardcoded list. When it sees a Claude model, it takes a dedicated path that:

  • Translates the incoming request to Claude format for that endpoint (kRouter's request pipeline treats Copilot as an OpenAI-format provider, so requests arrive OpenAI-shaped)
  • Forces stream: true upstream, then buffers the stream back into one JSON reply if your client asked for non-streaming
  • Strips the internal _toolNameMap field before sending (Anthropic's schema rejects the extra field with a 400)
  • Sends the required anthropic-version header (a no-op on the other endpoints)
  • Translates the Claude event stream back for your client

GPT, Gemini and Grok models on Copilot are unchanged -- they stay on /chat/completions or /responses. Only Claude gets the native-messages treatment.

Wire your Copilot plan in as a Claude provider

npm install -g @sifxprime/krouter
krouter -t

Then in the dashboard:

  1. Go to Providers and connect GitHub Copilot. kRouter shows a risk notice first, because a Copilot login is not licensed for router use; then GitHub's device login gives you a code to enter on github.com.
  2. Point your client at http://localhost:20128/v1 (Claude Code accepts the same URL as ANTHROPIC_BASE_URL)
  3. Request a Claude model, e.g. gh/claude-sonnet-4.6

Your Claude Code, Cline or script requests now draw on the Copilot credits you already pay for. Cursor is the exception: its requests come from Cursor's servers, so it needs kRouter's tunnel rather than localhost (the Cursor fix).

curl http://localhost:20128/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gh/claude-sonnet-4.6",
    "messages": [{"role": "user", "content": "Refactor this function for readability"}]
  }'

From the same machine no key is needed; from another machine, add -H "Authorization: Bearer <your-krouter-key>" with a key from the Endpoint page.

Which Claude models you can call depends on your plan, and on Business and Enterprise also on your admin's model policy. kRouter's live model list for a Copilot connection only shows the models the account has enabled. As of October 2026, GitHub's list includes Claude Haiku 4.5, Sonnet 4.6 to 5.5 and Opus 4.8 to 5.5; Sonnet 4.5 and Opus 4.7 are gone.

The cost angle

This is not free Claude. Every request draws credits at the model's API rate, and when the month's credits are gone you buy more or stop. Copilot Pro includes 1,000 base credits plus a 500 flex allotment at the moment.

What it is: a way to spend credits you are already paying for. If your Copilot use is mostly code completions, which do not use credits, the pool goes largely unspent while you pay per token elsewhere. Working prompt caching helps here too: GitHub counts input, output and cached tokens at each model's listed rates, and on Anthropic's price list a cache read costs a fraction of normal input.

Stack it into a combo as one tier among several: a free plan first, Copilot Claude as overflow on credits you have already paid for, a cheap pay-per-token model as the safety net. If you connect more than one Copilot account, kRouter's Zenith routing engine picks the healthiest one for each request.

A note on verification

Full honesty: v0.5.114 shipped this path with tests but without a live Copilot round trip, and the response conversion turned out to be backwards -- a Copilot Claude reply would have reached the client unconverted. v0.5.116 fixed the call and pinned the correct argument order in a test. kRouter's changelog records no live end-to-end Copilot run of this path since, so the first real check is the one you make: send one request and read the reply before you build a chain on it.

Common questions

Which Copilot models use the /v1/messages endpoint?

Every model whose id contains "claude". GPT, Gemini and Grok models stay on Copilot's /chat/completions or /responses endpoints.

Does this make Claude on Copilot free?

No. Since June 1, 2026 each request spends AI Credits at the model's API rate. It lets you spend credits already included in your plan instead of paying for a second subscription or API key.

Why does my Claude model fail on Copilot when it worked before?

GitHub changes its model list. Sonnet 4.5 and Opus 4.7 are no longer on it, and on Business and Enterprise plans an admin can disable models. Fetch the live list on the Copilot provider page and use an id from there.

Get started

npm install -g @sifxprime/krouter
krouter -t
# Dashboard -> Providers -> GitHub Copilot -> device login

See /install for the full setup, /docs/combos for building your fallback stack, and using your Copilot plan in Claude Code for the cost side.

Kodelyth · The team behind kRouter

Published by Kodelyth, the team that builds kRouter. Posts are drafted with AI assistance and reviewed by a person before they go out. kRouter is free and MIT licensed.

Install kRouter