Explain it simply
Explain it simply
Some APIs simply disappear. GitHub Models used to let you call hosted models with a GitHub token. GitHub's documentation now states that, as of July 30, 2026, it has been fully retired: the playground, the model catalog, the inference API and the bring-your-own-key feature are no longer available.
GitHub Copilot is a different thing. It is an assistant that lives in editors, in the command line and on GitHub itself, and it is not a general chat endpoint that you call with curl. Think of a shop that has closed. Its address may still be on your list of suppliers, and your Copilot subscription is a membership at a different shop that sells something else.
Problem → Why → Solution
The problem: debugging a service that no longer exists
A new teammate finds a blog post with a curl command for a GitHub Models endpoint and pastes it into the project. Nothing in the code looks wrong, so when the call fails the team suspects a missing token permission or a Copilot licence problem. They spend an afternoon debugging authentication for a service that has been switched off.
The opposite mistake is just as common. Someone assumes that because the company pays for Copilot, it can be called like any other chat API, and designs a feature around that assumption. Both mistakes come from treating a product name as if it were an API contract.
// copied from a blog post written while GitHub Models was available
const res = await fetch("https://models.github.ai/inference/chat/completions", {
method: "POST",
headers: { Authorization: "Bearer " + process.env.GITHUB_TOKEN },
body: JSON.stringify({
model: "<model-id>",
messages: [{ role: "user", content: "Hello" }],
}),
});Why one adapter beats fifty call sites
A retirement is a decision made outside your code. What you control is how many places know about one provider. If the URL, the headers and the response path live in one adapter, a retirement changes one file. If they are spread across the app, it changes fifty, and you will miss some.
Core concept: what is gone, what exists, how to migrate
This lesson is mostly about a skill, not a service: reading a retirement notice calmly and rebuilding safely. The facts below come from GitHub's own documentation.
1. What the retirement notice says
GitHub's documentation says GitHub Models was fully retired on July 30, 2026, and that its playground, model catalog, inference API and bring-your-own-key features are no longer available to any customer. It points to Azure AI Foundry for model access and to GitHub Copilot for AI-powered workflows on GitHub. Older hostnames such as models.inference.ai.azure.com and models.github.ai/inference appear in many tutorials from before the retirement.
2. Copilot is a product, not a chat endpoint
GitHub's Copilot documentation lists the ways to build on top of it, and a general public chat-completions endpoint is not among them. What exists instead includes the Copilot SDK (for example @github/copilot-sdk for TypeScript), which drives Copilot through the Copilot CLI; a REST API in public preview for starting Copilot cloud agent tasks on a repository; programmatic use of the Copilot CLI; and APIs for usage metrics.
3. Choose by the job, not by the brand
If you need raw model output inside your own back end, call a model provider: Anthropic, Google, OpenAI, Hugging Face or Azure AI Foundry, as the earlier lessons show. If you want a Copilot-powered assistant inside your own tool, look at the SDK. If a script should hand a coding task to an agent, look at the cloud agent API.
4. Migrate with an inventory, a contract and an adapter
First search the code and the configuration for retired hostnames and for tokens that were created only for GitHub Models. Then write down the contract your app needs: given a prompt, return text or a clear failure. Put one adapter behind that contract for each provider and test each adapter with a mock server. The next retirement then costs you one new adapter.
| I want to | Look at | Notes |
|---|---|---|
| Complete a prompt in my back end | A model provider API | Pay per token, key on a server |
| Embed a Copilot assistant | Copilot SDK | Needs the Copilot CLI, authenticated |
| Start a coding task from a script | Cloud agent REST API | Public preview, may change |
| Report on Copilot usage | Usage metrics API | See the usage-metrics docs |
- Notice says what is gone
- Inventory finds what you still use
- Contract says what the app needs
- Adapter hides one provider's shape
The adapter is the only file that knows a provider's URL, headers and response path. Everything else talks to the contract.
General pattern
const provider = {
path: "/<endpoint-path>",
headers: () => ({ authorization: "Bearer " + process.env.PROVIDER_KEY }),
body: (prompt) => ({ /* the shape this provider documents */ }),
read: (data) => data.<path-to-the-generated-text>,
};
// The app only ever calls the contract, never a provider directly.
const { text, provider: usedProvider } = await complete(base, [provider], prompt);Each provider is one object that says where to call, how to sign the request and where the generated text lives. The app calls complete() with a chain of providers and never touches a URL itself.
A provider chain and a retired-host audit
The script first audits three sample files for retired hostnames. It then starts a stand-in server with three routes: a simulated retired host that always fails, one provider that answers in the messages shape and one that answers in the chat shape. complete() tries providers in order, skips any failure and returns the first answer. The retired host is only simulated, because nobody can promise what a switched-off service returns, so every non-2xx reply is handled the same way.
import http from "node:http";
// Stand-in server. The retired host is only simulated: we do not know what a real
// retired endpoint answers today, so the adapter must treat any failure alike.
const server = http.createServer((req, res) => {
const json = (status, body) => {
res.writeHead(status, { "content-type": "application/json" });
res.end(JSON.stringify(body));
};
req.resume();
req.on("end", () => {
if (req.url.startsWith("/retired/")) return json(404, { message: "gone" });
if (req.url === "/messages-shape/v1/messages") {
if (req.headers["x-api-key"] !== "demo-key") return json(401, { type: "error" });
const content = [{ type: "text", text: "answer in the messages shape" }];
return json(200, { content });
}
if (req.url === "/chat-shape/v1/chat/completions") {
const message = { content: "answer in the chat shape" };
return json(200, { choices: [{ message }] });
}
json(404, {});
});
});
// One adapter object per provider: where to call, how to sign, how to read the text.
const textOf = (blocks) =>
blocks.filter((b) => b.type === "text").map((b) => b.text).join("");
const providers = {
retired: {
path: "/retired/inference/chat/completions",
headers: () => ({ authorization: "Bearer old-token" }),
body: (prompt) => ({ messages: [{ role: "user", content: prompt }] }),
read: (data) => data.choices[0].message.content,
},
messagesShape: {
path: "/messages-shape/v1/messages",
headers: () => ({ "x-api-key": "demo-key" }),
body: (prompt) => ({ max_tokens: 64, messages: [{ role: "user", content: prompt }] }),
read: (data) => textOf(data.content),
},
chatShape: {
path: "/chat-shape/v1/chat/completions",
headers: () => ({ authorization: "Bearer demo-token" }),
body: (prompt) => ({ messages: [{ role: "user", content: prompt }] }),
read: (data) => data.choices[0].message.content,
},
};
// The contract: give me a prompt, get text back or a clear failure.
async function complete(base, chain, prompt) {
const skipped = [];
for (const name of chain) {
const p = providers[name];
try {
const res = await fetch(base + p.path, {
method: "POST",
headers: { "content-type": "application/json", ...p.headers() },
body: JSON.stringify(p.body(prompt)),
});
if (!res.ok) {
skipped.push(name + ": HTTP " + res.status);
continue;
}
return { provider: name, text: p.read(await res.json()), skipped };
} catch (err) {
skipped.push(name + ": " + err.message);
}
}
throw new Error("every provider failed: " + skipped.join("; "));
}
// A first inventory step: find hostnames of the retired service in your files.
const RETIRED = ["models.inference.ai.azure.com", "models.github.ai"];
function audit(files) {
const findings = [];
for (const [file, text] of Object.entries(files)) {
text.split("\n").forEach((line, i) => {
for (const host of RETIRED) {
if (line.includes(host)) findings.push(file + ":" + (i + 1) + " uses " + host);
}
});
}
return findings;
}
console.log("audit findings:");
const sampleFiles = {
"src/ai.js": 'const BASE = "https://models.github.ai/inference";\nconst ok = true;',
".env.example": "GITHUB_TOKEN=\nAI_ENDPOINT=https://models.inference.ai.azure.com\n",
"src/util.js": "export const sum = (a, b) => a + b;",
};
for (const finding of audit(sampleFiles)) console.log(" " + finding);
await new Promise((resolve) => server.listen(0, resolve));
const base = "http://127.0.0.1:" + server.address().port;
const answer = await complete(base, ["retired", "messagesShape", "chatShape"], "Hi");
console.log("answered by:", answer.provider);
console.log("skipped:", answer.skipped.join("; "));
console.log("text:", answer.text);
const second = await complete(base, ["chatShape"], "Hi");
console.log("second chain answered by:", second.provider);
try {
await complete(base, ["retired"], "Hi");
} catch (err) {
console.log("error:", err.message);
}
server.close();Code breakdown
- One object per provider
read: (data) => textOf(data.content),Each provider owns its own response path. The messages shape reads text blocks while the chat shape reads choices[0].message.content, and callers never see the difference.
- Same interface for all
const p = providers[name];complete() looks the provider up by name and uses the same four members for every one, which is the contract in action.
- Any failure is a skip
skipped.push(name + ": HTTP " + res.status);A non-2xx reply is recorded and the loop moves on. A thrown network error is recorded the same way in the catch block.
- First answer wins
return { provider: name, text: p.read(await res.json()), skipped };The result says who answered and what was skipped on the way, which is exactly what you want in a log line after a migration.
- Audit by hostname
if (line.includes(host)) findings.push(file + ":" + (i + 1) + " uses " + host);A plain string search is enough for a first inventory. It reports file and line for src/ai.js and .env.example, and says nothing about the clean file.
- Fail loudly when all fail
throw new Error("every provider failed: " + skipped.join("; "));If the whole chain fails the caller gets one error that lists every reason, instead of a silent empty string.
audit findings:
src/ai.js:1 uses models.github.ai
.env.example:2 uses models.inference.ai.azure.com
answered by: messagesShape
skipped: retired: HTTP 404
text: answer in the messages shape
second chain answered by: chatShape
error: every provider failed: retired: HTTP 404What the Copilot surfaces look like
The Copilot SDK drives Copilot through the Copilot CLI, which must be installed and authenticated; according to GitHub's quickstart the Node.js, Python and .NET SDKs bundle it. The snippet below follows the quickstart's minimal TypeScript example. It is illustrative: check the current docs, because package names and options can change.
// Illustrative - check the current docs; needs Copilot access and the Copilot CLI.
import { CopilotClient } from "@github/copilot-sdk";
const client = new CopilotClient();
const session = await client.createSession({ model: "auto" });
const response = await session.sendAndWait({ prompt: "What is 2 + 2?" });
console.log(response?.data.content);
await client.stop();The cloud agent API starts a coding task on a repository. It is in public preview and subject to change, it accepts only user-to-server tokens such as a personal access token, an OAuth app token or a GitHub App user-to-server token, and a GitHub App installation token is not supported. The reply includes the task id and a state such as queued, in_progress or completed.
# Illustrative - public preview, so check the current docs first.
# Needs a user-to-server token (for example a personal access token) in GITHUB_TOKEN.
curl -X POST https://api.github.com/agents/repos/OWNER/REPO/tasks \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "X-GitHub-Api-Version: 2022-11-28" \
-d '{"prompt": "Add a section on local setup to the README"}'Writing the contract test
A contract test is a short script that runs your adapter against a mock server. Give the mock three behaviours: a normal reply in the provider's documented shape, a failure status such as 404 or 503, and a malformed body. The adapter should return text in the first case and a clear failure in the other two. Because a retired host's behaviour is unknowable, never write a test that expects one specific status from it.
Clean up what is left behind
Revoke any token that was created only for the retired service, delete the environment variables and documentation that mention it, and remove the dead code path instead of commenting it out. A leftover credential is a risk with no benefit, and a leftover URL is a trap for the next teammate.
In real projects
How to apply it in a real project
Imagine a team with three small services that all used GitHub Models in a prototype. In the first week they run an inventory: search every repository for the retired hostnames, list the environment variables and CI secrets that mention them and note who owns each use.
They then sort the findings. Inference inside a back end moves to a model provider behind an adapter. A developer-productivity use moves to a Copilot feature that people use in their editors. A dead prototype is deleted. In the second week they write the adapter and its contract tests, revoke the old tokens and update the setup guide, so the next retirement notice is a half-day task.
Common mistakes
Common mistakes
These four mistakes keep showing up around retired or look-alike services.
Expecting a Copilot subscription to act as a chat API key
A subscription is a licence to use Copilot features, not a credential for a general inference endpoint. Use a model provider's API for raw completions and the SDK or the agent API for Copilot-specific features.
Copying a tutorial without checking its date
A tutorial can be accurate on the day it was written and wrong a year later. Check the publication date and the provider's current documentation before you build on an example.
Spreading one provider's response path through the app
If twenty files read choices[0].message.content, a provider change touches twenty files. Keep the path inside one adapter function.
Leaving old tokens and hostnames behind
Unused credentials and URLs stay in repositories for years. Revoke the tokens, delete the variables and run your audit in CI so the old host cannot return unnoticed.
Best practices
Habits worth keeping
- Subscribe to the changelog or status feed of every provider you depend on, and put retirement dates in your team calendar.
- Name the data policy, cost owner and fallback for each provider in your README, so a migration plan already exists.
- Run the endpoint audit in CI and fail the build when a retired hostname appears.
Mini challenge
Build a stricter endpoint audit
Write audit(files) for an object of { path: text }. It should report every line that contains a retired hostname, with a one-based line number, but skip comment lines that start with // or #. Print one line per finding, then a summary that says how many findings there are and in how many of the files.
- Check both models.inference.ai.azure.com and models.github.ai
- Skip lines whose first non-space characters are // or #
- Report file, one-based line number and the host that matched
- Finish with a summary of findings and affected files out of all files
// Hostnames of the retired service, as seen in tutorials written before the retirement.
const RETIRED = ["models.inference.ai.azure.com", "models.github.ai"];
function audit(files) {
// files is an object of { "path": "file text" }
// TODO 1: look at every line of every file, with 1-based line numbers
// TODO 2: skip lines whose first non-space characters are // or # (comments)
// TODO 3: when a line contains a retired host, record { file, number, host }
return [];
}
// TODO 4: build four sample files in an object: one TypeScript file with one live
// and one commented-out use, one .env with a retired host, one clean .env and
// one README that only mentions a host inside a # line
// TODO 5: print one line per finding, for example config/dev.env:1 models.github.ai
// then a summary line such as 2 findings in 2 of 4 filesExpected: Two finding lines, src/client.ts:3 models.github.ai and config/dev.env:1 models.inference.ai.azure.com, then "2 findings in 2 of 4 files". The commented-out URL and the README mention are skipped.
Show hint
A regular expression such as /^\s*(\/\/|#)/ recognises comment lines. A Set of file names gives you the number of affected files.
Show solution
// Hostnames of the retired service, as seen in tutorials written before the retirement.
const RETIRED = ["models.inference.ai.azure.com", "models.github.ai"];
function audit(files) {
const findings = [];
for (const [file, text] of Object.entries(files)) {
const lines = text.split("\n");
for (let number = 1; number <= lines.length; number++) {
const line = lines[number - 1];
if (/^\s*(\/\/|#)/.test(line)) continue; // a commented-out URL is not a live call
const host = RETIRED.find((name) => line.includes(name));
if (host) findings.push({ file, number, host });
}
}
return findings;
}
const files = {
"src/client.ts": [
"import OpenAI from 'openai';",
"// old: https://models.github.ai/inference",
"const baseURL = 'https://models.github.ai/inference';",
].join("\n"),
"config/dev.env": "AI_BASE=https://models.inference.ai.azure.com\nREGION=eu",
"config/prod.env": "AI_BASE=https://api.example.com/v1",
"README.md": "# Setup\n# do not use models.github.ai any more",
};
const findings = audit(files);
for (const { file, number, host } of findings) console.log(file + ":" + number, host);
const dirty = new Set(findings.map((f) => f.file)).size;
const total = Object.keys(files).length;
console.log(findings.length + " findings in " + dirty + " of " + total + " files");Quick quiz 1 / 3
Quick quiz 2 / 3
Quick quiz 3 / 3
What to remember
- GitHub Models was fully retired on July 30, 2026, and Copilot is a separate product, not a chat-completions replacement.
- Programmable Copilot surfaces include the Copilot SDK and the cloud agent REST API, which is in public preview and takes only user-to-server tokens.
- Migrate in order: inventory the old hostnames, define a contract, write one adapter per provider and test it with a mock server.
- Revoke tokens and delete variables that only served the retired service.
GitHub Models — Retirement Notice — GitHub