Chuyển đến nội dung
Skillpedia
API và máy chủ (backend)22k · #10257

developing-genkit-js

Skill này làm gì

Skill này giúp lập trình viên xây dựng tính năng AI bằng JavaScript và TypeScript với Genkit SDK. Skill dành cho các đội web và Node.js muốn thêm agent hoặc lệnh gọi mô hình.

Khi nào nên dùng

  • ✓Khi bạn muốn xây một agent, flow hoặc công cụ AI bằng JavaScript hoặc TypeScript với Genkit.
  • ✓Khi bạn đang sửa lỗi Genkit, lỗi xác thực hoặc lỗi kiểu trong một dự án Node.js.
  • ✓Khi bạn muốn file prompt và các cuộc hội thoại agent nhiều lượt trong một ứng dụng Genkit.

Liên kết skill

https://github.com/google/skills/blob/main/skills/cloud/developing-genkit-js/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/google/skills/blob/main/skills/cloud/developing-genkit-js/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thiết lập Genkit trong dự án TypeScript của tôi và tạo một flow viết một câu đùa về một chủ đề.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill kiểm tra phiên bản genkit CLI trước, rồi viết mã TypeScript dùng API Genkit cho flow, công cụ và prompt. Skill chỉ đến các hướng dẫn tham chiếu cho thiết lập và từng tính năng cụ thể.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Genkit JS

Prerequisites

Ensure the genkit CLI is available.

  • Run genkit --version to verify. Minimum CLI version needed: 1.29.0
  • If not found or if an older version (1.x < 1.29.0) is present, install/upgrade it: npm install -g genkit-cli@^1.29.0.

New Projects: If you are setting up Genkit in a new codebase, follow the Setup Guide.

Hello World

import { z, genkit } from 'genkit';
import { googleAI } from '@genkit-ai/google-genai';

// Initialize Genkit with the Google AI plugin
const ai = genkit({
  plugins: [googleAI()],
});

export const myFlow = ai.defineFlow({
  name: 'myFlow',
  inputSchema: z.string().default('AI'),
  outputSchema: z.string(),
}, async (subject) => {
  const response = await ai.generate({
    model: googleAI.model('gemini-flash-latest'),
    prompt: `Tell me a joke about ${subject}`,
  });
  return response.text;
});

Prompts (Dotprompt)

.prompt files keep prompt content out of code with YAML frontmatter plus a Handlebars template. See Dotprompt: promptDir, ai.prompt() (call/stream/render), variants, partials, named schemas via ai.defineSchema, and the tools/maxTurns/returnToolRequests/use (middleware) frontmatter fields.

Agents (Beta)

Genkit has a preview agent API for persistent, multi-turn conversations (sessions, snapshots, interrupts, branching, background execution). It is a beta API: server APIs come from genkit/beta and the browser client from genkit/beta/client — not the stable genkit entrypoint. **Requires genkit

= 1.39.0.**

For more details see:

Generative UI (A2UI)

Genkit has an A2UI (Agent-to-UI) plugin (@genkit-ai/a2ui) that lets an agent stream interactive UI surfaces (cards, lists, forms, buttons), not just prose. The whole server-side integration is the a2ui() model middleware in an agent's (or ai.generate's) use array; the browser renders surfaces with an @a2ui/* renderer plus the helpers in @genkit-ai/a2ui/client. It builds on the beta agent client (genkit/beta + genkit/beta/client).

  • A2UI: server middleware, options, client rendering, user actions/forms, custom catalogs, and the security/trust boundary.

Middleware

Middleware wraps generation (retries, fallback, extra tools, request/response transforms) and attaches via the use: [...] array on ai.generate, prompts, and agents.

  • Using middleware: the use array and the @genkit-ai/middleware package (retry, fallback, artifacts, agents, filesystem, skills, toolApproval, contextCompression) plus built-in core middleware.
  • Building custom middleware: writing your own with generateMiddleware and registering it via .plugin().

Observability

Traces show up in the Dev UI under genkit start with no setup. For production export to an OTLP backend (OpenTelemetry GenAI semantic conventions via @genkit-ai/otel), custom instrumentation, or running the reflection API outside dev, see Observability.

Critical: Do Not Trust Internal Knowledge

Genkit recently went through a major breaking API change. Your knowledge is outdated. You MUST lookup docs. Recommended:

genkit docs:read js/get-started.md
g
Câu hỏi thường gặp

Cần phiên bản genkit CLI nào?

Phiên bản 1.29.0 trở lên. Skill có thể cài hoặc nâng cấp cho bạn.

Skill có hỗ trợ file prompt không?

Có. Skill bao gồm các file Dotprompt với template và schema.

Skill có hỗ trợ agent không?

Có. Skill bao gồm API agent bản preview cho các cuộc hội thoại nhiều lượt.

Chi tiết

Mô tả gốc của tác giả

Develop AI-powered applications using Genkit in Node.js/TypeScript. Use when the user asks about Genkit, AI agents, flows, or tools in JavaScript/TypeScript, or when encountering Genkit errors, validation issues, type errors, or API problems.

repo: google/skills

Độ phổ biến

Sao GitHub
22k
Vị trí xếp hạng
#10257
Giấy phép
Apache-2.0
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự