diff --git a/js/genkit/.guides/config.json b/js/genkit/.guides/config.json deleted file mode 100644 index 5e50ed14df..0000000000 --- a/js/genkit/.guides/config.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "mcpServers": { - "genkit": { - "command": "genkit", - "args": ["mcp"] - } - }, - "docs": [ - { - "url": "https://genkit.dev/docs/models.md", - "name": "generate-content", - "title": "Generate Content", - "description": "read before generating content (text, structured data, images, videos) with Genkit." - }, - { - "url": "https://genkit.dev/docs/flows.md", - "name": "flows", - "title": "Using Flows to build GenAI Workflows", - "description": "read before building API endpoints or repeatable, strongly-typed workflows with Genkit" - }, - { - "url": "https://genkit.dev/docs/tool-calling.md", - "name": "tool-calling", - "title": "Tool Calling", - "description": "read before adding tools/function calls to Genkit for GenAI" - }, - { - "url": "https://genkit.dev/docs/interrupts.md", - "name": "tool-calling/interrupts", - "title": "Interrupts (Tool Calling with Human-in-the-Loop)", - "description": "read to understand how to use interrupts to provide human-in-the-loop capabilities to Genkit agents" - }, - { - "url": "https://genkit.dev/docs/context.md", - "name": "context", - "description": "read to understand how to pass context to tools and flows without exposing sensitive data to the LLM" - } - ] -} diff --git a/js/genkit/.guides/style.md b/js/genkit/.guides/style.md deleted file mode 100644 index 170ec60592..0000000000 --- a/js/genkit/.guides/style.md +++ /dev/null @@ -1 +0,0 @@ -- Prefer destructuring generate calls e.g. `const {text} = await ai.generate(...)` diff --git a/js/plugins/google-genai/.guides/docs/search-and-urls.prompt b/js/plugins/google-genai/.guides/docs/search-and-urls.prompt deleted file mode 100644 index 1eae75b95b..0000000000 --- a/js/plugins/google-genai/.guides/docs/search-and-urls.prompt +++ /dev/null @@ -1,34 +0,0 @@ ---- -title: Search Grounding and URL Context -description: read this to understand how to ground results on Google search or automatically ingest URLs in prompts to understand their contents ---- - -When using Gemini models, you can add configuration to automatically ground the prompt in Google search: - -```ts -const {text} = await ai.generate({ - model: googleAI.model('gemini-2.5-flash'), - // this includes the "built-in" search grounding tool - config: { - tools: [ - {googleSearch: {}}, - ] - } -}) -``` - -If your prompt contains URLs that you want the model to read and understand, you can add the URL context tool: - -```ts -const {text} = await ai.generate({ - model: googleAI.model('gemini-2.5-flash'), - // this includes the "built-in" url fetching tool - config: { - tools: [ - {urlContext: {}}, - ] - } -}) -``` - -You can use either or both of these tools to improve the "groundedness" of your generated model responses. \ No newline at end of file diff --git a/js/plugins/google-genai/.guides/usage.md b/js/plugins/google-genai/.guides/usage.md deleted file mode 100644 index c26f839b26..0000000000 --- a/js/plugins/google-genai/.guides/usage.md +++ /dev/null @@ -1,19 +0,0 @@ -To use a Gemini model with Genkit: - -```ts -import { ai, z } from '...'; // path to genkit instance -import { googleAI } from '@genkit-ai/google-genai'; - -const { text } = await ai.generate({ - model: googleAI.model('gemini-2.5-flash'), - prompt: '...', -}); -``` - -ALWAYS use `gemini-2.5-*` series models, they are the best and current generation of Gemini models. NEVER use `gemini-2.0-*` or `gemini-1.5-*` models. For general purpose inference, use one of these models: - -- `gemini-2.5-flash`: balance of speed/performance, good default -- `gemini-2.5-pro`: most powerful, use for complex prompts -- `gemini-2.5-flash-lite`: very fast, use for simple prompts - -All of these models can accept multi-modal input, but for image or audio output see the available documentation for specialized models. diff --git a/js/genkit/.guides/usage.md b/skills/genkit-js/SKILL.md similarity index 62% rename from js/genkit/.guides/usage.md rename to skills/genkit-js/SKILL.md index 9411df7836..67515374f3 100644 --- a/js/genkit/.guides/usage.md +++ b/skills/genkit-js/SKILL.md @@ -1,3 +1,17 @@ +--- +name: genkit-js +description: Use the Genkit AI SDK to build application features and agents with LLMs and other GenAI models for JavaScript/TypeScript applications. ALWAYS use this skill when writing Genkit code. +license: Apache-2.0 +metadata: + author: Google +--- + +# Genkit JS + +## Installation + +If Genkit is not already installed and configured in this application (present in `package.json` and `const ai = genkit(...)` present in the codebase), read `references/setup.md` to install and configure Genkit. + ## Basic Example ```ts @@ -61,3 +75,18 @@ import { defineFlow } from "..."; // INCORRECT pre-1.0 syntax - Use `import {z} from "genkit"` when you need Zod to get an implementation consistent with Genkit. - When defining Zod schemas, ONLY use basic scalar, object, and array types. Use `.optional()` when needed and `.describe('...')` to add descriptions for output schemas. - Genkit has many capabilities, make sure to read docs when you need to use them. + +## References + +- [Using Gemini with Genkit](references/gemini.md): Read this to leverage Google's Gemini models with Genkit. +- [Image Generation/Editing with Nano Banana](references/nano-banana.md): Read this to leverage Google's Nano Banana models for image generation and editing. +- [Speech generation with Gemini](references/generating-speech.md): Read this to leverage Google's Gemini TTS models for speech generation. + +## Online Documentation + +In addition to the above, you can read official documentation directly from the Genkit website by using `https://genkit.dev/docs/{topic}.md` as the URL. Available topics include: + +- `models`: general information about how to generate content +- `flows`: general information about how to define and use flows +- `tool-calling`: general information about how to define and use tools +- `model-context-protocol`: information about how to use and build MCP servers with Genkit diff --git a/skills/genkit-js/references/gemini.md b/skills/genkit-js/references/gemini.md new file mode 100644 index 0000000000..4560d89e31 --- /dev/null +++ b/skills/genkit-js/references/gemini.md @@ -0,0 +1,90 @@ +# Gemini + +## Installation + +To use Gemini models with Genkit, you need to install the Google GenAI plugin: + +```bash +npm i @genkit-ai/google-genai +``` + +and configure it for the Gemini API or Vertex AI API depending on the user's needs: + +```ts +import { googleAI } from '@genkit-ai/google-genai'; // for Gemini API +import { vertexAI } from '@genkit-ai/google-genai'; // for Vertex AI API + +const ai = genkit({ + // ... + plugins: [ + googleAI(), // for Gemini API, GEMINI_API_KEY env variable must be set + vertexAI({ location: 'global' }), // for Vertex AI, Google Application Default Credentials must be available + ], +}); + +googleAI.model('gemini-3-flash-preview'); // specify models for Gemini API +vertexAI.model('gemini-3-pro-preview'); // specify models for Vertex AI API +``` + +## Basic Usage + +```ts +import { ai, z } from '...'; // path to genkit instance +import { googleAI } from '@genkit-ai/google-genai'; + +const { text } = await ai.generate({ + model: googleAI.model('gemini-3-flash-preview'), + prompt: 'Tell me a story in a pirate accent', +}); +``` + +ALWAYS use `gemini-3-*` or`gemini-2.5-*` series models, they are the best and current generation of Gemini models. NEVER use `gemini-2.0-*` or `gemini-1.5-*` models. For general purpose inference, use one of these models: + +- `gemini-3-flash-preview`: balance of speed and performance, good default +- `gemini-3-pro-preview`: most powerful, use for complex prompts +- `gemini-2.5-flash`: GA model with balance of speed/performance +- `gemini-2.5-pro`: GA model for complex prompts +- `gemini-2.5-flash-lite`: GA model for simple prompts + +All of these models can accept multi-modal input, but for image or audio output see the available documentation for specialized models. + +## Common Usage Scenarios + +### Setting Thinking Level (Gemini 3 Models Only) + +```ts +const response = await ai.generate({ + model: googleAI.model('gemini-3-pro-preview'), + prompt: 'what is heavier, one kilo of steel or one kilo of feathers', + config: { + thinkingConfig: { + thinkingLevel: 'HIGH', // Or 'LOW' + includeThoughts: true, // Include thought summaries + }, + }, +}); +``` + +### Google Search Grounding + +When enabled, Gemini models can use Google Search to find current information to answer prompts. + +```ts +const response = await ai.generate({ + model: googleAI.model('gemini-2.5-flash'), + prompt: 'What are the top tech news stories this week?', + config: { + googleSearchRetrieval: true, + }, +}); + +// Access grounding metadata +const groundingMetadata = (response.custom as any)?.candidates?.[0] + ?.groundingMetadata; +if (groundingMetadata) { + console.log('Sources:', groundingMetadata.groundingChunks); +``` + +### Image Generation + +See `references/nano-banana.md` for information about using Nano Banana models for image generation and editing. diff --git a/js/plugins/google-genai/.guides/docs/generating-speech.prompt b/skills/genkit-js/references/generating-speech.md similarity index 89% rename from js/plugins/google-genai/.guides/docs/generating-speech.prompt rename to skills/genkit-js/references/generating-speech.md index df4d9410e3..6dcae1e052 100644 --- a/js/plugins/google-genai/.guides/docs/generating-speech.prompt +++ b/skills/genkit-js/references/generating-speech.md @@ -1,9 +1,6 @@ ---- -title: Generating Speech with Gemini -description: read this to understand how to generate realistic speech audio from a text script ---- +# Speech Generation with Gemini TTS -The Google Genai plugin provides access to text-to-speech capabilities through Gemini TTS models. These models can convert text into natural-sounding speech for various applications. +The Google GenAI plugin provides access to text-to-speech capabilities through Gemini TTS models. These models can convert text into natural-sounding speech for various applications. #### Basic Usage @@ -184,9 +181,3 @@ speechConfig: { - `volumeGainDb`: Controls the volume (higher values = louder) For more detailed information about the Gemini TTS models and their configuration options, see the [Google AI Speech Generation documentation](https://ai.google.dev/gemini-api/docs/speech-generation). - -## Next Steps - -- Learn about [generating content](/docs/models) to understand how to use these models effectively -- Explore [creating flows](/docs/flows) to build structured AI workflows -- To use the Gemini API at enterprise scale or leverage Vertex vector search and Model Garden, see the [Vertex AI plugin](/docs/integrations/vertex-ai) \ No newline at end of file diff --git a/js/plugins/google-genai/.guides/docs/editing-images.prompt b/skills/genkit-js/references/nano-banana.md similarity index 89% rename from js/plugins/google-genai/.guides/docs/editing-images.prompt rename to skills/genkit-js/references/nano-banana.md index 8ae25190d8..76b525275f 100644 --- a/js/plugins/google-genai/.guides/docs/editing-images.prompt +++ b/skills/genkit-js/references/nano-banana.md @@ -1,9 +1,6 @@ ---- -title: Edit images with `gemini-2.5-flash-image-preview` (aka "Nano Banana") -description: read this if you need to perform sophisticated image edits such as background removal, post matching, character replacement, relighting, on an existing image ---- +The Nano Banana models can perform sophisticated image edits. -The `gemini-2.5-flash-image-preview` model (also known as "Nano Banana") can perform sophisticated image edits. +- `gemini-2.5-flash-image-preview` - You must ALWAYS add `{config: {responseModalities: ['TEXT', 'IMAGE']}}` to your `ai.generate` calls when using this model. diff --git a/js/genkit/.guides/setup.md b/skills/genkit-js/references/setup.md similarity index 97% rename from js/genkit/.guides/setup.md rename to skills/genkit-js/references/setup.md index af7e48e4a9..92f0a1ea91 100644 --- a/js/genkit/.guides/setup.md +++ b/skills/genkit-js/references/setup.md @@ -1,3 +1,5 @@ +# Genkit JS Setup + Follow these instructions to set up Genkit in the current codebase. These instructions are general-purpose and have not been written with specific codebase knowledge, so use your best judgement when following them. 0. Tell the user "I'm going to check out your workspace and set you up to use Genkit for GenAI workflows." @@ -13,7 +15,7 @@ import { googleAI } from '@genkit-ai/google-genai'; export const ai = genkit({ plugins: [googleAI()], - model: googleAI.model('gemini-2.5-flash'), + model: googleAI.model('gemini-3-flash-preview'), }); export { z };