mirror of
https://github.com/humanlayer/humanlayer.git
synced 2025-08-20 19:01:22 +03:00
HumanLayer + Vercel AI SDK example
Overview
This example demonstrates how to use HumanLayer with the Vercel AI SDK in Typescript.
It makes use of the humanlayer-ts-vercel-ai-sdk package, which includes methods
specifically for wrapping/integrating w/ the Vercel AI SDK tools system.
There are two examples:
npm run mathwill run a math problem, whereaddcan be called without approval, butmultiplyrequires approval.
for the multiply operation, approval will be requested
npm run human-as-toolwill run a prompt where the model should select the "contact a human" tool, which will fetch a human response via humanlayer
since the prompt is not clear, the model will ask for clarification
Running the Example
Set up env
Get a HumanLayer API key from HumanLayer and an OpenAI API key from OpenAI
cp dotenv.example .env
# configure API token(s)
HUMANLAYER_API_KEY=
OPENAI_API_KEY=
Running with NPM
npm install
npm run math
npm run human-as-tool



