New Apr 9, 2026

@google/genai SDK: Does chat.sendMessage config override the ai.chats.create config?

Libraries, Frameworks, etc. All from Newest questions tagged vue.js - Stack Overflow View @google/genai SDK: Does chat.sendMessage config override the ai.chats.create config? on stackoverflow.com

I am using the official @google/genai SDK in a Vue.js application. My goal is to establish a persistent systemInstruction for a chat session, while retaining the ability to cancel individual requests using an AbortController.

Because an AbortController is single-use, I must instantiate a new one and pass its abortSignal into every individual sendMessage call.

However, doing this seems to completely overwrite the base configuration established in chats.create. The LLM entirely forgets the system prompt.

Here is a minimal reproducible example:

<script setup>
import { ref } from 'vue';
import { GoogleGenAI } from "@google/genai";

const ai = new GoogleGenAI({ apiKey: "BLABLABLABLABLABLA" });

const chat = ai.chats.create({ model: "gemini-3-flash-preview", config: { systemInstruction: "You are an expert about tennis. Don't reply to other kinds of requests, but apologize and state that you're a tennis assistant only", } });

const inputText = ref(""); const result = ref(""); let abortController;

async function sendRequest() { abortController = new AbortController();

try { console.log("Sending message"); const response = await chat.sendMessage({ message: inputText.value, config: { abortSignal: abortController.signal } }); console.log(response.text); result.value = response.text; } catch (e) { if (e && e.name === "AbortError") { console.log("Request was aborted"); } else { console.log(e); } } finally{ abortController = null; } }

function abortRequest(){ if(abortController){ abortController.abort(); } abortController = null; }

</script>

<template>

<input type="text" v-model="inputText"> <button @click="sendRequest">Send</button> <button @click="abortRequest">Abort</button> <p>{{ result }}</p>

</template>

I would expect that the 2 configs are merged. Instead, the second one completely overrides the first one.

  1. Is this complete configuration overwrite the intended behavior of the SDK?

  2. Is manually spreading the base configuration into every single sendMessage call (e.g., config: { ...baseConfig, abortSignal }) the only correct architectural approach here?

Scroll to top