genkit

Activity, over time

Daily observations from the public event archive.

Attention

Daily stars & forks

Loading attention chart

Star accumulation

Cumulative stars

Loading star accumulation chart

Pull requests

Daily opens & merges

Loading pull requests chart

Conversations

Daily issues & comments

Loading conversations chart

Community

Daily accounts & reviews

Loading community chart

Releases

Daily releases

Loading releases chart

Mentions

2posts · 30d
Nov 30 posts
  1. Extracting structured data from PDFs using Gemini 2.0 and Genkit in Firebase: Web Architecture & Implementation Guide Original: codingcat.dev Building AI features in TypeScript or Go quickly turns into spaghetti when you try to bolt structured output validation, tool calling, and OpenTelemetry tracing onto raw model API calls. Following the announcement of Extracting structured data from PDFs using Gemini 2.0 and Genkit by Peter Friese on the Official Firebase Blog (2025-02-20), here is our hands-on CodingCat.dev breakdown of what actually shipped, how it works under the hood, and how we wire it into production TypeScript, Next.js, Astro, SvelteKit, React, and Angular applications. Last week, Google released Gemini 2.0, and after reading this blog post about parsing PDFs using Gemini 2.0, I decided to rebuild the sample using Genkit. The Mental Model: Why Extracting structured data from PDFs using Gemini 2.0 and Genkit Matters for Web Devs As a Google Developer Expert (GDE) for Firebase and Senior Solutions Engineer at CodingCat.dev, I evaluate every Firebase update through one lens: does it reduce boilerplate while keeping our runtime security and cloud bills predictable? Firebase Genkit gives full-stack engineers strongly typed flows, dotprompt templates, local developer UI trace inspection, and production observability wired directly into Google Cloud and Firebase. > AJ Pro-Tip from Alex: Always wrap your Genkit flows with explicit Zod input/output schemas and enforce Firebase App Check attestation on callable endpoints so bots cannot rack up unauthenticated token spend. How It Works: Technical Breakdown & Implementation For those who are unfamiliar, Genkit is an AI integration framework that makes implementing AI features for your apps easier. In this blog post, I am going to focus on Genkit for Node.js, but the team is also working on building support for Go (available in alpha) and Python (under development). This means you can use Genkit on any runtime that supports one of those three languages. The sample app I’m discussing in this blog post is a simple command-line utility that you can run on macOS or any other platform that supports Node.js, but you can also use Genkit on the backend, for example in Cloud Functions for Firebase, Cloud Run, or any other environment that supports Node.js. Setup Before you can use Gemini 2.0 Flash in Genkit, you need to install and add Genkit and the Google AI SDK plugin for Genkit. You can then instantiate Genkit and define a default model. This model will then be used in all subsequent calls you make via the ai instance. import import // instantiate Genkit const plugins: [ model: gemini20Flash, }); For a detailed walkthrough of the setup process, check out this video: Extracting structured data In this first example, let’s look at how you can use Gemini 2.0 Flash and Genkit to extract structured data from PDFs. Let’s imagine you’ve received a PDF with an invoice. To further process the invoice, you need to extract the invoice number, date, all the line items (including description, amount, and their individual price), as well as the gross price of the invoice. Thanks to Gemini’s vision capabilities, we can let it handle the OCR for us. The following code snippet shows how to call any LLM via Genkit’s unified generation API, and pass a multimodal prompt (including a URL to the PDF file we want to analyse as well as an instruction). export const prompt: [ { media: { url } }, { text: ] }); return } If you’d call this method now for example by passing this URL (which points to an invoice), you’d get the following result: [ { 'Invoice no': ' 'Date of issue': ' Seller: { Name: 'Williams LLC', Address: ' Tax Id': ' IBAN: 'GB }, Client: { Name: 'Hernandez-Anderson', Address: ' 'Tax Id': ' }, Items: [ [Object], [Object], [Object], [Object], [Object], [Object], [Object] ], Summary: { 'VAT [%]': ' 'Net worth': ' VAT: ' 'Gross worth': ' Total: '$ 'Total VAT': '$ 'Total Gross worth': '$ } } ] Which is pretty impressive - after all, the model was able to correctly extract all information. However, this might not be in the format you need this in. This is where Genkit’s support for structured output comes in handy. You can define a schema for your data using Zod, like this: export const prompt: [ { media: { url } }, { text: ] }); return } Then, pass the schema to Genkit’s generate call to enforce this schema. export const prompt: [ { media: { url } }, { text: ], }); return } And now, calling the function with the same PDF file will yield the following result: { date: ' invoiceNumber: ' items: [ { description: 'Lilly Pulitzer dress Size grossWorth: quantity: }, { description: 'New ERIN Erin Fertherston Straight Dress White Sequence Lining Sleeveless SZ grossWorth: quantity: }, { description: 'Sequence dress Size Small', grossWorth: quantity: }, { description: 'fire los angeles dress Medium', grossWorth: quantity: }, { description: grossWorth: quantity: }, { description: 'Lularoe Nicole Dress Size Small Light Solid Grey/ White Ringer Tee Trim', grossWorth: quantity: }, { description: 'J.Crew Collection Black & White sweater Dress sz S', grossWorth: quantity: } ], totalGrossWorth: } Since this adheres to the schema we provided, it will be much easier to process. Gemini 2.0 Flash supports structured output, but even if you’re using an LLM that doesn’t support natively structured output, Genkit can help by augmenting the prompt and coercing the returned data for you. What’s really amazing about this: you won’t have to change your code, thanks to Genkit’s unified generation API (check out this thread on Bluesky in which I demonstrate this). Parsing hand-written form input I mentioned Gemini’s OCR capabilities, so let’s try extracting the hand-written entries in the following PDF: One way to achieve this would be to define a new schema and then call Genkit’s generate method using this new schema. But there is a more flexible way to do this. It turns out that the actual code for calling Gemini to extract data from a PDF is always the same - only the output format (and potentially the instructions) change for each type of PDF we want to analyse. So why not make this a bit more generic? Genkit provides a way to extract prompts into external files, using the Dotprompt library. This allows you to keep your code free from any prompt, making it easier to change the prompt independently of the code. --- model input schema pdfUrl default pdfUrl output schema formNumber startDate beginningOfYear endOfYear name address phoneNumber ein --- Extract the hand-written form data. {{media url This prompt file defines the model Genkit should use (Gemini 2.0 Flash), as well as the prompt itself. But it also specifies the input and output schemas for the prompt. For example, under input/schema, we define an input parameter named pdfUrl of type string, which can then be used in the prompt to pass the URL. Likewise, under output/schema, we define all the keys we want to extract from the PDF file, including their types. Note that the descriptions of the keys do not just serve the purpose of documentation - Genkit will use them in the prompt to specifically tell the model how to find the data for the respective keys. To load a prompt from a file, use ai.prompt(filename). This has a beneficial side effect: we can now create.prompt files for all the different types of data we want to extract from PDF files, and just pass the filename to the extract function: export const const return } Instead of using ai.generate() to call the LLM, you can execute a prompt by caling the prompt itself, and passing the required parameters. Calling this method using extract("form", "https://storage.googleapis.com/generativeai-downloads/data/pdf_structured_outputs/handwriting_form.pdf") will yield the following result: { address: ' beginningOfYear: ein: ' endOfYear: formNumber: 'CA name: 'Annual Return Plan', phoneNumber: ' startDate: ' } Which - if you ask me - is mind-boggling. Where to go from here To learn more about Genkit, check out the documentation. Also, feel free to drop by my weekly livestreams - I’m currently working on implementing a Second Brain app, and I’m using Genkit for some of the AI-powered features. If you’d like to try out the sample app, the source code is available on GitHub. Production Web Architecture & Security Checklist Whether we are deploying on Firebase App Hosting, Cloudflare Workers, or Vercel, shipping AI features to production requires defense-in-depth across three layers: - Enforce Firebase App Check & Attestation: **Protect your web endpoints, Cloud Functions, Data Connect GraphQL resolvers, and Firebase AI Logic calls against unauthorized replay or billing abuse using Firebase App Check with reCAPTCHA Enterprise**. - **Validate Locally with the Firebase Emulator Suite: **Run deterministic integration tests against local Firestore, Auth, Functions, and Data Connect PostgreSQL emulators before promoting schema or rule changes to production. - **Keep Server & Client Boundaries Type-Safe: **Use the modular Firebase Web SDK and generated TypeScript bindings so SSR frameworks like Next.js, Astro, SvelteKit, and Angular serialize state cleanly without hydration flickers. Conclusion Accelerate your full-stack web and AI development by pairing Extracting structured data from PDFs using Gemini 2.0 and Genkit with strict Security Rules, Firebase App Check, and local emulator testing. Come tell us on X (@CodingCatDev) and LinkedIn (CodingCat.dev) how you are using Firebase in your stack, and subscribe to the CodingCat.dev YouTube Channel so you don't miss what we build next! Watch Our Related Firebase Video Tutorial on YouTube Want to see how we architect and debug Firebase web applications live? Watch our related CodingCat.dev session Firebase SQL with Data Connect below, and make sure to Subscribe to CodingCat.dev on YouTube for weekly full-stack web and AI deep dives: {% youtube N25khadfUag %} Resources, Official Docs & Related CodingCat.dev Guides - Primary Release Source: **Extracting structured data from PDFs using Gemini 2.0 and Genkit on the Official Firebase Blog (published 2025-02-20 by Peter Friese) - **Official Firebase Documentation: **Firebase Developer Docs & Web SDK Reference - **Related on CodingCat.dev: Announcing Firebase Genkit 1.0 for Node.js - Related on CodingCat.dev: Firebase + Gemini Code Assist - Related on CodingCat.dev: Firebase SQL with Data Connect - Related on CodingCat.dev: Build a Custom No-Code App in 90 Minutes Frequently Asked Questions (FAQ) What are the key capabilities introduced in Extracting structured data from PDFs using Gemini 2.0 and Genkit? Extracting structured data from PDFs using Gemini 2.0 and Genkit (announced 2025-02-20 by the Firebase team) enhances the platform for Firebase, Google Cloud, Web Dev, AI, TypeScript, Serverless workloads. Last week, Google released Gemini 2.0, and after reading this blog post about parsing PDFs using Gemini 2.0, I decided to rebuild the sample using Genkit. Developers can review the primary announcement on the Firebase Blog alongside our implementation patterns and production checklist above. How do web developers use Extracting structured data from PDFs using Gemini 2.0 and Genkit with Next.js, SvelteKit, React, or Angular? Web developers can integrate these features using the modular Firebase JavaScript/TypeScript SDK, Firebase Data Connect web bindings, and Firebase App Hosting. Always pair client-side SDK initialization with Firebase App Check and strict Security Rules, and test locally with the Firebase Local Emulator Suite before deploying. Where can I watch video tutorials on Firebase Web and AI development? You can watch our hands-on Firebase video walkthroughs on the CodingCat.dev YouTube Channel, including Firebase SQL with Data Connect, and follow us on X (@CodingCatDev) for weekly full-stack tutorials.

  2. Announcing Genkit for Python and Go in Firebase: Web Architecture & Implementation Guide Original: codingcat.dev Announcing Genkit for Python and Go **marks an important milestone for full-stack web and AI engineers building on Firebase and Google Cloud. Following the official announcement by Chris Gill, Peter Friese on the Firebase Blog** (2025-04-09), this hands-on CodingCat.dev implementation guide breaks down how to adopt these capabilities in modern TypeScript, Next.js, SvelteKit, React, and Angular applications. Building intelligent features into your apps can be complex. Testing models, building prompts, and debugging your solution are all real challenges when building apps powered by large language models. We built Genkit to help you with these challenges. Genkit is an open-source framework with built-in tooling and observab Why Announcing Genkit for Python and Go Matters for Full-Stack Web Developers When evaluating every new Firebase release for our production web apps and Google Developer Expert (GDE) architecture reviews, the first question is always how it improves developer velocity, runtime security, and end-user latency in the browser and on the server. Building intelligent features into your apps can be complex. Testing models, building prompts, and debugging your solution are all real challenges when building apps powered by large language models. We built Genkit to help you with these challenges. Genkit is an open-source framework with built-in tooling and observability. Together, these capabilities provide both a unified API to build your app using a variety of AI models from Google, OpenAI, Anthropic, and open models through Ollama, etc. While you’re building the app, you’ll also get the tooling needed to help you iterate quickly on your solution and debug common problems, as well as the observability you need to monitor your app in production once you deploy to Google Cloud or Firebase. Earlier this year, we announced our stable release of Genkit for Node.js, and today we’re thrilled to announce the expansion of Genkit’s language support with Genkit for Python (Alpha) and Go (Beta). These new SDKs bring Genkit’s powerful capabilities to even more developer ecosystems: - Genkit for Python (Alpha) is ideal for experimentation and early development. The API may evolve rapidly as we incorporate your feedback, but all essential capabilities are available to start building today. - Genkit for Go (Beta) has a rich feature set, and increased reliability as it approaches production readiness. Whether you’re using Node.js, Python, or Go, you can now leverage Genkit’s consistent tools and concepts to build sophisticated AI-powered features with robust primitives, integrated tooling, and an extensible plugin system that simplifies prototyping, building, and deploying AI workflows. We’re also excited about partners that build plug-ins for Genkit such as Pinecone, Astra DB, Neo4j, AuthO, and others. This growing ecosystem of plugins significantly expands Genkit’s capabilities, letting you to seamlessly integrate a wide array of specialized tools and services into their AI-powered applications. **Note: **Both SDKs are still in versions <1.0.0 and may have breaking changes without major version increments as we refine the APIs based on your feedback. Genkit for Python (Alpha) If you’re building with Python, Genkit has intuitive and concise syntax for working with AI capabilities. The Python SDK offers a clean, asynchronous API with strong typing support through Pydantic integration. Python’s data class capabilities, enhanced by Pydantic for schema definition, shine in this Genkit example for structured output. Notice how the RpgCharacter class clearly defines the expected format, ensuring the structured_character_flow consistently returns AI-generated data in this predictable structure. from from from ai plugins model ) class name: backstory: abilities: list[ @ async """ result prompt output_schema ) return Genkit is also designed with intuitive and concise syntax for defining tools, as illustrated in this example. Leveraging decorators and Pydantic for data modeling, creating a tool like convert_currency and integrating it into an asynchronous flow becomes straightforward. # Imports and initialization omitted for brevity class amount: @ async """ print return @ async """ response prompt tools ) return - Google GenAI: Access Google’s Gemini, Imagen, embedding models from Google AI Studio or Google Cloud Vertex AI. - Ollama: Run open models like Gemma, Llama, and Mistral locally. - Flask Integration: Easily serve your Genkit flows via a Flask web server. - Firestore: Ground your generations with data retrieved using Firestore vector search. Genkit for Go (Beta) If you’re building with Go, Genkit offers a robust and explicit API with strong type safety, making it suitable for building scalable applications approaching production readiness. This Go snippet illustrates Genkit’s approach to guaranteeing structured output by explicitly defining a RpgCharacter struct and using ai.WithOutputType. Observe how the characterPrompt is configured with the desired output type, ensuring the structuredCharacterFlow reliably produces data conforming to the specified schema. package import " " " " " " " ) type Name Backstory Abilities [] } func ctx g, err genkit. genkit. ) if log. } characterPrompt, _ ai. ai. ai. ) genkit. func resp, err if return } var if return } return }, ) mux for mux. } log. } Run the Go app and call your flow using: curl -X POST localhost:8080/structuredCharacterFlow \ -H "Content-Type: application/json" \ -d '{"data": "Elara"}' Genkit offers a robust and explicit way to define and integrate custom tools into your AI workflows, as shown below. This example clearly demonstrates the registration of the convertCurrencyTool and its use within the convertCurrencyFlow, emphasizing Go’s type safety and suitability for building scalable applications. // Imports omitted for brevity func ctx g, err if log. } convertCurrencyTool " func log. return }, ) flow func return ai. ai. ai. ) }, ) mux mux. log. } curl -X POST localhost:8080/convertCurrencyFlow \ -H "Content-Type: application/json" \ -d '{"data": 190.00}' - Google GenAI: Access Gemini models and embeddings. - Google Cloud Vertex AI: Integrate with Google Cloud’s AI platform. - Ollama: Run open models locally. - Pinecone: Connect to Pinecone’s vector database. - pgvector: Integrate with PostgreSQL vector storage. - Google Cloud Telemetry: Export observability data. Developer tooling for rapid iteration Building AI applications involves unique challenges. Genkit provides dedicated tooling, consistent across Python, Go, and Node.js, to accelerate testing and development. Our CLI and intuitive browser-based **Developer UI **help you: - Experiment Faster: Interactively run and iterate on your flows, prompts, and tools in dedicated playgrounds within the UI - Debug Efficiently: Visualize detailed execution traces, inspect inputs/outputs (including structured data), view logs, and understand exactly how your flows are executing - Evaluate Confidently: Test your AI workflows against predefined datasets and analyze scored metrics to ensure quality and reliability Launch the Developer UI by running your app like so: - Go: genkit start, go run main.go - Python: genkit start, python main.py Get started Ready to build your next AI-powered application? Explore our comprehensive documentation and resources: - Python: Get Started with Genkit for Python (Alpha - Great for experimentation!) - Go: Get Started with Genkit for Go (Beta - Maturing towards production-readiness!) What’s next? We are committed to continuously evolving and improving Genkit across all supported languages. We are actively working towards bringing Genkit for Python and Go to feature parity with Genkit for Node.js, as well as embracing language-specific benefits and integration. Got questions or feedback? Join us on our Discord server, or Stack Overflow. For feature requests and bug reports, hit us up on the GitHub issue tracker. Join our community, share your feedback, and help shape the future of Genkit! Whether you’re developing in Python or Go, now is the perfect time to explore the possibilities of building intelligent, agentive applications with Genkit. Happy coding, and we look forward to seeing what you create! Production Web Architecture & Security Checklist Whether you are deploying on Firebase App Hosting, Cloudflare Workers, or Vercel, shipping AI features to production requires defense-in-depth across three layers: - Enforce Firebase App Check & Attestation: **Protect your web endpoints, Cloud Functions, Data Connect GraphQL resolvers, and Firebase AI Logic calls against unauthorized replay or billing abuse using Firebase App Check with reCAPTCHA Enterprise**. - **Validate Locally with the Firebase Emulator Suite: **Run deterministic integration tests against local Firestore, Auth, Functions, and Data Connect PostgreSQL emulators before promoting schema or rule changes to production. - **Keep Server & Client Boundaries Type-Safe: **Use the modular Firebase Web SDK and generated TypeScript bindings so SSR frameworks like Next.js, SvelteKit, and Angular serialize state cleanly without hydration flickers. Watch Our Related Firebase Video Tutorial on YouTube Want to see how we architect and debug Firebase web applications live? Watch our related CodingCat.dev session Firebase SQL with Data Connect below, and make sure to Subscribe to CodingCat.dev on YouTube for weekly full-stack web and AI deep dives: {% youtube N25khadfUag %} Resources, Official Docs & Related CodingCat.dev Guides - Primary Release Source: **Announcing Genkit for Python and Go on the Official Firebase Blog (published 2025-04-09 by Chris Gill, Peter Friese) - **Official Firebase Documentation: **Firebase Developer Docs & Web SDK Reference - **Related on CodingCat.dev: Data Connect is now generally available! - Related on CodingCat.dev: Introducing Firebase Studio - Related on CodingCat.dev: Firebase SQL with Data Connect - Related on CodingCat.dev: Build a Custom No-Code App in 90 Minutes Frequently Asked Questions (FAQ) What are the key capabilities introduced in Announcing Genkit for Python and Go? Announcing Genkit for Python and Go (announced 2025-04-09) enhances the Firebase platform for Firebase, Google Cloud, Web Dev, AI, TypeScript workloads. Building intelligent features into your apps can be complex. Testing models, building prompts, and debugging your solution are all real challenges when building apps powered by large language models. Developers can review the official release notes on the Firebase Blog alongside the implementation patterns in this guide. How do web developers use Announcing Genkit for Python and Go with Next.js, SvelteKit, React, or Angular? Web developers can integrate these features using the modular Firebase JavaScript/TypeScript SDK, Firebase Data Connect web bindings, and Firebase App Hosting. Always pair client-side SDK initialization with Firebase App Check and strict Security Rules, and test locally with the Firebase Local Emulator Suite before deploying. Where can I watch video tutorials on Firebase Web and AI development? You can watch our hands-on Firebase video walkthroughs on the CodingCat.dev YouTube Channel, including Firebase SQL with Data Connect, and browse our complete Firebase tutorial archive on CodingCat.dev.

Latest stargazers

The last 10 distinct accounts we observed this year.

Most active participants

PR, issue, comment & review events in the past year.

Packages

Scan pending.

README badges

Embed a badge in your README or website.

Live mentions · last 30 days
firebase/genkit mentions in the last 30 days