2024-08-17 11:03:17 +00:00
---
title: Genkit
description: Agentic adapter for the Firebase Genkit SDK.
---
- package: `@agentic/genkit`
- exports: `function createGenkitTools`
- [source](https://github.com/transitive-bullshit/agentic/blob/main/packages/genkit/src/genkit.ts)
- [Firebase Genkit docs](https://firebase.google.com/docs/genkit)
## Install
<CodeGroup>
```bash npm
2025-02-19 14:16:07 +00:00
npm install @agentic/genkit genkit
2024-08-17 11:03:17 +00:00
```
```bash yarn
2025-02-19 14:16:07 +00:00
yarn add @agentic/genkit genkit
2024-08-17 11:03:17 +00:00
```
```bash pnpm
2025-02-19 14:16:07 +00:00
pnpm add @agentic/genkit genkit
2024-08-17 11:03:17 +00:00
```
</CodeGroup>
## Usage
This example also requires you to install the [genkitx-openai](https://github.com/TheFireCo/genkit-plugins/tree/main/plugins/openai) package, which adds support for OpenAI to Genkit.
```ts
import 'dotenv/config'
import { createGenkitTools } from '@agentic/genkit'
import { WeatherClient } from '@agentic/stdlib'
2025-02-19 14:16:07 +00:00
import { genkit } from 'genkit'
2024-08-17 11:03:17 +00:00
import { gpt4oMini, openAI } from 'genkitx-openai'
async function main() {
const weather = new WeatherClient()
2025-02-19 14:16:07 +00:00
const ai = genkit({
2024-08-17 11:03:17 +00:00
plugins: [openAI()]
})
2025-02-19 14:16:07 +00:00
const result = await ai.generate({
2024-08-17 11:03:17 +00:00
model: gpt4oMini,
2025-02-19 14:16:07 +00:00
tools: createGenkitTools(ai, weather),
system: 'You are a helpful assistant. Be as concise as possible.',
2024-08-17 11:03:17 +00:00
prompt: 'What is the weather in San Francisco?'
})
console.log(result)
}
await main()
```
## Running this example
<Info>
You'll need a free API key from [weatherapi.com](https://www.weatherapi.com)
to run this example. Store it in a local `.env` file as `WEATHER_API_KEY`.
</Info>
<Info>
You'll need an [OpenAI API key](https://platform.openai.com/docs/quickstart)
to run this example. Store it in a local `.env` file as `OPENAI_API_KEY`.
</Info>
```sh
git clone git@github.com:transitive-bullshit/agentic.git
cd agentic
pnpm install
echo 'WEATHER_API_KEY=your-key' >> .env
echo 'OPENAI_API_KEY=your-key' >> .env
npx tsx examples/genkit/bin/weather.ts
```