-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.html
More file actions
642 lines (602 loc) · 27.4 KB
/
setup.html
File metadata and controls
642 lines (602 loc) · 27.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
<!DOCTYPE html>
<!--
| Generated by Apache Maven Doxia Site Renderer 2.0.0 from target/filtered-site/markdown/setup.md at 2026-03-26
| Rendered using Apache Maven Fluido Skin 2.1.0
-->
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="generator" content="Apache Maven Doxia Site Renderer 2.0.0" />
<title>Setup & Deployment Guide – GitHub Copilot SDK :: Java</title>
<link rel="stylesheet" href="./css/apache-maven-fluido-2.1.0.min.css" />
<link rel="stylesheet" href="./css/site.css" />
<link rel="stylesheet" href="./css/print.css" media="print" />
<script src="./js/apache-maven-fluido-2.1.0.min.js"></script>
<style>.github-fork-ribbon:before { background-color: gray; }</style>
</head>
<body class="topBarEnabled">
<a class="github-fork-ribbon right-top" href="https://github.com/github/copilot-sdk-java" data-ribbon="Fork me on GitHub">Fork me on GitHub</a>
<header id="topbar" class="navbar navbar-fixed-top ">
<div class="navbar-inner">
<div class="container-fluid">
<a data-target=".nav-collapse" data-toggle="collapse" class="btn btn-navbar">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="index.html">GitHub Copilot SDK for Java
</a>
<ul class="nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Overview <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="index.html">Introduction</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<li><a>Setup</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="mcp.html">MCP Servers</a></li>
<li><a href="hooks.html">Session Hooks</a></li>
<li><a href="advanced.html">Advanced Usage</a></li>
<li><a href="apidocs/index.html">API Javadoc</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Guides <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="documentation.html#Basic_Usage">Basic Usage</a></li>
<li><a href="documentation.html#Handling_Responses">Handling Responses</a></li>
<li><a href="documentation.html#Streaming_Responses">Streaming</a></li>
<li><a href="documentation.html#Choosing_a_Model">Choosing a Model</a></li>
<li><a href="documentation.html#Session_Management">Session Management</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Advanced <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="advanced.html#Custom_Tools">Custom Tools</a></li>
<li><a href="advanced.html#System_Messages">System Messages</a></li>
<li><a href="advanced.html#File_Attachments">File Attachments</a></li>
<li><a href="advanced.html#Bring_Your_Own_Key_.28BYOK.29">BYOK</a></li>
<li><a href="advanced.html#Infinite_Sessions">Infinite Sessions</a></li>
<li><a href="advanced.html#MCP_Servers">MCP Servers</a></li>
<li><a href="hooks.html">Session Hooks</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Cookbook <b class="caret"></b></a>
<ul class="dropdown-menu">
<li><a href="cookbook/README.html">Overview</a></li>
<li><a href="cookbook/error-handling.html">Error Handling</a></li>
<li><a href="cookbook/multiple-sessions.html">Multiple Sessions</a></li>
<li><a href="cookbook/managing-local-files.html">Managing Local Files</a></li>
<li><a href="cookbook/pr-visualization.html">PR Visualization</a></li>
<li><a href="cookbook/persisting-sessions.html">Persisting Sessions</a></li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown">Project Documentation <b class="caret"></b></a>
<ul class="dropdown-menu">
<li class="dropdown-submenu">
<a href="project-info.html">Project Information</a>
<ul class="dropdown-menu">
<li><a href="dependencies.html">Dependencies</a></li>
<li><a href="dependency-info.html">Maven Coordinates</a></li>
<li><a href="distribution-management.html">Distribution Management</a></li>
<li><a href="index.html">About</a></li>
<li><a href="licenses.html">Licenses</a></li>
<li><a href="plugin-management.html">Plugin Management</a></li>
<li><a href="plugins.html">Plugins</a></li>
<li><a href="scm.html">Source Code Management</a></li>
<li><a href="summary.html">Summary</a></li>
<li><a href="team.html">Team</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="project-reports.html">Project Reports</a>
<ul class="dropdown-menu">
<li><a href="apidocs/index.html">Javadoc</a></li>
<li><a href="surefire.html">Surefire</a></li>
<li><a href="spotbugs.html">SpotBugs</a></li>
<li><a href="taglist.html">Tag List</a></li>
<li><a href="dependency-analysis.html">Dependency Analysis</a></li>
</ul>
</li>
</ul>
</li>
</ul>
</div>
</div>
</header>
<div class="container-fluid container-fluid-top">
<header>
<div id="banner">
<div class="pull-left"></div>
<div class="pull-right"></div>
<div class="clear"><hr/></div>
</div>
<div id="breadcrumbs">
<ul class="breadcrumb">
<li id="publishDate">Last Published: 2026-03-26<span class="divider">|</span>
</li>
<li id="projectVersion">Version: 0.2.1-java.0<span class="divider">|</span></li>
<li><a href="index.html">Home</a><span class="divider">/</span></li>
<li class="active">Setup & Deployment Guide</li>
</ul>
</div>
</header>
<div class="row-fluid">
<header id="leftColumn" class="span2">
<nav class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Overview</li>
<li><a href="index.html">Introduction</a></li>
<li><a href="getting-started.html">Getting Started</a></li>
<li class="active"><a>Setup</a></li>
<li><a href="documentation.html">Documentation</a></li>
<li><a href="mcp.html">MCP Servers</a></li>
<li><a href="hooks.html">Session Hooks</a></li>
<li><a href="advanced.html">Advanced Usage</a></li>
<li><a href="apidocs/index.html">API Javadoc</a></li>
<li class="nav-header">Guides</li>
<li><a href="documentation.html#Basic_Usage">Basic Usage</a></li>
<li><a href="documentation.html#Handling_Responses">Handling Responses</a></li>
<li><a href="documentation.html#Streaming_Responses">Streaming</a></li>
<li><a href="documentation.html#Choosing_a_Model">Choosing a Model</a></li>
<li><a href="documentation.html#Session_Management">Session Management</a></li>
<li class="nav-header">Advanced</li>
<li><a href="advanced.html#Custom_Tools">Custom Tools</a></li>
<li><a href="advanced.html#System_Messages">System Messages</a></li>
<li><a href="advanced.html#File_Attachments">File Attachments</a></li>
<li><a href="advanced.html#Bring_Your_Own_Key_.28BYOK.29">BYOK</a></li>
<li><a href="advanced.html#Infinite_Sessions">Infinite Sessions</a></li>
<li><a href="advanced.html#MCP_Servers">MCP Servers</a></li>
<li><a href="hooks.html">Session Hooks</a></li>
<li class="nav-header">Cookbook</li>
<li><a href="cookbook/README.html">Overview</a></li>
<li><a href="cookbook/error-handling.html">Error Handling</a></li>
<li><a href="cookbook/multiple-sessions.html">Multiple Sessions</a></li>
<li><a href="cookbook/managing-local-files.html">Managing Local Files</a></li>
<li><a href="cookbook/pr-visualization.html">PR Visualization</a></li>
<li><a href="cookbook/persisting-sessions.html">Persisting Sessions</a></li>
<li class="nav-header">Project Documentation</li>
<li><a href="project-info.html"><span class="icon-chevron-right"></span>Project Information</a></li>
<li><a href="project-reports.html"><span class="icon-chevron-right"></span>Project Reports</a></li>
</ul>
</nav>
<div class="well sidebar-nav">
<div id="poweredBy">
<div class="clear"></div>
<div class="clear"></div>
<a href="https://maven.apache.org/" class="builtBy" target="_blank"><img class="builtBy" alt="Built by Maven" src="./images/logos/maven-feather.png" /></a>
</div>
</div>
</header>
<main id="bodyColumn" class="span10">
<section><a id="Setup_.26_Deployment_Guide"></a>
<h1>Setup & Deployment Guide</h1>
<p>This guide explains how to configure the Copilot SDK for different deployment scenarios — from local development to production multi-user applications.</p><section><a id="Quick_Reference"></a>
<h2>Quick Reference</h2>
<table class="table table-striped">
<thead>
<tr class="a">
<th>Scenario</th>
<th>Configuration</th>
<th>Guide Section</th></tr></thead><tbody>
<tr class="b">
<td>Local development</td>
<td>Default (no options)</td>
<td><a href="#local-cli">Local CLI</a></td></tr>
<tr class="a">
<td>Multi-user app</td>
<td><code>setGitHubToken(userToken)</code></td>
<td><a href="#github-oauth-authentication">GitHub OAuth</a></td></tr>
<tr class="b">
<td>Server deployment</td>
<td><code>setCliUrl("host:port")</code></td>
<td><a href="#backend-services">Backend Services</a></td></tr>
<tr class="a">
<td>Custom CLI location</td>
<td><code>setCliPath("/path/to/copilot")</code></td>
<td><a href="#bundled-cli">Bundled CLI</a></td></tr>
<tr class="b">
<td>Own model keys</td>
<td>Provider configuration</td>
<td><a href="advanced.html#Bring_Your_Own_Key_BYOK">BYOK</a></td></tr></tbody>
</table>
</section><section><a id="Local_CLI"></a>
<h2>Local CLI</h2>
<p>The simplest setup uses the Copilot CLI already signed in on your development machine.</p>
<p><strong>Use when:</strong> Building personal projects, prototyping, or learning the SDK.</p>
<pre class="prettyprint"><code class="language-java">try (var client = new CopilotClient()) {
client.start().get();
var session = client.createSession(
new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL).setModel("gpt-4.1")
).get();
// Use session...
}
</code></pre>
<p><strong>How it works:</strong> The SDK automatically spawns the CLI process and uses credentials from your system keychain.</p>
<p><strong>Requirements:</strong></p>
<ul>
<li>Copilot CLI installed and signed in (<code>copilot auth login</code>)</li>
<li>Active Copilot subscription</li>
</ul>
<p>See <a href="getting-started.html">Getting Started</a> for a complete tutorial.</p></section><section><a id="GitHub_OAuth_Authentication"></a>
<h2>GitHub OAuth Authentication</h2>
<p>For multi-user applications where users authenticate with their GitHub accounts.</p>
<p><strong>Use when:</strong> Building apps where users have GitHub accounts and Copilot subscriptions.</p><section><a id="Basic_Setup"></a>
<h3>Basic Setup</h3>
<p>After obtaining a user's GitHub OAuth token, pass it to the SDK:</p>
<pre class="prettyprint"><code class="language-java">var options = new CopilotClientOptions()
.setGitHubToken(userAccessToken)
.setUseLoggedInUser(false);
try (var client = new CopilotClient(options)) {
client.start().get();
var session = client.createSession(
new SessionConfig().setOnPermissionRequest(PermissionHandler.APPROVE_ALL).setModel("gpt-4.1")
).get();
// Requests are made on behalf of the authenticated user
}
</code></pre></section><section><a id="OAuth_Flow_Integration"></a>
<h3>OAuth Flow Integration</h3>
<p>Your application handles the OAuth flow:</p>
<ol style="list-style-type: decimal;">
<li>Create a GitHub OAuth App in your GitHub settings</li>
<li>Redirect users to GitHub's authorization URL</li>
<li>Exchange the authorization code for an access token</li>
<li>Pass the token to <code>CopilotClientOptions.setGitHubToken()</code></li>
</ol></section><section><a id="Per-User_Client_Management"></a>
<h3>Per-User Client Management</h3>
<p>Each authenticated user should get their own client instance:</p>
<pre class="prettyprint"><code class="language-java">private final Map<String, CopilotClient> clients = new ConcurrentHashMap<>();
public CopilotClient getClientForUser(String userId, String gitHubToken) {
return clients.computeIfAbsent(userId, id -> {
var options = new CopilotClientOptions()
.setGitHubToken(gitHubToken)
.setUseLoggedInUser(false);
var client = new CopilotClient(options);
try {
client.start().get();
} catch (Exception e) {
throw new RuntimeException("Failed to start client for user: " + userId, e);
}
return client;
});
}
</code></pre></section><section><a id="Token_Types"></a>
<h3>Token Types</h3>
<table class="table table-striped">
<thead>
<tr class="a">
<th>Token Prefix</th>
<th>Description</th>
<th>Supported</th></tr></thead><tbody>
<tr class="b">
<td><code>gho_</code></td>
<td>OAuth user access token</td>
<td>✅</td></tr>
<tr class="a">
<td><code>ghu_</code></td>
<td>GitHub App user access token</td>
<td>✅</td></tr>
<tr class="b">
<td><code>github_pat_</code></td>
<td>Fine-grained personal access token</td>
<td>✅</td></tr></tbody>
</table>
<p><strong>Note:</strong> Token lifecycle management (storage, refresh, expiration) is your application's responsibility.</p></section></section><section><a id="Backend_Services"></a>
<h2>Backend Services</h2>
<p>Run the SDK in server-side applications by connecting to an external CLI server.</p>
<p><strong>Use when:</strong> Building web backends, APIs, microservices, or any server-side workload.</p><section><a id="Architecture"></a>
<h3>Architecture</h3>
<p>Instead of spawning a CLI process, your application connects to a separately-running CLI server:</p>
<pre><code class="nohighlight nocode">┌─────────────────┐ ┌─────────────────┐
│ Your Backend │ │ CLI Server │
│ │ │ (headless) │
│ ┌───────────┐ │ │ ┌───────────┐ │
│ │ SDK ├──┼──────►│ │JSON-RPC │ │
│ └───────────┘ │ TCP │ │:4321 │ │
└─────────────────┘ │ └───────────┘ │
└─────────────────┘
</code></pre></section><section><a id="Start_the_CLI_Server"></a>
<h3>Start the CLI Server</h3>
<p>Run the CLI in headless server mode:</p>
<pre class="prettyprint"><code class="language-bash">copilot server --port 4321
</code></pre>
<p>Or with authentication:</p>
<pre class="prettyprint"><code class="language-bash">export GITHUB_TOKEN=your_token
copilot server --port 4321
</code></pre></section><section><a id="Connect_from_Your_Application"></a>
<h3>Connect from Your Application</h3>
<p>Configure the SDK to connect to the external server:</p>
<pre class="prettyprint"><code class="language-java">var options = new CopilotClientOptions()
.setCliUrl("localhost:4321");
try (var client = new CopilotClient(options)) {
client.start().get();
// Client connects to the external server
}
</code></pre></section><section><a id="Multiple_SDK_Clients.2C_One_Server"></a>
<h3>Multiple SDK Clients, One Server</h3>
<p>Multiple application instances can share a single CLI server:</p>
<pre class="prettyprint"><code class="language-java">// In different parts of your application or different containers
var client1 = new CopilotClient(new CopilotClientOptions().setCliUrl("cli-server:4321"));
var client2 = new CopilotClient(new CopilotClientOptions().setCliUrl("cli-server:4321"));
// Both connect to the same CLI server
</code></pre></section><section><a id="Deployment_Patterns"></a>
<h3>Deployment Patterns</h3>
<p><strong>Container deployment:</strong></p>
<pre class="prettyprint"><code class="language-yaml"># docker-compose.yml
services:
cli-server:
image: copilot-cli:latest
command: copilot server --port 4321
environment:
- GITHUB_TOKEN=${GITHUB_TOKEN}
ports:
- "4321:4321"
backend:
image: your-backend:latest
environment:
- CLI_URL=cli-server:4321
depends_on:
- cli-server
</code></pre>
<p><strong>Kubernetes deployment:</strong></p>
<pre class="prettyprint"><code class="language-yaml">apiVersion: v1
kind: Service
metadata:
name: copilot-cli
spec:
selector:
app: copilot-cli
ports:
- port: 4321
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: copilot-cli
spec:
replicas: 1
template:
spec:
containers:
- name: cli
image: copilot-cli:latest
args: ["server", "--port", "4321"]
env:
- name: GITHUB_TOKEN
valueFrom:
secretKeyRef:
name: copilot-auth
key: token
</code></pre></section></section><section><a id="Bundled_CLI"></a>
<h2>Bundled CLI</h2>
<p>Package the Copilot CLI with your application so users don't need to install it separately.</p>
<p><strong>Use when:</strong> Distributing desktop applications or standalone tools.</p><section><a id="Configuration"></a>
<h3>Configuration</h3>
<p>Point the SDK to your bundled CLI binary:</p>
<pre class="prettyprint"><code class="language-java">var options = new CopilotClientOptions()
.setCliPath("./bundled/copilot"); // Relative to working directory
try (var client = new CopilotClient(options)) {
client.start().get();
// SDK uses the bundled CLI
}
</code></pre></section><section><a id="Packaging"></a>
<h3>Packaging</h3>
<ol style="list-style-type: decimal;">
<li>Download the appropriate CLI binary for your target platform</li>
<li>Include it in your application bundle:
<pre><code class="nohighlight nocode">my-app/
├── bin/
│ └── copilot # CLI binary
├── lib/
│ └── my-app.jar
└── run.sh
</code></pre></li>
<li>Configure the path in your application</li>
</ol></section><section><a id="Platform-Specific_Binaries"></a>
<h3>Platform-Specific Binaries</h3>
<p>For cross-platform applications, detect the platform and use the appropriate binary:</p>
<pre class="prettyprint"><code class="language-java">private String getCliPathForPlatform() {
String os = System.getProperty("os.name").toLowerCase();
String arch = System.getProperty("os.arch").toLowerCase();
if (os.contains("win")) {
return "./bin/copilot-windows-" + arch + ".exe";
} else if (os.contains("mac")) {
return "./bin/copilot-darwin-" + arch;
} else {
return "./bin/copilot-linux-" + arch;
}
}
var options = new CopilotClientOptions()
.setCliPath(getCliPathForPlatform());
</code></pre></section></section><section><a id="Scaling_.26_Multi-Tenancy"></a>
<h2>Scaling & Multi-Tenancy</h2>
<p>For applications serving many concurrent users, consider these patterns:</p><section><a id="Session_Isolation"></a>
<h3>Session Isolation</h3>
<p>Each user's sessions are automatically isolated within their client instance. For strongest isolation, use one CLI server per user:</p>
<pre class="prettyprint"><code class="language-java">// Pattern: Isolated CLI per user (requires CLI server per user)
public CopilotClient createIsolatedClient(String userId, int port) {
// Start CLI server for this user: copilot server --port {port}
var options = new CopilotClientOptions()
.setCliUrl("localhost:" + port);
return new CopilotClient(options);
}
</code></pre></section><section><a id="Resource_Management"></a>
<h3>Resource Management</h3>
<p>For high-concurrency scenarios:</p>
<pre class="prettyprint"><code class="language-java">// Use a client pool with bounded resources
public class CopilotClientPool {
private final Semaphore permits;
private final CopilotClient sharedClient;
public CopilotClientPool(int maxConcurrentSessions) {
this.permits = new Semaphore(maxConcurrentSessions);
this.sharedClient = new CopilotClient(/* options */);
}
public <T> T withSession(SessionConfig config,
Function<CopilotSession, T> action) throws Exception {
permits.acquire();
try {
var session = sharedClient.createSession(config).get();
try {
return action.apply(session);
} finally {
session.close();
}
} finally {
permits.release();
}
}
}
</code></pre></section><section><a id="Horizontal_Scaling"></a>
<h3>Horizontal Scaling</h3>
<p>When scaling beyond a single server:</p>
<ol style="list-style-type: decimal;">
<li>Run multiple CLI servers (one per app server or shared)</li>
<li>Use load balancing at the application tier</li>
<li>Each app server connects to its assigned CLI server via <code>setCliUrl()</code></li>
</ol></section></section><section><a id="Configuration_Reference"></a>
<h2>Configuration Reference</h2>
<p>Complete list of <code>CopilotClientOptions</code> settings:</p>
<table class="table table-striped">
<thead>
<tr class="a">
<th>Option</th>
<th>Type</th>
<th>Description</th>
<th>Default</th></tr></thead><tbody>
<tr class="b">
<td><code>cliPath</code></td>
<td>String</td>
<td>Path to CLI executable</td>
<td><code>"copilot"</code> from PATH</td></tr>
<tr class="a">
<td><code>cliUrl</code></td>
<td>String</td>
<td>External CLI server URL</td>
<td><code>null</code> (spawn process)</td></tr>
<tr class="b">
<td><code>cliArgs</code></td>
<td>String[]</td>
<td>Extra CLI arguments</td>
<td><code>null</code></td></tr>
<tr class="a">
<td><code>gitHubToken</code></td>
<td>String</td>
<td>GitHub OAuth token</td>
<td><code>null</code></td></tr>
<tr class="b">
<td><code>useLoggedInUser</code></td>
<td>Boolean</td>
<td>Use system credentials</td>
<td><code>true</code></td></tr>
<tr class="a">
<td><code>useStdio</code></td>
<td>boolean</td>
<td>Use stdio transport</td>
<td><code>true</code></td></tr>
<tr class="b">
<td><code>port</code></td>
<td>int</td>
<td>TCP port for CLI</td>
<td><code>0</code> (random)</td></tr>
<tr class="a">
<td><code>autoStart</code></td>
<td>boolean</td>
<td>Auto-start server</td>
<td><code>true</code></td></tr>
<tr class="b">
<td><code>autoRestart</code></td>
<td>boolean</td>
<td>Auto-restart on crash</td>
<td><code>true</code></td></tr>
<tr class="a">
<td><code>logLevel</code></td>
<td>String</td>
<td>CLI log level</td>
<td><code>"info"</code></td></tr>
<tr class="b">
<td><code>environment</code></td>
<td>Map</td>
<td>Environment variables</td>
<td>inherited</td></tr>
<tr class="a">
<td><code>cwd</code></td>
<td>String</td>
<td>Working directory</td>
<td>current dir</td></tr>
<tr class="b">
<td><code>onListModels</code></td>
<td>Supplier</td>
<td>Custom model listing implementation</td>
<td><code>null</code> (use CLI)</td></tr></tbody>
</table>
<section><a id="Extra_CLI_Arguments"></a>
<h3>Extra CLI Arguments</h3>
<p>Pass additional command-line arguments to the CLI process:</p>
<pre class="prettyprint"><code class="language-java">var options = new CopilotClientOptions()
.setCliArgs(new String[]{"--verbose", "--no-telemetry"});
try (var client = new CopilotClient(options)) {
client.start().get();
// CLI process receives the extra flags
}
</code></pre></section><section><a id="Custom_Environment_Variables"></a>
<h3>Custom Environment Variables</h3>
<p>Set environment variables for the CLI process (merged with the inherited system environment):</p>
<pre class="prettyprint"><code class="language-java">var options = new CopilotClientOptions()
.setEnvironment(Map.of(
"HTTPS_PROXY", "http://proxy.example.com:8080",
"NO_PROXY", "localhost,127.0.0.1"
));
try (var client = new CopilotClient(options)) {
client.start().get();
// CLI process uses the proxy settings
}
</code></pre>
<p>This is useful for configuring proxy servers, custom CA certificates, or any environment-specific settings the CLI needs.</p></section></section><section><a id="Best_Practices"></a>
<h2>Best Practices</h2><section><a id="Development"></a>
<h3>Development</h3>
<ul>
<li>Use default configuration (local CLI) for fastest iteration</li>
<li>Enable debug logging: <code>setLogLevel("debug")</code></li>
<li>Test with multiple models to ensure compatibility</li>
</ul></section><section><a id="Production"></a>
<h3>Production</h3>
<ul>
<li>Use external CLI servers (<code>setCliUrl</code>) for better resource management</li>
<li>Implement health checks on the CLI server endpoint</li>
<li>Monitor CLI server resource usage (CPU, memory)</li>
<li>Use connection pooling for high-concurrency scenarios</li>
<li>Implement proper token refresh for OAuth-based auth</li>
<li>Set appropriate timeouts for session operations</li>
</ul></section><section><a id="Security"></a>
<h3>Security</h3>
<ul>
<li>Never log or expose GitHub tokens</li>
<li>Use environment variables for tokens in production</li>
<li>Regularly rotate tokens</li>
<li>Implement proper access controls for multi-user apps</li>
<li>Validate user input before sending to sessions</li>
</ul></section></section><section><a id="Next_Steps"></a>
<h2>Next Steps</h2>
<ul>
<li><strong><a href="getting-started.html">Getting Started</a></strong> - Complete tutorial</li>
<li><strong><a href="documentation.html">Documentation</a></strong> - Core concepts</li>
<li><strong><a href="advanced.html">Advanced Usage</a></strong> - Tools, BYOK, MCP servers</li>
<li><strong><a href="apidocs/index.html">API Javadoc</a></strong> - Complete API reference</li>
</ul></section></section> </main>
</div>
</div>
<hr/>
<footer>
<div class="container-fluid">
<div class="row-fluid">
<p>© 2026
</p>
</div>
</div>
</footer>
</body>
</html>