Package com.github.copilot
package com.github.copilot
Core classes for the GitHub Copilot SDK for Java.
This package provides the main entry points for interacting with GitHub Copilot programmatically. The SDK enables Java applications to leverage Copilot's agentic capabilities, including multi-turn conversations, tool execution, and AI-powered code generation.
Main Classes
CopilotClient- The main client for connecting to and communicating with the Copilot CLI. Manages the lifecycle of the CLI process and provides methods for creating sessions, querying models, and checking authentication status.CopilotSession- Represents a single conversation session with Copilot. Sessions maintain context across multiple messages and support streaming responses, tool invocations, and event handling.JsonRpcClient- Low-level JSON-RPC client for communication with the Copilot CLI process.
Quick Start
try (var client = new CopilotClient()) {
client.start().get();
var session = client.createSession(new SessionConfig().setModel("gpt-4.1")).get();
session.on(AssistantMessageEvent.class, msg -> {
System.out.println(msg.getData().content());
});
session.send(new MessageOptions().setPrompt("Hello, Copilot!")).get();
}
Related Packages
com.github.copilot.generated- Auto-generated event types emitted during session processingcom.github.copilot.rpc- Configuration and data transfer objects
- See Also:
-
ClassDescriptionOpts a declaration into using
CopilotExperimentalAPIs.Represents the connection state of aCopilotClient.Provides a client for interacting with the Copilot CLI server.Marks a type or method as experimental.Annotation processor that enforces compile-time gating of experimental APIs.The per-request context handed to everyCopilotRequestHandlerhook.The base class for SDK consumers who want to observe or replace the LLM inference requests the runtime issues (for both CAPI and BYOK providers).The transport the runtime would otherwise use to issue an intercepted model-layer request.Represents a single conversation session with the Copilot CLI.The terminal status for a callback-owned WebSocket connection.The default pass-throughCopilotWebSocketHandler: it dials the real upstream usingWebSocketand relays upstream-to-runtime messages into the runtime response unchanged.A per-connection WebSocket handler returned byCopilotRequestHandler.openWebSocket(CopilotRequestContext).A single WebSocket message exchanged through aCopilotWebSocketHandlerhook.A handler for errors thrown by event handlers during event dispatch.Controls how event dispatch behaves when an event handler throws an exception.Provides the SDK protocol version.Specifies how the system message should be applied to a session.