Gemini API Coding Guidelines (JavaScript/TypeScript)

Generate JavaScript/TypeScript code examples for the Gemini API using the @google/genai SDK.

4|Updated Feb 1, 2026
One-click install
npx skills add https://github.com/Gyana491/opencanvas-gemini --skill gemini-api-coding-guidelines-javascript-typescript
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Gemini API Coding Guidelines (JavaScript/TypeScript)
Source: https://github.com/Gyana491/opencanvas-gemini/tree/main/app/api/providers/google
Command: npx skills add https://github.com/Gyana491/opencanvas-gemini --skill gemini-api-coding-guidelines-javascript-typescript

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill provides clear, up-to-date guidance and code examples for using the Google Gen AI SDK (@google/genai) to interact with Gemini models, ensuring developers use the correct libraries and practices.

Core Features & Use Cases

  • SDK Best Practices: Demonstrates correct installation, initialization, and API usage for the @google/genai SDK.
  • Model Selection: Guides on choosing appropriate Gemini models for various tasks (text, multimodal, video, image).
  • Advanced Capabilities: Provides code snippets for features like multimodal inputs, system instructions, structured outputs (JSON), function calling, and media generation (images, video).
  • Use Case: A developer needs to integrate Gemini's multimodal capabilities into their application. They can refer to this Skill for precise JavaScript code examples on how to send images and text prompts to the API and handle the response.

Quick Start

Use the Gemini API coding skill to generate a JavaScript code snippet for basic text generation using the gemini-3-flash-preview model.

Frequently Asked Questions about Gemini API Coding Guidelines (JavaScript/TypeScript)

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use the Gemini API for text generation in JavaScript?

To use the Gemini API for text generation in JavaScript, install the official `@google/genai` SDK, initialize the client, and call the API with a text prompt using models like `gemini-3-flash-preview` to receive generated text responses.

What's the best way to send multimodal inputs like images to the Gemini API in TypeScript?

Sending multimodal inputs to the Gemini API in TypeScript involves using the `@google/genai` SDK to pass both text prompts and image data within the same request payload, allowing the model to process and respond to combined visual and textual information.

How do I get structured JSON outputs from the Gemini API using @google/genai?

You can get structured JSON outputs from the Gemini API by configuring your `@google/genai` SDK request with specific response schema parameters, ensuring the model returns valid JSON data conforming to your defined structure.

Does the Gemini API support function calling with JavaScript?

Yes, the Gemini API supports function calling with JavaScript. Using the `@google/genai` SDK, you can define functions for the model to invoke, allowing your application to execute custom logic and return results to the model.

Why should I use the @google/genai SDK instead of older Google AI libraries for TypeScript?

You should use the `@google/genai` SDK because it represents the current standard for interacting with Gemini models in TypeScript, ensuring adherence to modern API practices and avoiding deprecated libraries for long-term stability.

Can I generate media like images and video with the Gemini API in JavaScript?

Yes, you can generate media like images and video with the Gemini API in JavaScript by utilizing the `@google/genai` SDK, which provides specific code examples and methods for requesting and handling generated media content.