Convert Figma logo to code with AI

google-gemini logodeprecated-generative-ai-js

This SDK is now deprecated, use the new unified Google GenAI SDK.

1,225
307
1,225
97

Top Related Projects

This SDK is now deprecated, use the new unified Google GenAI SDK.

Official JavaScript / TypeScript library for the OpenAI API

Utilities to use the Hugging Face Hub API

Integrate cutting-edge LLM technology quickly and easily into your apps

Quick Overview

The google-gemini/deprecated-generative-ai-js repository is a deprecated JavaScript library for interacting with Google's Generative AI models. It provided a way to integrate Google's AI capabilities into web applications, but has since been replaced by newer solutions.

Pros

  • Easy integration with Google's AI models
  • Simplified API for generating text and images
  • Supported both browser and Node.js environments
  • Provided TypeScript support

Cons

  • Deprecated and no longer maintained
  • May have compatibility issues with newer AI model versions
  • Limited documentation due to its deprecated status
  • Potential security risks from using outdated libraries

Code Examples

// Initialize the GenerativeAI client
const genAI = new GenerativeAI(API_KEY);

// Generate text
const model = genAI.getGenerativeModel({ model: "gemini-pro" });
const result = await model.generateContent("Tell me a joke about programming.");
console.log(result.response.text());
// Generate an image
const model = genAI.getGenerativeModel({ model: "gemini-pro-vision" });
const image = await fetch('https://example.com/image.jpg');
const result = await model.generateContent([
  "Describe this image:",
  image
]);
console.log(result.response.text());
// Use streaming for real-time responses
const stream = await model.generateContentStream("Write a short story.");
for await (const chunk of stream) {
  console.log(chunk.text());
}

Getting Started

As this library is deprecated, it's not recommended for use in new projects. However, if you still need to use it for legacy reasons, you can install it via npm:

npm install @google/generative-ai

Then, import and use it in your JavaScript code:

import { GenerativeAI } from "@google/generative-ai";

const API_KEY = "YOUR_API_KEY";
const genAI = new GenerativeAI(API_KEY);

// Use the genAI object to interact with the models

Remember to replace "YOUR_API_KEY" with your actual Google API key. For current and supported solutions, please refer to Google's official documentation for their latest AI offerings.

Competitor Comparisons

This SDK is now deprecated, use the new unified Google GenAI SDK.

Pros of deprecated-generative-ai-js

  • Identical repositories, so no distinct advantages
  • Both provide deprecated JavaScript SDK for Google's Generative AI

Cons of deprecated-generative-ai-js

  • No unique disadvantages compared to the other repository
  • Both are deprecated, indicating lack of ongoing support or updates

Code Comparison

Both repositories contain identical code. Here's a sample from the main index.js file:

import { GoogleGenerativeAI } from "@google/generative-ai";

const genAI = new GoogleGenerativeAI(process.env.API_KEY);

