Skip to main content

NanoGPT logoNanoGPT

Access 21 NanoGPT models through Mastra's model router. Authentication is handled automatically using the NANO_GPT_API_KEY environment variable.

Learn more in the NanoGPT documentation.

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

const agent = new Agent({
id: "my-agent",
name: "My Agent",
instructions: "You are a helpful assistant",
model: "nano-gpt/deepseek/deepseek-r1"
});

// 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 NanoGPT documentation for details.

Models
Direct link to Models

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
nano-gpt/deepseek/deepseek-r1128K$1$2
nano-gpt/deepseek/deepseek-v3.2:thinking128K$1$2
nano-gpt/meta-llama/llama-3.3-70b-instruct128K$1$2
nano-gpt/meta-llama/llama-4-maverick128K$1$2
nano-gpt/minimax/minimax-m2.1128K$1$2
nano-gpt/mistralai/devstral-2-123b-instruct-2512131K$1$2
nano-gpt/mistralai/ministral-14b-instruct-2512131K$1$2
nano-gpt/mistralai/mistral-large-3-675b-instruct-2512131K$1$2
nano-gpt/moonshotai/kimi-k2-instruct131K$1$2
nano-gpt/moonshotai/kimi-k2-thinking33K$1$2
nano-gpt/nousresearch/hermes-4-405b:thinking128K$1$2
nano-gpt/nvidia/llama-3_3-nemotron-super-49b-v1_5128K$1$2
nano-gpt/openai/gpt-oss-120b128K$1$2
nano-gpt/qwen/qwen3-235b-a22b-thinking-2507262K$1$2
nano-gpt/qwen/qwen3-coder106K$1$2
nano-gpt/z-ai/glm-4.6200K$1$2
nano-gpt/z-ai/glm-4.6:thinking128K$1$2
nano-gpt/zai-org/glm-4.5-air128K$1$2
nano-gpt/zai-org/glm-4.5-air:thinking128K$1$2
nano-gpt/zai-org/glm-4.7205K$1$2
nano-gpt/zai-org/glm-4.7:thinking128K$1$2
21 available models

Advanced Configuration
Direct link to Advanced Configuration

Custom Headers
Direct link to Custom Headers

const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://nano-gpt.com/api/v1",
id: "nano-gpt/deepseek/deepseek-r1",
apiKey: process.env.NANO_GPT_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});

Dynamic Model Selection
Direct link to Dynamic Model Selection

const agent = new Agent({
id: "dynamic-agent",
name: "Dynamic Agent",
model: ({ requestContext }) => {
const useAdvanced = requestContext.task === "complex";
return useAdvanced
? "nano-gpt/zai-org/glm-4.7:thinking"
: "nano-gpt/deepseek/deepseek-r1";
}
});

On this page