Sample demonstrating how to set-up the Vertex AI SDK and create a non-streaming conversation with three consecutive messages sent to the model.

## Code sample

### Node.js


Before trying this sample, follow the Node.js setup instructions in the
[Vertex AI quickstart using
client libraries](https://docs.cloud.google.com/vertex-ai/docs/start/client-libraries).


For more information, see the
[Vertex AI Node.js API
reference documentation](https://docs.cloud.google.com/nodejs/docs/reference/aiplatform/latest).


To authenticate to Vertex AI, set up Application Default Credentials.
For more information, see

[Set up authentication for a local development environment](https://docs.cloud.google.com/docs/authentication/set-up-adc-local-dev-environment).

    const {GoogleGenAI} = require('@google/genai');
    /**
     * TODO(developer): Update these variables before running the sample.
     */
    async function createNonStreamingChat(
      projectId = 'PROJECT_ID',
      location = 'us-central1',
      model = 'gemini-2.5-flash'
    ) {
      // Initialize client with your Cloud project and location
      const client = new GoogleGenAI({
        vertexai: true,
        project: projectId,
        location: location,
      });

      const chat = client.chats.create({
        model: model,
      });

      const response1 = await chat.sendMessage({message: 'Hello'});
      console.log('Chat response 1: ', response1.text);

      const response2 = await chat.sendMessage({
        message: 'Can you tell me a scientific fun fact?',
      });
      console.log('Chat response 2: ', response2.text);

      const response3 = await chat.sendMessage({
        message: 'How can I learn more about that?',
      });
      console.log('Chat response 3: ', response3.text);
    }

## What's next


To search and filter code samples for other Google Cloud products, see the
[Google Cloud sample browser](https://docs.cloud.google.com/docs/samples?product=aiplatform).