async function run() {
  const model = genAI.getGenerativeModel({ model: "gemini-pro" });

Summary

The comparison between deprecated-generative-ai-js and itself yields no meaningful differences. Both repositories are identical and deprecated, serving as historical references for the JavaScript SDK for Google's Generative AI. Users should seek current, supported alternatives for integrating Google's Generative AI capabilities into their JavaScript projects.

Official JavaScript / TypeScript library for the OpenAI API

Pros of openai-node

  • More mature and widely adopted library with extensive documentation
  • Supports a broader range of OpenAI models and features
  • Active development and frequent updates

Cons of openai-node

  • Specific to OpenAI services, limiting flexibility for other AI providers
  • May have a steeper learning curve for beginners due to its comprehensive feature set

Code Comparison

openai-node:

import OpenAI from 'openai';
const openai = new OpenAI({ apiKey: 'your-api-key' });
const completion = await openai.chat.completions.create({
  model: "gpt-3.5-turbo",
  messages: [{ role: "user", content: "Hello, how are you?" }]
});

deprecated-generative-ai-js:

import { GoogleGenerativeAI } from '@google/generative-ai';
const genAI = new GoogleGenerativeAI('your-api-key');
const model = genAI.getGenerativeModel({ model: 'gemini-pro' });
const result = await model.generateContent('Hello, how are you?');

The openai-node library offers a more structured approach with explicit role definitions, while deprecated-generative-ai-js provides a simpler interface for basic text generation. However, it's important to note that deprecated-generative-ai-js is no longer actively maintained, which may impact its long-term viability and compatibility with newer features.

Utilities to use the Hugging Face Hub API

Pros of huggingface.js

  • Broader ecosystem support with access to numerous pre-trained models
  • More comprehensive documentation and community resources
  • Active development and frequent updates

Cons of huggingface.js

  • Potentially more complex setup for simple use cases
  • May require more computational resources for some tasks

Code Comparison

huggingface.js:

import { HfInference } from '@huggingface/inference'
const hf = new HfInference(process.env.HF_API_KEY)
const result = await hf.textGeneration({
  model: 'gpt2',
  inputs: 'The meaning of life is'
})

deprecated-generative-ai-js:

import { GenerativeModel } from '@google/generative-ai'
const model = new GenerativeModel({ model: 'gemini-pro' })
const result = await model.generateContent('The meaning of life is')

Both libraries offer straightforward ways to interact with language models, but huggingface.js provides access to a wider range of models and tasks. The deprecated-generative-ai-js focuses specifically on Google's Gemini model, which may be advantageous for certain use cases but limits flexibility compared to huggingface.js.

Integrate cutting-edge LLM technology quickly and easily into your apps

Pros of semantic-kernel

  • More comprehensive framework for building AI-powered applications
  • Supports multiple programming languages (C#, Python, Java)
  • Extensive documentation and examples for various use cases

Cons of semantic-kernel

  • Steeper learning curve due to more complex architecture
  • Potentially overkill for simple AI integration tasks
  • Requires more setup and configuration compared to simpler libraries

Code Comparison

semantic-kernel:

using Microsoft.SemanticKernel;

var kernel = Kernel.Builder.Build();
var prompt = "Summarize this text: {{$input}}";
var function = kernel.CreateSemanticFunction(prompt);
var result = await function.InvokeAsync("Long text to summarize...");

deprecated-generative-ai-js:

import { GenerativeModel } from "@google/generative-ai";

const model = new GenerativeModel({ model: "gemini-pro" });
const result = await model.generateContent("Summarize this text: Long text to summarize...");

The semantic-kernel example showcases its more structured approach with kernel building and function creation, while deprecated-generative-ai-js offers a simpler, more direct method for generating content. semantic-kernel provides more flexibility and control, but requires more setup code.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

[Deprecated] Google AI JavaScript SDK for the Gemini API

With Gemini 2.0, we took the chance to create a single unified SDK for all developers who want to use Google's GenAI models (Gemini, Veo, Imagen, etc). As part of that process, we took all of the feedback from this SDK and what developers like about other SDKs in the ecosystem to create the Google Gen AI SDK.

The full migration guide from the old SDK to new SDK is available in the Gemini API docs.

The Gemini API docs are fully updated to show examples of the new Google Gen AI SDK. We know how disruptive an SDK change can be and don't take this change lightly, but our goal is to create an extremely simple and clear path for developers to build with our models so it felt necessary to make this change.

Thank you for building with Gemini and let us know if you need any help!

Please be advised that this repository is now considered legacy. For the latest features, performance improvements, and active development, we strongly recommend migrating to the official Google Generative AI SDK for JavaScript.

Support Plan for this Repository:

  • Limited Maintenance: Development is now restricted to critical bug fixes only. No new features will be added.
  • Purpose: This limited support aims to provide stability for users while they transition to the new SDK.
  • End-of-Life Date: All support for this repository (including bug fixes) will permanently end on September 30, 2025.

We encourage all users to begin planning their migration to the Google Generative AI SDK to ensure continued access to the latest capabilities and support.

NPM DownloadsLast 30 Days