Skip to content

[VertexAI] startChat() doesn’t work with a string for the systemInstruction #9006

Open
@nohe427

Description

@nohe427

Operating System

MacOS

Environment (if applicable)

node 22

Firebase SDK Version

11.1.0

Firebase SDK Product(s)

VertexAI

Project Tooling

Vite and NodeJS

Detailed Problem Description

Setting a system instruction using a string input in the startChat function call does not convert the string into a system part as required by the API endpoint.

Steps and code to reproduce issue

Code

const vertexSDK = getVertexAI(app);const genModel = getGenerativeModel(vertexSDK, {
  model: 'gemini-2.0-flash',
});
      
const chat = genModel.startChat({
 systemInstruction: 'talk like a pirate'
});
const response = await chat.sendMessage('how are you today?');
 console.log(response.response.text);

Error

error FirebaseError: VertexAI: Error fetching from https://firebasevertexai.googleapis.com/v1beta/projects/_/locations/us-central1/publishers/google/models/gemini-2.0-flash:generateContent: [400 ] Invalid value at 'system_instruction' (type.googleapis.com/google.cloud.aiplatform.v1beta1.Content), "talk like a pirate" [{"@type":"type.googleapis.com/google.rpc.BadRequest","fieldViolations":[{"field":"system_instruction","description":"Invalid value at 'system_instruction' (type.googleapis.com/google.cloud.aiplatform.v1beta1.Content), \"talk like a pirate\""}]}] (vertexAI/fetch-error)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions