Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

Sample Google GenAI Application

This application demonstrates using the agent to instrument @google/genai and record spans for chat completions and embeddings.

This app supports both Gemini AI and Vertex AI. Specify which one you want with environment variable GOOGLE_GENAI_USE_VERTEXAI; acceptable values are 'true' for true and blank (not defined) for false.

Getting started

Note: This application requires the use of Node.js v20+.

  1. Make a Google Cloud project or a Gemini API Key.

  2. Clone or fork this repository.

  3. Install dependencies and run application.

    npm i
    cp env.sample .env
    # Fill out `NEW_RELIC_LICENSE_KEY`, `GEMINI_API_KEY` or `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` in .env and save 
    npm start
  4. Make requests to application.

    # Basic generate content example
    curl http://localhost:3000/
    
    # Generate content stream example
    curl http://localhost:3000/stream
    
    # Embed content example
    curl http://localhost:3000/embed

Inspecting AI Responses

After sending a few requests, navigate to your application in APM & Services. Select AI Monitoring > AI Responses:

AI Responses Landing

If you click the details of a response you will see metrics, trace information and LLM specific information:

AI Response

Click the metadata tab to see more information about the raw events:

AI Response Meta