Prerequisites
- Node.js 22.18 or later
- A Venice API key
Create a Mastra project
.env file:
Create a Venice-powered agent
Create an agent and point its model configuration at the Venice API:id is Mastra’s routing label. Mastra sends the remaining model ID, venice-uncensored, to Venice.
Set
url to the base API URL shown above. Do not append /chat/completions; Mastra adds that path.Generate a response
Retrieve the registered agent and callgenerate():
Stream a response
Usestream() when you want to display output as it arrives:
Add tools
Mastra tools use Zod schemas to validate their inputs and outputs. Use a Venice model that supports function calling when attaching tools to an agent.Generate structured output
Pass a Zod schema throughstructuredOutput to receive validated data:
jsonPromptInjection: true inside structuredOutput to have Mastra add the schema to the prompt instead.
Change models
To use another Venice text model, keep thevenice/ routing prefix and replace the remaining model ID:
Troubleshooting
The API reports that the model does not exist
The API reports that the model does not exist
Use the exact model ID shown on the models page. In Mastra, prefix it with
venice/, for example venice/venice-uncensored.Requests return 404 Not Found
Requests return 404 Not Found
Set the model URL to
https://api.venice.ai/api/v1. Do not use the full /chat/completions endpoint.The agent does not call its tool
The agent does not call its tool
Choose a model that supports function calling, describe when the agent should use the tool in its instructions, and define the tool with
createTool().Mastra Documentation
Learn more about Mastra agents, tools, and workflows
Venice Models
Browse models and supported capabilities