genkit

genkit-aiApache-2.0活跃维护

Google 开源的智能体应用开发框架,支持 JavaScript、Go、Dart 和 Python,内置 LLM 调用、多模态、RAG 与向量检索能力,帮开发者快速搭建生产级 AI 应用。

Open-source framework for building agentic apps in JavaScript, Go, Dart, and Python, built and used in production by Google

py/v0.13.0发布于 2026-11-05 16:53 UTC6,579star +7 / 7 天879fork同步于 2026-11-10 17:34 UTC

怎么上手

由 README 提炼,执行前请确认
npm install -g genkit-cli
genkit start -- <command to run your code>
硬件要求按 README 说明

README 未说明硬件要求;模型推理走云端 API,本地无需 GPU 显存

下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Google 开源的全栈 AI 应用框架,统一接口接入多家模型,快速搭建智能体应用

Google 开源的智能体应用开发框架,支持 JavaScript、Go、Dart 和 Python,内置 LLM 调用、多模态、RAG 与向量检索能力,帮开发者快速搭建生产级 AI 应用。

核心能力

  • 用统一接口接入 Google、OpenAI、Anthropic、Ollama 等数百个模型
  • 提供结构化输出、工具调用、多模态输入输出与 RAG 等 API
  • 支持 JS/TS、Go、Python(Beta)、Dart(Preview) 多语言 SDK
  • 自带 CLI 与本地 Developer UI,可测试提示词、对比模型、查看执行链路
  • 提供生产监控面板,追踪延迟、请求量与错误率

容易踩的坑

