Follow these steps to create a Chef Agent in Mastra that can suggest ingredient substitutions, build recipes from a pantry list, and integrate into your app.
npx mastra init my-app
)..env
as OPENAI_API_KEY
.Substitute tool
Recipe tool
src/tools/suggest-substitute-tool.ts
:
src/tools/recipe-from-pantry-tool.ts
:
src/agents/chef-agent.ts
:
src/mastra/index.ts
:
The key inagents: { chef: chefAgent }
determines the API path:/api/agents/chef/*
.
Ping test
Temporary public tunnel
Use a tunnel to test the agent before full deployment:
Append /api/agents/chef/generate
and copy the HTTPS URL into the Dashboard.
Vercel serverless example (TypeScript)
Production patterns
Security essentials
CometChat mapping
/api/agents/chef/generate
. Mastra Agent ID = chef
.Open Dashboard
Navigate
Add agent
chef
, Deployment URL=your public generate endpoint.(Optional) Enhancements
Enable
Open variant
Customize & Deploy
Adjust settings
Preview
Note: The Mastra agent you connected in earlier steps is already part of the exported configuration, so your end-users will chat with that agent immediately.
API generates response
/api/agents/chef/generate
returns a recipe or suggestion.Agent listed
/api/agents
includes “chef”
.Tool action works
suggest-substitute
tool invocation.Full sample test (run curl)
agents
map in mastra/index.ts
.id
matches exactly between the tool file and the agent.OPENAI_API_KEY
is set.