Index of every page on this site: llms.txt
All skills
genkit-ai avatar

/developing-genkit-dart

@d12c988
by Genkitgenkit-ai/skills40 stars
13
Run it yourself

Provides guidance on developing AI-powered applications using the Genkit Dart SDK. Use when the user asks to build AI agents in Dart, use Genkit flows, or integrate LLMs into Dart/Flutter applications. Don't use for Genkit in JavaScript/TypeScript, Go, or Python.

Use this Skill: https://skilld.dev/gh/genkit-ai/skills/developing-genkit-dart

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

referencesgenkit_google_genai.md

≈1k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Genkit Google GenAI Plugin (genkit_google_genai)

The Google AI plugin provides an interface against the official Google AI Gemini API.


Usage

import 'package:genkit/genkit.dart';
import 'package:genkit_google_genai/genkit_google_genai.dart';

void main() async {
  // Initialize Genkit with the Google AI plugin.
  final ai = Genkit(plugins: [googleAI()]);

  // Generate text
  final response = await ai.generate(
    model: googleAI.gemini('gemini-flash-latest'),
    prompt: 'Tell me a joke about a developer.',
    // Built-in; transient "high demand" errors are common.
    use: [retry()],
  );

  print(response.text);
}

Model refs and Gemma

googleAI.gemini('<name>') builds a ref for any Gemini model. Gemma models the Gemini API serves have a dedicated googleAI.gemma('<name>') alias (it reads correctly at call sites). Refer to models by name; there are no GoogleAiModels constants.

final response = await ai.generate(
  model: googleAI.gemma('gemma-4-31b-it'),
  prompt: 'Tell me a joke about a developer.',
);

Embeddings

final embeddings = await ai.embed(
  embedder: googleAI.textEmbedding('gemini-embedding-001'),
  documents: [
    DocumentData(content: [TextPart(text: 'Hello world')]),
  ],
  // Optional per-request tuning.
  options: GoogleGenAiEmbedderOptions(outputDimensionality: 768),
);

Config types are provider-prefixed

Nested config classes carry a Gemini prefix (embedder options use GoogleGenAi). Unprefixed names like ThinkingConfig do not exist here.

config: GeminiOptions(
  // Allowed levels depend on the model ('LOW' is widely supported).
  thinkingConfig: GeminiThinkingConfig(thinkingLevel: 'LOW'),
  safetySettings: [
    GeminiSafetySettings(
      category: 'HARM_CATEGORY_HATE_SPEECH',
      threshold: 'BLOCK_MEDIUM_AND_ABOVE',
    ),
  ],
  googleSearch: GeminiGoogleSearch(),
),

Also: GeminiFunctionCallingConfig, GeminiFileSearch, GeminiSpeechConfig, GeminiVoiceConfig, GeminiPrebuiltVoiceConfig, GeminiMultiSpeakerVoiceConfig, GeminiSpeakerVoiceConfig. The same types are re-exported by genkit_vertexai.

Image Generation

The plugin also supports image generation models such as gemini-3.1-flash-image.

Example (Nano Banana)

// Define an image generation flow
ai.defineFlow(
  name: 'imageGenerator',
  inputSchema: .string(defaultValue: 'A banana riding a bike'),
  outputSchema: Media.$schema,
  fn: (input, context) async {
    final response = await ai.generate(
      model: googleAI.gemini('gemini-3.1-flash-image'),
      prompt: input,
    );
    if (response.media == null) {
      throw Exception('No media generated');
    }
    return response.media!;
  },
);

The media (url field) contain base64 encoded data uri. You can decode it and save it as a file.

Text-to-Speech (TTS)

You can use text-to-speech models to generate audio from text. The generated Media object will contain base64 encoded PCM audio in its data URI.

// Define a TTS flow
ai.defineFlow(
  name: 'textToSpeech',
  inputSchema: .string(defaultValue: 'Genkit is an amazing AI framework!'),
  outputSchema: Media.$schema,
  fn: (prompt, _) async {
    final response = await ai.generate(
      model: googleAI.gemini('gemini-3.1-flash-tts-preview'),
      prompt: prompt,
      config: GeminiTtsOptions(
        responseModalities: ['AUDIO'],
        speechConfig: GeminiSpeechConfig(
          voiceConfig: GeminiVoiceConfig(
            prebuiltVoiceConfig: GeminiPrebuiltVoiceConfig(voiceName: 'Puck'),
          ),
        ),
      ),
    );
    
    if (response.media != null) {
      return response.media!;
    }
    throw Exception('No audio generated');
  },
);

Google AI also supports multi-speaker TTS by configuring a MultiSpeakerVoiceConfig inside SpeechConfig.

Source: SKILL.md on GitHub

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

1 alert2d4 checks · Risk SAFE
  • Gen Agent Trust Hub3d

    The Genkit Dart skill provides comprehensive documentation and examples for building AI agents and flows using the Genkit framework. It includes guidance on using A2UI for interactive interfaces, managing agent sessions, and implementing middleware for filesystem access and multi-agent orchestration. While the skill includes instructions for installing the Genkit CLI from a vendor-controlled domain, its primary security considerations involve the attack surface for indirect prompt injection created by agents that ingest external data while possessing capabilities such as file modification and command execution.

  • Socket2d

    No alerts

  • Snyk3d

    Risk: CRITICAL · 2 issues

  • Runlayer8mo

    2/11 files flagged

Signed by skilld at d12c988. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 4 days ago.

Activeupdated 5 days ago
metadata
{
  "version": "1.0.0",
  "category": "AiAndMachineLearning"
}

README badge

README badge for genkit-ai/skills/developing-genkit-dart