Skip to main content

Venice AI logoVenice AI

Access 13 Venice AI models through Mastra's model router. Authentication is handled automatically using the VENICE_API_KEY environment variable.

Learn more in the Venice AI documentation.

VENICE_API_KEY=your-api-key
import { Agent } from "@mastra/core";

const agent = new Agent({
name: "my-agent",
instructions: "You are a helpful assistant",
model: "venice/deepseek-coder-v2-lite",
});

// Generate a response
const response = await agent.generate("Hello!");

// Stream a response
const stream = await agent.stream("Tell me a story");
for await (const chunk of stream) {
console.log(chunk);
}
OpenAI Compatibility

Mastra uses the OpenAI-compatible /chat/completions endpoint. Some provider-specific features may not be available. Check the Venice AI documentation for details.

Models

ModelImageAudioVideoToolsStreamingContext Window
venice/dolphin-2.9.2-qwen2-72b32,768
venice/mistral-31-24b131,072
venice/venice-uncensored32,768
venice/qwen-2.5-vl32,768
venice/qwen3-235b131,072
venice/qwen-2.5-qwq-32b32,768
venice/deepseek-coder-v2-lite131,072
venice/qwen3-4b32,768
venice/llama-3.3-70b65,536
venice/qwen-2.5-coder-32b32,768
venice/deepseek-r1-671b131,072
venice/llama-3.2-3b131,072
venice/llama-3.1-405b65,536

Advanced Configuration

Custom Headers

const agent = new Agent({
name: "custom-agent",
model: {
url: "https://api.venice.ai/api/v1",
modelId: "deepseek-coder-v2-lite",
apiKey: process.env.VENICE_API_KEY,
headers: {
"X-Custom-Header": "value",
},
},
});

Dynamic Model Selection

const agent = new Agent({
name: "dynamic-agent",
model: ({ runtimeContext }) => {
const useAdvanced = runtimeContext.task === "complex";
return useAdvanced
? "venice/venice-uncensored"
: "venice/deepseek-coder-v2-lite";
},
});