Vercel AI SDK
Code execution for Vercel AI SDK Agents
Get your Freestyle API Key from the Freestyle Dashboard
Set up the Code Executor
The simplest code executor looks like this:
You can also pass in any nodeModules, environment variables, timeout, or network restrictions you need.
Here's an example with access to the resend
and octokit
node modules, and environment variables for RESEND_API_KEY
and GITHUB_PERSONAL_ACCESS_TOKEN
:
Notes
- You can actually give it multiple code executors with different node modules, different environment variables, and different network restrictions.
- When the AI writes invalid code, or the code gets errors they will be returned in the response. If the AI has steps left, it will try to fix the code and continue.
- If you add a node module we haven't seen before, the first time you run it it will take longer because we have to install the node module. After that, it will be cached and return to normal speed.