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.
Note: This application requires the use of Node.js v20+.
-
Make a Google Cloud project or a Gemini API Key.
-
Clone or fork this repository.
-
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 -
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
After sending a few requests, navigate to your application in APM & Services. Select AI Monitoring > AI Responses:
If you click the details of a response you will see metrics, trace information and LLM specific information:
Click the metadata tab to see more information about the raw events:


