Skip to content

Get up and running with the Gemini API using a simple Journaling App + Angular

License

Notifications You must be signed in to change notification settings

google-gemini/Journal-with-Gemini

Repository files navigation

Journal with Gemini

Get started with the Gemini API by asking questions about your journal.

Open in IDX

Basic request

To send your first API request with the Gemini API JavaScript SDK, make sure you have the right dependencies installed (see installation steps below) and then run the following code:

const { GoogleGenerativeAI } = require("@google/generative-ai");

const genAI = new GoogleGenerativeAI("GEMINI_API_KEY");
const model = genAI.getGenerativeModel({ model: "gemini-1.5-flash" });

const prompt = "Explain how AI works";

const result = await model.generateContent(prompt);
console.log(result.response.text());

Setup

  1. If you don’t have Angualr installed, install it from Angular.io.

  2. Clone this repository.

  3. Install the requirements:

    $ npm install
  4. Run the app:

Run ng serve for a dev server. Navigate to http://localhost:4200/. The application will automatically reload if you change any of the source files. Run ng build to build the project. The build artifacts will be stored in the dist/ directory.

  1. Paste your API key in the frontend, note this is generally a bad practice and is just shown here for simplicity.