Install
npm install @agentic/mastra @mastra/core
Usage
import 'dotenv/config'
import { createMastraTools } from '@agentic/mastra'
import { WeatherClient } from '@agentic/weather'
import { openai } from '@ai-sdk/openai'
import { Agent } from '@mastra/core/agent'
async function main() {
const weather = new WeatherClient()
const weatherAgent = new Agent({
name: 'Weather Agent',
instructions: 'You are a helpful assistant. Be as concise as possible.',
model: openai('gpt-4o-mini'),
tools: createMastraTools(weather)
})
const res = await weatherAgent.generate(
'What is the weather in San Francisco?'
)
console.log(res.text)
}
await main()
Note that this example snippet also requires you to install the AI SDK’s OpenAI provider, the Agentic weather tool, and dotenv
.
npm install @ai-sdk/openai @agentic/weather dotenv
Running this example
You’ll need a free API key from weatherapi.com
to run this example. Store it in a local .env
file as WEATHER_API_KEY
.
You’ll need an OpenAI API key
to run this example. Store it in a local .env
file as OPENAI_API_KEY
.
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/mastra/bin/weather.ts