Skip to main content

Neon logoNeon

Access 25 Neon models through Mastra's model router. Authentication is handled automatically using the NEON_AI_GATEWAY_TOKEN environment variable. Configure NEON_AI_GATEWAY_BASE_URL as well.

Learn more in the Neon documentation.

.env
NEON_AI_GATEWAY_BASE_URL=your-value
NEON_AI_GATEWAY_TOKEN=your-api-token
src/mastra/agents/my-agent.ts
import { Agent } from "@mastra/core/agent";

const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "neon/claude-haiku-4-5"
});

// 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);
}
info

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

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
neon/claude-haiku-4-5200K$1$5
neon/claude-opus-4-1200K$15$75
neon/claude-opus-4-5200K$5$25
neon/claude-opus-4-61.0M$5$25
neon/claude-opus-4-71.0M$5$25
neon/claude-sonnet-4200K$3$15
neon/claude-sonnet-4-5200K$3$15
neon/claude-sonnet-4-61.0M$3$15
neon/gemini-2-5-flash1.0M$0.30$3
neon/gemini-2-5-pro1.0M$1$10
neon/gemini-3-1-flash-lite1.0M$0.25$2
neon/gemini-3-1-pro1.0M$2$12
neon/gemini-3-flash1.0M$0.50$3
neon/gemini-3-pro1.0M$2$12
neon/gpt-5400K$1$10
neon/gpt-5-1400K$1$10
neon/gpt-5-2400K$2$14
neon/gpt-5-41.1M$3$15
neon/gpt-5-4-mini400K$0.75$5
neon/gpt-5-4-nano400K$0.20$1
neon/gpt-5-51.1M$5$30
neon/gpt-5-mini400K$0.25$2
neon/gpt-5-nano400K$0.05$0.40
neon/gpt-oss-120b131K$0.07$0.28
neon/gpt-oss-20b131K$0.05$0.20
25 available models

Advanced configuration
Direct link to Advanced configuration

Custom headers
Direct link to Custom headers

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "${NEON_AI_GATEWAY_BASE_URL}/ai-gateway/mlflow/v1",
id: "neon/claude-haiku-4-5",
apiKey: process.env.NEON_AI_GATEWAY_TOKEN,
headers: {
"X-Custom-Header": "value"
}
}
});

Dynamic model selection
Direct link to Dynamic model selection

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "neon/gpt-oss-20b"
: "neon/claude-haiku-4-5";
}
});
On this page