Brifing

GitHub Copilot SDK for Java: Framework-Agnostic AI Integration

The first truly framework-independent way to drive AI from Java applications

The GitHub Blog3 min

1Framework-Agnostic AI Solution

GitHub Copilot SDK for Java provides AI integration without framework dependencies. Unlike solutions like Langchain4j and Spring AI, it works independently of any specific framework. Requiring JDK 17 or 25, the SDK can be easily added to projects via Maven. It supports modern Java features like virtual threads, ensuring high performance for enterprise applications.

2Multi-Model Support

The SDK works with various AI providers including OpenAI, Azure, and Anthropic. Its BYOK (Bring Your Own Key) approach allows usage without a Copilot subscription by specifying your own API keys and endpoints. The customizable ProviderConfig enables easy switching between different AI models. This flexibility provides significant advantages for enterprise solutions requiring vendor neutrality.

3Jakarta EE 11 Sample Application

The article showcases a sample application built on Jakarta EE 11. This real-time property management pipeline uses WebSocket to send live updates to clients. Copilot Agents running on virtual threads process each query independently. The application utilizes H2 in-memory database and presents its interface with PrimeFaces 15.0.16, demonstrating practical enterprise implementation.

4@CopilotTool Annotation

The SDK's core feature, @CopilotTool annotation, functions similarly to JAX-RS @GET endpoints. Developers can mark regular Java methods to create AI-callable tools. Parameters can be described using @CopilotToolParam annotations. The SDK automatically handles JSON Schema generation and argument parsing, significantly simplifying integration while maintaining type safety.

5Experimental Features

The annotation-based tool API is currently offered as an experimental feature. Enabling it requires passing -Acopilot.experimental.allowed=true flag to the Maven compiler. Additionally, the SDK's annotation processor must be added to maven-compiler-plugin. Without this configuration, $$CopilotToolMeta classes won't generate during compilation. Detailed documentation about experimental APIs is available in Copilot SDK docs.

6Lambda Tool Definitions

Beyond method annotations, the SDK supports lambda-based tool definitions through ToolDefinition.from(). This approach allows instant tool creation, ideal for small, single-use functions. Particularly useful for dynamically generated pipelines, lambda tools maintain full JSON Schema support just like their annotated counterparts. This dual approach provides flexibility for different development scenarios.

7Real-Time Workflow

In the sample app, users submit property requests processed by separate virtual threads. Copilot Agents manage the workflow through stages like VALIDATING, SEARCHING, and WRITING_REPORT. Real-time WebSocket updates allow users to monitor agent progress live. This architecture proves ideal for managing complex business workflows with transparency and efficiency.

8Enterprise Java Compatibility

The SDK supports many features familiar to enterprise Java developers. It works seamlessly with modern Java concepts like CompletableFuture, annotations, lambdas, and virtual threads. Compatibility with both Spring and Jakarta EE environments simplifies integration into existing systems. This makes it particularly valuable for microservices architectures requiring AI capabilities.

9Sample App Architecture

The demo application builds on Concern Technology Runtime and Open Liberty 26.0.0.5 platform. It utilizes Jakarta EE 11 specifications including Faces 4.1, CDI 4.1, WebSocket 2.2, Data 1.0, and Persistence 3.2. For UI, it employs PrimeFaces 15.0.16 with H2 in-memory database handling storage. AI orchestration uses Copilot SDK for Java 1.0.7-preview.1, showcasing a complete enterprise-grade implementation.

10Getting Started

To experiment with the SDK, developers can clone the sample application from GitHub. Requirements include JDK 17 or 25, Maven 3.9+, and a GitHub account. Local installation of Copilot CLI version 1.0.71 or later is necessary. The application runs via mvn clean package liberty:run commands, accessible at http://localhost:9080/index.xhtml. Developers can build custom agent harnesses using their preferred Java frameworks.

11Position in Java AI Ecosystem

GitHub Copilot SDK for Java fills a significant gap in the Java AI ecosystem. Its framework-agnostic nature and multi-model support offer developers unprecedented flexibility. Particularly suited for secure, scalable AI integration in enterprise applications, it promises long-term viability through open standards support. This SDK represents a new gateway for Java developers entering the AI landscape.

Original article: The GitHub Blog — GitHub Copilot SDK ile Java'da AI Entegrasyonu