Using the GitHub Copilot SDK for Java

Using the GitHub Copilot SDK for Java

2026年8月10日1 次浏览来源:GitHub Blog阅读原文

Java developers no longer have to rely on Java framework-specific approaches to drive AI from their enterprise apps.

While it is true that Langchain4j empowered developers by disintermediating specific AI vendors, you still had a dependency on Langchain4j.

And with Spring AI, well, of course you had a dependency on design choices made by Spring, if not on Spring itself.

Now, GitHub Copilot SDK for Java is the first truly framework agnostic way to drive AI from Java.

And with its BYOK support, GitHub Copilot SDK for Java is also AI vendor neutral.

Even though it’s called GitHub Copilot SDK, you can use it with any direct model provider, such as OpenAI, Azure, Anthropic, or OpenAI-compatible endpoints, by passing a / with your own + (or bearer token).

No Copilot subscription required.

The GitHub Copilot SDK for Java is a client library that empowers your server-side Java code to create Copilot agent sessions, register tools, send prompts, and receive structured responses—all programmatically.

It works in server environments, including Jakarta EE and Spring.

If you’ve been building enterprise Java for any length of time, this SDK will feel like home: , annotations, lambdas, virtual threads, it’s all here.

This post shows you how to use the SDK, walks through a complete Jakarta EE 11 sample application, and leaves you with concrete next steps to try it yourself.

I chose Jakarta EE 11 for my demo because I was the lead release coordinator for that release.

I believe in open standards as the best way to empower developers.

For more on Jakarta EE 11 see this InfoQ article.

This sample app is an agent harness using Jakarta EE

11.

But, of course, developers can build their own agent harness using the well-known Java frameworks and libraries of their choice.

Clone the sample app and try it yourself > Where to get it The SDK is available as a Maven dependency: Prerequisites: JDK 17 or 25 (25 recommended — unlocks virtual threads and other modern features) Maven 3.9+ A GitHub account with an active Copilot subscription The Copilot CLI installed locally at version 1.0.71 or later.

Walk through the sample app The best way to see the SDK in action is to run this sample application.

Get the code The Java demo is built on: ConcernTechnologyRuntimeOpen Liberty 26.0.0.5PlatformJakarta EE 11 (Faces 4.1, CDI 4.1, WebSocket 2.2, Data 1.0, Persistence 3.2)UIPrimeFaces 15.0.16AI orchestrationCopilot SDK for Java 1.0.7-preview.1DatabaseH2 in-memory (10 seed property listings) What the app does The application is a real-estate lead-management agent pipeline.

A customer submits an enquiry (“I’m looking for a 3-bedroom house in London under £800,000”), and the system spins up an isolated Copilot Agent on a virtual thread to process it through a pipeline: The architecture uses Jakarta WebSocket to push real-time status updates from the server to the browser, so you can watch agents progress through phases as the model calls tools: Submit multiple inquiries simultaneously to see concurrent virtual-thread agents in action.

Each one processes independently with its own Copilot session.

SDK features in action Let’s walk through the key SDK features as they appear in the sample code.

Defining tools with This is the headline API.

If you’ve ever written a endpoint in JAX-RS or an bean, this will feel instantly familiar: The annotation declares the method as a tool the model can call.

The annotation describes each parameter so the model knows what to pass.

The SDK handles all the JSON Schema generation, argument parsing, and dispatch.

You just write a normal Java method.

Two build prerequisites for .

The annotation-based tool API is currently an experimental feature of the SDK, so you need to configure two things in your Maven build: Enable experimental APIs: pass to the compiler.

Without this flag, the annotation processor will refuse to generate the tool metadata.

For more details on the experime

分享
Baike.dev

baike.dev helps you discover great languages, frameworks, databases, DevOps and cloud-native tools.

Quick links

About

Contribute

Found a great developer tool? Share it with the community.

Submit a tool
© 2026 baike.dev Developer EncyclopediaUpdated daily · Discover great developer tools