SDK v2 loads the native Copilot runtime into your application process by default, so you don't install the GitHub Copilot CLI or run a separate runtime process. Node.js and .NET include platform runtime assets; Rust bundles them with its default features. Go applications use the bundler, and Java applications add a platform runtime classifier.
The Python SDK recommends a one-time download step after installation:
python -m copilot download-runtime --in-process
This downloads the matching runtime and caches it locally. If you skip this step, the SDK will attempt to download it automatically on first use as a fallback.
Best for: Most applications—desktop apps, standalone tools, CLI utilities, prototypes, and more.
After the matching native artifacts are installed, the SDK loads the Rust runtime through its C ABI and communicates using framed JSON-RPC in memory. No separate runtime process or Node.js interpreter is needed. See In-process runtime for platform requirements, shared-process limitations, and explicit subprocess alternatives.
flowchart TB
subgraph Bundle["Your Application"]
App["Application Code"]
SDK["SDK Client"]
Runtime["Native Copilot runtime<br/>(loaded in process)"]
end
App --> SDK
SDK -- "JSON-RPC / C ABI" --> Runtime
Runtime -- "API calls" --> Copilot["☁️ GitHub Copilot"]
style Bundle fill:#0d1117,stroke:#58a6ff,color:#c9d1d9
Key characteristics:
In-process hosting is not a sandbox and provides no crash isolation. To host the runtime outside your application process instead:
RuntimeConnection.forSpawnedStdio() or RuntimeConnection.forSpawnedTcp() (TypeScript and Java names; each SDK has an equivalent), and the SDK starts the runtime as a child process. See Migrate to the v2 default and Use your own runtime binary.copilot-runtime --server yourself and attach to it over TCP with RuntimeConnection.forTcp(host, port). One runtime server can serve many SDK clients and concurrent sessions. See Backend services.note
Each SDK has a minimum language runtime requirement—see the Prerequisites section of the Node.js, Python, Go, Rust, Java, or .NET README—since an unsupported runtime (e.g. Python below the stated floor) can cause pip/package managers to silently resolve an outdated SDK release instead of reporting a version conflict.
import { CopilotClient } from "copilot-sdk-supercharged";
const client = new CopilotClient({ mode: "coding-agent" });
const session = await client.createSession({ model: "auto" });
const response = await session.sendAndWait({ prompt: "Hello!" });
console.log(response?.data.content);
await client.stop();
from copilot import CopilotClient
from copilot.session import PermissionHandler
from copilot.session_events import AssistantMessageData
client = CopilotClient(mode="coding-agent")
await client.start()
session = await client.create_session(
model="auto", permissions={"on_request": PermissionHandler.approve_all}
)
response = await session.send_and_wait("Hello!")
if response and isinstance(response.data, AssistantMessageData):
print(response.data.content)
await client.stop()
note
The Go SDK needs a native runtime package. Run the bundler tool before building, or set COPILOT_CLI_PATH to a compatible runtime package. No build tag is needed. The default does not search PATH or fall back to a subprocess.
package main
import (
"context"
"fmt"
copilot "github.com/microsoft/copilot-sdk/go/v2"
"log"
)
func main() {
ctx := context.Background()
client := copilot.NewClient(&copilot.ClientOptions{Mode: copilot.ModeCodingAgent})
if err := client.Start(ctx); err != nil {
log.Fatal(err)
}
defer client.Stop()
session, _ := client.CreateSession(ctx, &copilot.CreateSessionOptions{
Model: "auto",
})
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{
Prompt: "Hello!",
})
if d, ok := response.Data.(*copilot.AssistantMessageData); ok {
fmt.Println(d.Content)
}
}
client := copilot.NewClient(&copilot.ClientOptions{Mode: copilot.ModeCodingAgent})
if err := client.Start(ctx); err != nil {
log.Fatal(err)
}
defer client.Stop()
session, _ := client.CreateSession(ctx, &copilot.CreateSessionOptions{
Model: "auto",
})
response, _ := session.SendAndWait(ctx, copilot.MessageOptions{
Prompt: "Hello!",
})
if d, ok := response.Data.(*copilot.AssistantMessageData); ok {
fmt.Println(d.Content)
}
await using var client = new CopilotClient(new CopilotClientOptions { Mode = CopilotClientMode.CodingAgent });
await using var session = await client.CreateSessionAsync(new CreateSessionOptions
{
Model = "auto"
});
var response = await session.SendAndWaitAsync(new MessageOptions
{
Prompt = "Hello!"
});
Console.WriteLine(response?.Data.Content);
note
Add the matching platform runtime classifier alongside the Java SDK. JNA is included transitively. GraalVM native-image requires an explicit subprocess or external-server connection.
import com.microsoft.copilot.CopilotClient;
import com.microsoft.copilot.rpc.*;
var client = new CopilotClient(new CopilotClientOptions().setMode(CopilotClientMode.CODING_AGENT));
client.start().get();
var session = client.createSession(new CreateSessionOptions()
.setModel("auto")
.setPermissions(new SessionPermissionOptions().setOnRequest(PermissionHandler.APPROVE_ALL))
).get();
var response = session.sendAndWait(new MessageOptions()
.setPrompt("Hello!")).get();
System.out.println(response.getData().content());
client.stop().get();
You need to decide how your users will authenticate. Here are the common patterns:
flowchart TB
App["Bundled App"]
App --> A["User signs in<br/>(keychain credentials)"]
App --> B["App provides token<br/>(OAuth / env var)"]
App --> C["BYOK<br/>(your own API keys)"]
A --> Note1["User runs 'copilot' once<br/>to authenticate"]
B --> Note2["Your app handles login<br/>and passes token"]
C --> Note3["No GitHub auth needed<br/>Uses your model provider"]
style App fill:#0d1117,stroke:#58a6ff,color:#c9d1d9
The user signs in once (for example, by running copilot login with the GitHub Copilot CLI), and your app uses the stored credentials. No extra code needed—this is the default behavior.
import { CopilotClient } from "copilot-sdk-supercharged";
const client = new CopilotClient({ mode: "coding-agent" });
// Default: uses signed-in user credentials
Ship your app with instructions to set a token, or set it programmatically:
import { RuntimeConnection, CopilotClient } from "copilot-sdk-supercharged";
// Your application's own way of getting the user's token
declare function getUserToken(): string;
const client = new CopilotClient({
mode: "coding-agent",
github: { token: getUserToken() }, // Your app provides the token
});
If you manage your own model provider keys, users don't need GitHub accounts at all:
import { CopilotClient } from "copilot-sdk-supercharged";
const client = new CopilotClient({ mode: "coding-agent" });
const session = await client.createSession({
model: "gpt-5.4",
github: { capi: { enabled: false } },
inference: {
defaultProvider: "byok", providers: [{ name: "byok",
type: "openai",
baseUrl: "https://api.openai.com/v1",
apiKey: process.env.OPENAI_API_KEY,
}],
},
});
See the BYOK guide for full details.
Apps typically want named sessions so users can resume conversations:
import { CopilotClient } from "copilot-sdk-supercharged";
// The project the user has open in your app
declare const projectName: string;
const client = new CopilotClient({ mode: "coding-agent" });
// Create a session tied to the user's project
const sessionId = `project-${projectName}`;
const session = await client.createSession({
sessionId,
model: "auto",
});
// User closes app...
// Later, resume where they left off
const resumed = await client.resumeSession(sessionId, {});
Session state persists at ~/.copilot/session-state/{sessionId}/.
| Need | Next Guide |
|---|---|
| Users signing in with GitHub accounts | GitHub OAuth |
| Run on a server instead of user machines | Backend Services |
| Use your own model keys | BYOK |
Can you improve this documentation? These fine people already did:
copilot-cli-release-app[bot], Patrick Nikoletich, Brett Cannon, Bruno Borges, copilot-sdk-mirror-writer[bot], Steve Sanderson, Antonio Goncalves, Jeremiah Isaacson, Stephen Toub, Sunbrye Ly, Rince Yuan, Ed Burns & SanzoEdit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |