AI SDKs
Vercel AI SDK
Agentic adapter for the Vercel AI SDK.
- package:
@agentic/ai-sdk
- exports:
function createAISDKTools
- source
- Vercel AI SDK docs
Install
Usage
This example also requires you to install @ai-sdk/openai
.
import 'dotenv/config'
import { createAISDKTools } from '@agentic/ai-sdk'
import { WeatherClient } from '@agentic/weather'
import { openai } from '@ai-sdk/openai'
import { generateText } from 'ai'
async function main() {
const weather = new WeatherClient()
const result = await generateText({
model: openai('gpt-4o-mini'),
tools: createAISDKTools(weather),
toolChoice: 'required',
temperature: 0,
system: 'You are a helpful assistant. Be as concise as possible.',
prompt: 'What is the weather in San Francisco?'
})
console.log(result.toolResults[0])
}
await main()
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/ai-sdk/bin/weather.ts