We'd love to accept your patches and contributions to this project.
Contributions to this project must be accompanied by a Contributor License Agreement (CLA). You (or your employer) retain the copyright to your contribution; this simply gives us permission to use and redistribute your contributions as part of the project.
If you or your current employer have already signed the Google CLA (even if it was for a different project), you probably don't need to do it again.
Visit https://cla.developers.google.com/ to see your current agreements or to sign a new one.
This project follows Google's Open Source Community Guidelines.
All submissions, including submissions by project members, require review. We use GitHub pull requests for this purpose. Consult GitHub Help for more information on using pull requests.
Genkit supports JavaScript, Go, and Python. Before contributing in any of these languages, complete these prerequisites:
-
Install Node.js 20 or later using nvm
Note: Node.js v20 or greater is required. Earlier versions may not work properly.
-
Install the Genkit CLI globally:
npm install -g genkit-cli
After completing these prerequisites, follow the language-specific setup instructions below.
-
Install Go 1.24 or later Follow the official Go installation guide.
-
Configure your AI model Most samples use Google's Gemini model. You'll need to generate an API key at Google AI Studio.
Once you have your key, set it in your environment:
export GOOGLE_GENAI_API_KEY=<your-api-key>
-
Run a sample application
cd go/samples # Navigate to samples directory cd <sample-name> # Choose a sample to run go mod tidy # Install Go dependencies genkit start -- go run . # Start the Genkit server and run the application
Once running, visit http://localhost:4000 to access the Developer UI.
-
Run tests
cd <test-directory> # Navigate to test directory go test . # Run tests in current directory
Run corepack enable pnpm to enable pnpm.
pnpm i
pnpm run setup
This will install all dependencies and build all packages.
pnpm build
This will build all packages in this repository. This is recommended the first time you check out a fresh repo or pull new revisions.
Pack packages for testing/distribution.
Assuming you built everything previously....
pnpm pack:all
This will produce tarballs in the dist folder. Also genkit-dist.zip -- a zip of all the package tarballs.
You will need the Genkit CLI to run test apps and the Developer UI (this is done for you with pnpm run setup):
pnpm link-genkit-cli
In the js/testapps folder you will find some test apps using Genkit. They might contain instructions for how to run them and what setup is necessary.
Here's one that requires no setup:
cd js/testapps/flow-sample1
genkit start -- tsx --watch src/index.ts
Point your browser to http://localhost:4000
We'll be using the pdfQA flow for our example.
To start, let's make sure we have some context to pull from the vector store.
- Start the Developer UI
cd js/testapps/evals
genkit start -- pnpm genkit:dev
- Click on the
indexPdfflow in the left nav. - Input paths to pdfs you want to index. There's one checked into the directory:
"./docs/cat-handbook.pdf"
- Run an evaluation on a sample dataset checked into the testapp
genkit eval:flow pdfQA --input ./data/cat_adoption_questions.json
- Go to the Evaluations tab in the Developer UI to view the evaluation results.
FYI: js and genkit-tools are in two separate workspaces.
As you make changes you may want to build and test things by running test apps. You can reduce the scope of what you're building by running a specific build command:
pnpm build:genkit
pnpm build:genkit-tools
But you can also go into specific package that you changed and run
pnpm build
If you are going to be coding for a while then do
pnpm build:watch
in the package that you're editing.
If you are contributing to the core Genkit JS SDK (under the /js directory), please make sure that all exported members have a valid JSDoc associated with them.
Use the following command to build and view the new API reference locally.
cd js && pnpm build && pnpm typedoc-html && open api-refs-js/index.html
-
Create a Branch: Create a new branch for your feature or bug fix.
git checkout -b your-name/my-feature-branch
-
Format and Build: Before submitting a pull request, ensure your changes are formatted and build cleanly:
pnpm format pnpm build
-
Commit Your Changes: Make your changes and commit them using Conventional Commits. Both commit messages and Pull Request titles must include a type and a scope:
<type>(<scope>): <description>Examples:
feat(js/ai): add support for custom tool output handlersfix(go/plugins/googlegenai): default ResponseModalities for image modelschore(global): update root formatting configuration
Common types include:
feat: A new featurefix: A bug fixdocs: Documentation only changesstyle: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc.)refactor: A code change that neither fixes a bug nor adds a featureperf: A code change that improves performancetest: Adding missing tests or correcting existing testsbuild: Changes that affect the build system or external dependenciesci: Changes to CI configuration files and scriptschore: Changes to the build process or auxiliary tools and libraries that don't modify source or test filesrevert: Reverts a previous commit
-
Open a Pull Request: Submit your pull request to the
mainbranch. Provide a clear description of the changes and link to any related issues.
- Keep it Focused: A pull request should ideally do one thing. If you have multiple unrelated changes, please split them into separate PRs.
- Update Documentation: If your changes introduce new features or change existing behavior, please update the relevant documentation and code comments as necessary.
- Test Your Changes: Ensure that your changes are well-tested and don't break existing functionality.