需自行申请所选模型提供商的 API key,Vertex AI 等还需另外的认证方式;Python 为 Beta、Dart 为 Preview,稳定性不如 JS/Go;用编码智能体开发时建议先安装对应语言的 Genkit skill 以了解最新 API

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本py/v0.13.0
  1. py/v0.13.0Genkit Python SDK v0.13.0最新正式版2026-11-05 · 2026-11-05 16:53 UTC

    Genkit Python 0.13 is the last release with major breaking changes, and the last release before 1.0. Yes, there are a lot of breaking changes, and that's on purpose. The SDK we had going in carried many conventions borrowed from Genkit JS and Go. In this release we went through the whole API surface and made it feel native to Python, while keeping it consistent with what you'd expect from the other Genkit SDKs.

    We chose clean breaks over deprecation shims and aliases because we want a clean, Pythonic API surface going into 1.0, not one that carries two names for everything. We didn't want to break you a little at a time before 1.0, and we won't break you after it. So everything that wasn't Pythonic comes to light in this one release. This is the API we're sticking with, and you shouldn't expect changes like these going forward.

    Upgrading? Follow the 0.12 → 0.13 migration guide, or point your coding agent at it.

    Evaluators are the one exception. They still ship in 0.13 and go away in 1.0, the next release, while we redesign them across all the Genkit SDKs. We kept them on purpose. Older plugin releases accepted any version of genkit, so removing evaluators now could let pip install an old genkit-evaluators next to a genkit that no longer has them. 0.13 adds version bounds to every plugin, and genkit-evaluators now requires genkit<1, so the next release can remove them cleanly (see below).

    Why upgrade

    Feels like Python

    Your IDE and type checker now catch Genkit mistakes before you run anything. Contexts are generic, config fields are typed Literals, and signatures are keyword-only. Cancellation is plain asyncio, and flow input and output are validated by Pydantic.

    @ai.flow()
    async def plan(trip: Trip, ctx: FlowContext[Status]) -> Itinerary:
        ctx.send_chunk(Status(step='search'))   # chunk type checked by pyright
        res = await ai.generate(
            prompt=trip.ask,
            config=GeminiConfig(thinking_level='HIGH'),   # a typo here is a type error
        )
        ...
    
    task = asyncio.create_task(plan(trip))
    task.cancel()   # cancels the model call and any running tools, like any asyncio code
    

    Safe by default

    In 0.12, some mistakes failed silently or in surprising places. In 0.13 they fail where you made them, with an error that names the problem.

    # 0.12 silently dropped the misspelled key. 0.13 raises before the model is called.
    await ai.generate(prompt=p, config={'temprature': 0.2})
    
    # 0.12 let a tool's catch-all swallow an approval request.
    # In 0.13, Interrupt is a BaseException, so it reaches the caller.
    @ai.tool()
    async def refund(order: Order) -> dict:
        try:
            require_approval(order)          # raises Interrupt
        except Exception:
            log.warning('refund check failed')
    
    • Approval interrupts. An interrupt isn't an error, so it's now a BaseException, like asyncio.CancelledError. A tool's except Exception: can no longer turn an approval request into an error and let the turn continue without approval.
    • Truncated JSON. When a reply hit the token limit partway through a JSON object, 0.12 could return a partial object that looked valid. Now response.output is None and response.error reports INVALID_OUTPUT.
    • API keys. Per-request keys already belonged in context.secrets, but some plugins silently dropped or ignored a key left in model config. Every plugin now raises instead.
    • Media URLs. Ollama no longer reads media from local file paths, and media downloads over 20 MB fail instead of loading into memory.

    Errors are safe to serve

    When you serve flows over HTTP, errors no longer leak. In 0.12, a served flow sent the client the message and details of any GenkitError, plus the text and stack trace of any other exception. In 0.13, the client sees only what you mark as public, and your own code still sees everything.

    @
    
  2. [email protected]Genkit JS 1.44.02026-11-03 · 2026-11-03 21:01 UTC
    查看更新说明

    Features

    Google GenAI

    • Added the Gemini Deep Research agent (deep-research-preview-04-2026) to the vertexAI plugin as a background model. (#6872)

      const { operation } = await ai.generate({
        model: vertexAI.model('deep-research-preview-04-2026'),
        prompt: 'Compare TCP and UDP in a short markdown table.',
      });
      
    • googleAI now sends store on generateContent requests when it's set, so you can opt out of the Gemini API's new default request logging for paid projects. (#6919)

    • Interactions API models now accept Word, Excel and other document types instead of only PDF and CSV. (#6904)

    • gemini-nano-banana-* models on googleAI are now treated as image models and accept imageConfig. (#6910)

    • generateContent models now report tool-use tokens as usage.custom.toolUseTokens. (#6963)

    Bug Fixes

    Google GenAI

    • On Interactions API models, a request-level store now overrides the plugin-level store option. (#6963)
    • Server-side tool steps (URL context, file search, Google Maps, MCP) are now kept in multi-turn history on Interactions API models. (#6909)
    • vertexAI stateless multi-turn conversations that used Google Search no longer fail with a 501. (#6909)
    • Output settings are now sent as response_format, which also fixes JSON output losing its schema when combined with audioFormat or videoFormat. (#6910)
    • responseMimeType: 'application/json' and JSON output without a schema now work on Interactions API models. (#6963)
    • Removed the shut-down Veo models from googleAI. veo-* names now fail with a clear error pointing to gemini-omni-1.1-flash. Veo is still available on vertexAI. (#6918)

    Breaking Changes

    • Google GenAI, Interactions API usage: per-modality token counts moved from inputCharacters, inputImages, outputAudioFiles, etc. to usage.custom.*Tokens (e.g. inputTextTokens). Those old fields held token counts by mistake. See #6963 for the full mapping.

    Full Changelog: https://github.com/genkit-ai/genkit/compare/[email protected]@1.44.0

  3. [email protected]Genkit CLI and Dev UI 1.45.02026-11-03 · 2026-11-03 02:09 UTC
    查看更新说明

    CLI

    This release improves the Genkit MCP server and documentation commands with automatic project language detection and more reliable runtime restarts, adds trace indexing and filtering by session ID, and introduces experimental flags for Reflection API authentication and OTLP telemetry routing.

    New Features

    • Automatic Project Language Detection for Docs & MCP Tools: genkit docs:list and genkit docs:search, as well as the MCP list_genkit_docs, search_genkit_docs, and get_usage_guide tools, now automatically detect your project's language (js, go, python, or dart) from workspace files instead of defaulting to JavaScript.
    • Session ID Trace Indexing & Filtering: Local trace storage now indexes agent session IDs, and genkit trace:list adds a --session-id <sessionId> option to filter traces by session.
    • Experimental Reflection API Authentication & Host Binding: Added --experimental-auth (and GENKIT_REFLECTION_SECRET_TOKEN support) across CLI workflow and runtime commands (start, start:flutter, mcp, flow:run, flow:batch-run, eval:run, eval:flow, and eval:extract-data) to require shared-secret authentication from connecting runtimes. The Reflection v2 WebSocket server now binds to loopback (127.0.0.1) by default and adds --reflection-v2-host <host> on start and start:flutter for remote or containerized runtimes.
    • Experimental OTLP Telemetry Routing: Added genkit start --experimental-use-otel to point an application's own OpenTelemetry SDK at the local Dev UI telemetry server via standard OTEL_EXPORTER_OTLP_* environment variables while suppressing native direct telemetry export.

    Fixes

    • Reliable MCP Runtime Restarts & Tool Metadata: Fixed restart_runtime in the MCP server so process start options (such as working directory and non-interactive mode) are preserved across restarts and the tool waits for the restarted runtime to finish registering before returning. Added server-level MCP instructions, clearer tool descriptions, and improved error formatting.
    • Compact list_genkit_docs MCP Output: Omitted section headers from list_genkit_docs tool output to reduce token overhead when AI assistants browse documentation.
    • Smaller CLI & Telemetry Package Tarballs: Build dependency improvements and clean up.

    Dev UI

    This release introduces live interactive rendering, validation, pop-out inspection, and end-to-end action simulation for A2UI surfaces across the Agent, Model, and Prompt runners, alongside layout and preference improvements in the Trace Viewer and navigation sidebar.

    New Features

    • Live A2UI Surface Previews & Validation: A2UI Surface cards now render interactive live previews for Basic Catalog surfaces directly inline. Surfaces are validated against catalog schemas, surfacing error or warning callouts and per-node issue badges in the component tree when validation issues or custom catalogs are detected.

    • Pop-Out A2UI Surface Inspector: Added an Inspect button on previewable A2UI surface cards that opens a resizable split-pane workbench pairing the live preview with the Component Tree and Active Data Model. Hovering or focusing nodes in the component tree highlights the corresponding rendered element in the live preview, and edits made in interactive preview controls sync live with the inspected data model and bound tree properties.

    • Interactive A2UI Action Simulation & Action Cards: You can now trigger client-to-server A2UI actions directly by in

  4. [email protected]Genkit JS 1.43.02026-10-21 · 2026-10-21 19:36 UTC
    查看更新说明

    Highlights

    Agents that recover from failures, plus background sub-agents

    Agent runs can now pick up where they stopped after a failure or an abort, and orchestrators can hand work to sub-agents that run in the background.

    • throwOnError: false on generate() returns the failure and the conversation up to the last completed tool round, so you can retry from there. Code that doesn't set it still gets the same errors as before. (#6359)

      const opts = { model: googleAI.model('gemini-flash-latest'), tools: [getWeather], throwOnError: false };
      let res = await ai.generate({ ...opts, prompt: 'What should I wear in Tokyo today?' });
      if (res.finishReason === 'failed' || res.finishReason === 'aborted') {
        res = await ai.generate({ ...opts, messages: res.messages });
      }
      
    • Failed and aborted agent turns are now resume points. A failed turn is saved as a failed snapshot and a stopped run is saved as an aborted snapshot. Both can be resumed. (#6361, #6362, #6360)

    • waitForSnapshot is the blocking version of getSnapshot. It waits on the server until a detached turn finishes, so you don't need a polling loop. (#6272)

      const task = await reportAgent.chat().detach('Write the report');
      const snap = await task.wait();
      
    • Background delegation in the agents middleware. With async: true, delegation tools accept background: true and return a task ID right away. New check_background_tasks, wait_for_background_tasks and abort_background_tasks tools let the orchestrator manage those tasks. (#6273)

      use: [agents({ agents: ['researcher'], async: true })]
      
    • continue_task continues a failed, aborted or finished sub-agent task from its handle, with optional new instructions. Snapshot reads also accept metadataOnly to skip loading the state. (#6693)

    • Transport-specific options in AgentAPI. In-process agents accept a per-chat or per-call context, so auth carries through detached tasks and background jobs. The building blocks for custom AgentTransport implementations are now exported. (#6448)

      const chat = weatherAgent.chat({}, { context: { auth: { uid: 'alice' } } });
      

    New contextCompression middleware

    @genkit-ai/middleware now includes contextCompression, which keeps long agent conversations within a token budget. It truncates tool responses, removes duplicate tool responses, caps message counts, and can summarize old turns with an LLM. It tracks compaction history so later rounds build on earlier ones. (#6266, #6267, #6269, #6270)

    use: [
      contextCompression({
        maxInputTokens: 80000,
        deduplicateToolResponses: { matchBy: 'name-and-input' },
        toolResponses: { maxChars: 2000, preserveRecent: 2 },
        summarize: { model: googleAI.model('gemini-flash-lite-latest'), preserveRecent: 6 },
      }),
    ]
    

    Gemini: Interactions API, Gemini 4 Argon, Omni and more

    • The googleAI plugin now sends requests for -latest aliases, newer Gemini models and any model it doesn't know to the Interactions API. Older built-in models stay on generateContent. (#6344)
    • The vertexAI plugin routes the same way, with one difference: image models and the -latest aliases stay on generateContent. (#6851)
    • New models: gemini-4-argon, gemini-3.8-flash, gemini-3.8-flash-tts, gemini-3.8-flash-lite-tts, gemini-nano-banana-2.1, gemini-omni-1.1-flash (replaces Veo 3.1), lyria-3.5 and antigravity-preview-09-2026. Gemini 2.5 and the retiring preview models are now hidden: they still work but no longer show up in autocomplete. (#6807)
    • vertexAI gets the same model updates, plus text-to-speech, Omni video generation and the gemini-embedding-2 embedder. (#6859)

    Breaking for models on the Interactions API: response.raw/custom now has a different shape. safetySettings, toolConfig, thinkingBudget and candidates > 1 are dro

  5. go/v1.14.0Genkit Go v1.14.02026-10-20 · 2026-10-20 18:07 UTC
    查看更新说明

    Tools and interrupts are stable and typed end to end. A tool that pauses is resumed with the type it declared, a tool error can go back to the model to fix, and an approval can be decided by a judge model or refused with a reason. Every run reports what it spent, a budget can stop or pause it, and context compression keeps long tool loops inside the window. Agents can delegate to agents that other Genkit apps serve, sessions persist in PostgreSQL, and telemetry plugs in with or without OpenTelemetry. A preview plugin adds decision models.

    go get github.com/firebase/genkit/[email protected]
    

    Tools that pause are resumed by type

    genkit.DefineResumableTool declares a third type: what the tool is resumed with. The tool gets it as a pointer, nil on the first call. The caller claims each paused call with the tool's Interrupted method, which matches the part to the tool and decodes its input, so nothing after the claim can fail.

    Before: the caller matches tools by name, reads the input as an untyped map, and the tool reads its answer back one key at a time.

    transferMoney := genkit.DefineTool(g, "transferMoney", "...",
    	func(tc *ai.ToolContext, in TransferInput) (*TransferOutput, error) {
    		if !tc.IsResumed() && in.Amount > approvalLimit {
    			return nil, ai.InterruptWith(tc, map[string]any{"reason": "over_limit"})
    		}
    		if approved, ok := ai.ResumedValue[bool](tc, "approved"); ok && !approved {
    			return &TransferOutput{Status: "declined"}, nil
    		}
    		// ...
    	})
    
    var restarts []*ai.Part
    for _, part := range resp.Interrupts() {
    	switch part.ToolRequest.Name {
    	case transferMoney.Name():
    		in := part.ToolRequest.Input.(map[string]any) // untyped on the part
    		approved := askHuman(in["amount"].(float64), in["toAccount"].(string))
    		restart, err := transferMoney.RestartWith(part,
    			ai.WithResumedMetadata[TransferInput](map[string]any{"approved": approved}))
    		if err != nil {
    			return nil, err
    		}
    		restarts = append(restarts, restart)
    	}
    }
    resp, err = genkit.Generate(ctx, g,
    	ai.WithMessages(resp.History()...), ai.WithTools(transferMoney), ai.WithToolRestarts(restarts...))
    

    After: the claim does the match and the type check, and the answer has one type at both ends.

    transferMoney := genkit.DefineResumableTool(g, "transferMoney", "Transfers money to another account.",
    	func(ctx context.Context, in TransferInput, resume *Confirmation) (*TransferOutput, error) {
    		if resume == nil && in.Amount > approvalLimit {
    			return nil, tool.Interrupt(ctx, map[string]any{"reason": "over_limit"})
    		}
    		if resume != nil && !resume.Approved {
    			return &TransferOutput{Status: "declined"}, nil
    		}
    		// ...
    	})
    
    var parts []*ai.Part
    for _, part := range resp.Interrupts() {
    	if call, ok := transferMoney.Interrupted(part); ok {
    		approved := askHuman(call.Input.Amount, call.Input.ToAccount) // TransferInput, decoded
    		parts = append(parts, call.Restart(Confirmation{Approved: approved}))
    	}
    }
    resp, err = genkit.Generate(ctx, g,
    	ai.WithMessages(resp.History()...), ai.WithTools(transferMoney), ai.WithResume(parts...))
    

    call.Respond(out) answers without running the tool again, and call.RestartWithInput(in, res) runs it with revised arguments, which history then records as the request. The tool reads the input it was first called with through tool.OriginalInput[In](ctx). Code that holds only the part, such as a generic handler, builds the same parts untyped with part.ToToolRestart, part.ToToolRestartWithInput, and part.ToToolResponse: the payload is checked against the resumeSchema the tool advertises and decoded into the resume type, so a map with the right fields behaves like the typed value, in process or after a wire hop.

    The resume is checked as a whole before any tool runs. A restart that would charge a card no longer runs while a sibling request fails the resume, and WithResume rejects a part that is still paused, such as `r

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Genkit logo Genkit logo

    Genkit is an open-source framework for building full-stack AI-powered applications, built and used in production by Google's Firebase. It provides SDKs for multiple programming languages with varying levels of stability:

    • JavaScript/TypeScript: Production-ready with full feature support
    • Go: Production-ready with full feature support
    • Python (Beta): Wide feature support approaching production-readiness
    • Dart (Preview): Early development with core functionality

    It offers a unified interface for integrating AI models from providers like Google, OpenAI, Anthropic, Ollama, and more. Rapidly build and deploy production-ready chatbots, automations, and recommendation systems using streamlined APIs for multimodal content, structured outputs, tool calling, and agentic workflows.

    Building with a coding agent? Install the Genkit skill first.

    npx skills add genkit-ai/skills --skill developing-genkit-js      # JavaScript/TypeScript
    npx skills add genkit-ai/skills --skill developing-genkit-go      # Go
    npx skills add genkit-ai/skills --skill developing-genkit-python  # Python
    npx skills add genkit-ai/skills --skill developing-genkit-dart    # Dart
    

    It teaches your agent the current Genkit APIs and common gotchas. Source and manual install: genkit-ai/skills.

    Get started with just a few lines of code:

    import { genkit } from 'genkit';
    import { googleAI } from '@genkit-ai/google-genai';
    
    const ai = genkit({ plugins: [googleAI()] });
    
    const { text } = await ai.generate({
        model: googleAI.model('gemini-flash-latest'),
        prompt: 'What is the meaning of life?'
    });
    

    Explore & build with Genkit

    Play with AI sample apps, with visualizations of the Genkit code that powers them, at no cost to you.

    Explore Genkit by Example

    Key capabilities

    How does it work?

    Genkit simplifies AI integration with an open-source SDK and unified APIs that work across various model providers and programming languages. It abstracts away complexity so you can focus on delivering great user experiences.

    Some key features offered by Genkit include:

    Genkit is designed for server-side deployment in multiple language environments, and also provides seamless client-side integration through dedicated helpers and client SDKs.

    Implementation path

    Get started

    Development tools

    Genkit provides a CLI and a local UI to streamline your AI development workflow.

    CLI

    The Genkit CLI includes commands for running and evaluating your Genkit functions (flows) and collecting telemetry and logs.

    • Install: npm install -g genkit-cli
    • Run a command, wrapped with telemetry, a interactive developer UI, etc: genkit start -- <command to run your code>

    Developer UI

    The Genkit developer UI is a local interface for testing, debugging, and iterating on your AI application.

    Key features:

    • Run: Execute and experiment with Genkit flows, prompts, queries, and more in dedicated playgrounds.
    • Inspect: Analyze detailed traces of past executions, including step-by-step breakdowns of complex flows.
    • Evaluate: Review the results of evaluations run against your flows, including performance metrics and links to relevant traces.

    Connect with us

    Ask DeepWiki

    Contributing

    Contributions to Genkit are welcome and highly appreciated! See our Contribution Guide to get started.

    Authors

    Genkit is built by Google with contributions from the Open Source Community.