-
Notifications
You must be signed in to change notification settings - Fork 651
docs: Adds genkit-js skill as a starting point for Genkit agent skills.
#4284
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3c25e41
1442319
0b8800b
a4d8674
c99af65
1743db7
3ece4a9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The reference to |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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'), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The default model in the setup guide has been updated to |
||
| }); | ||
|
|
||
| export { z }; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The phrase "ALWAYS use this skill when writing Genkit code" is quite strong. While it's good to emphasize its importance, consider softening it to a strong recommendation, e.g., "It is highly recommended to use this skill..." or "This skill should be used...". This allows for more flexibility in edge cases where it might not strictly apply.