Get started with the Gemini API by asking questions about your journal.
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());
-
If you don’t have Angualr installed, install it from Angular.io.
-
Clone this repository.
-
Install the requirements:
$ npm install
-
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.
- Paste your API key in the frontend, note this is generally a bad practice and is just shown here for simplicity.