cd /news/generative-ai/create-a-chatbot-with-google-generat… · home › topics › generative-ai › article
[ARTICLE · art-180991] src=loicmathieu.fr ↗ pub= topic=generative-ai verified=true sentiment=↑ positive

Create a Chatbot with Google Generative AI and Quarkus

Developer Loïc Mathieu published a walkthrough showing how to build a chatbot with a new Quarkus extension, quarkus-google-cloud-genai, which injects a Client object into a Quarkus REST endpoint to call Google's Gemini models. The example exposes a /chat endpoint that sends each prompt to the "gemini-3.8-flash" model with a system instruction and returns the generated text, and Mathieu notes the bot has no memory of earlier turns until conversation history is added. The extension is available from code.quarkus.io alongside the quarkus-rest extension.

recommendation

Store conversation history and resend it with each request, since a stateless generateContent call with only a system instruction leaves the chatbot unable to recall earlier turns such as the user's name.

more in playbook: Designing agent systems
by read4 min views1 publishedDec 3, 2026

I recently created a Quarkus extension that provides access to Google Generative AI. In this article, I’ll use this extension to create a chatbot.

The first step is to create a Quarkus project that includes the REST and Google Cloud Gen AI extensions.

Here are the extensions to add to your dependencies file:

<dependency>
        <groupId>io.quarkus</groupId>
        <artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
        <groupId>io.quarkiverse.googlecloudservices</groupId>
        <artifactId>quarkus-google-cloud-genai</artifactId>
</dependency>

Or, simpler, here’s a link that will let you create a project from code.quarkus.io.

The extension allows you to inject a Client object into a Quarkus application to access the Google Cloud Generartive AI service. This service lets you use the Gemini generative AI model in a Google Cloud project.

We’ll use this extension in a REST endpoint to build a chatbot. Since I’m not too keen on developing UIs, I’ll use cURL to call the chatbot.

Here’s the starting code for a chatbot:

package fr.loicmathieu.google.genai;

// [...] imports omitted for brevity

// 1. Standard REST endpoint available on /chat
@Path("/chat")
public class GenAIResource {
    // 2. System message telling the LLM it is a chatbot
    private static final String SYSTEM_INSTRUCTION = """
        You are a chatbot named Loïc.
        Don't pretend you know everything,
        but be helpful with a touch of humour.""";

    private GenerateContentConfig config;

    // 3. Injection of the provided GenAI Client object
    @Inject
    Client client;

    // 4. Init the configuration with the system instruction
    @PostConstruct
    void init() {
        var systemInstruction = Content.fromParts(Part.fromText(SYSTEM_INSTRUCTION));
        config = GenerateContentConfig.builder()
            .systemInstruction(systemInstruction).build();
    }

    // 5. Generate a chat response on each call to /chat
    @GET
    public String chat(@QueryParam("prompt") String prompt) {
        return client.models
            .generateContent("gemini-3.8-flash", prompt, config).text() + "\n";
    }
}
  1. A REST endpoint using the JAX-RS standard, available at the /chat path in the application.
  2. System message informing the model that it is a chatbot and asking it to respond with a touch of humor.
  3. Injection of the Client GenAI service, which is provided by theQuarkus Google Cloud GenAI extension.
  4. Initialization of the configuration in the REST endpoint’s post-construct method.
  5. Each time the endpoint is called, we’ll invoke the model and return the first generated response. A real-world application would certainly implement something more advanced. Here, we’re using Gemini Flash 3.8 because Gemini Flash is a model that combines performance with cost efficiency; exactly what we want for a chatbot that needs to respond quickly and doesn’t require overly complexreasoning .

To start the application in dev mode, you can use the Quarkus CLI: quarkus dev; the application will then be available on port 8080.

To call the chatbot, I use the following cURL command: curl -G localhost:8080/chat --data-urlencode "prompt=Tell me a joke". For those who aren’t familiar with this, using -G forces cURL to perform a GET request, which will then pass the data as a query string in the URL. This helps avoid any encoding issues with spaces by using --data-urlencode.

Here’s an example conversation:

As you can see, everything is going well until I ask him what my name is! Even though I just told him, he doesn’t know it because he has no memory.

We’re going to add a memory to the chatbot so we can have a real conversation with it; this is done through a chat session.

package fr.loicmathieu.quarkus.vertexai;

// [...] Imports omitted for brevity

// 1. Standard REST endpoint available on /chat
@Path("/chat")
public class GenAIResource {
    // 2. System message telling the LLM it is a chatbot
    private static final String SYSTEM_INSTRUCTION = """
        You are a chatbot named Loïc.
        Don't pretend you know everything;
            but be helpful with a touch of humour.""";

    private Chat chat;

    // 3. Injection of the provided GenAI Client object
    @Inject
    Client client;

    // 4. Init the configuration with the system instruction and a chat session
    @PostConstruct
    void init() {
        var systemInstruction = Content.fromParts(Part.fromText(SYSTEM_INSTRUCTION));
        var config = GenerateContentConfig.builder().
            systemInstruction(systemInstruction).build();

        chat = client.chats.create("gemini-3.8-flash", config);
    }

    // 5. Generate a chat response on each call to /chat
    @GET
    public String chat(@QueryParam("prompt") String prompt) {
        return chat.sendMessage(prompt).text() + "\n";
    }
}

With a memory, the chatbot works much better!

Here, I used a single chat session for the entire application, stored in memory (RAM). In a real-world scenario, you’ll of course need to use one chat session per user, ideally stored persistently.

That’s all for today; we’ve learned how to create a chatbot in Quarkus using Google Generative AI and the Gemini model. Google GenAI supports many other features: RAG, multimodal completion, tools, and more. You can find more information in its documentation.

You can find the project code on GitHub: quarkus-gen-ai.

Thank you to Google for providing Google Cloud credits to write this article.

── more in #generative-ai 4 stories · sorted by recency
── more on @google 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/create-a-chatbot-wit…] indexed:0 read:4min 2026-12-03 · —