본문으로 건너뛰기

NEAR AI Cloud logoAI 클라우드 근처

Mastra의 Model 라우터를 통해 37개의 NEAR AI Cloud Model에 액세스하세요. 인증은 다음을 사용하여 자동으로 처리됩니다.NEARAI_API_KEY environment variable.

자세한 내용은 다음에서 확인하세요.NEAR AI Cloud documentation.

.env
NEARAI_API_KEY=your-api-key
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: "nearai/Qwen/Qwen3-30B-A3B-Instruct-2507"
});

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

Mastra는 OpenAI 호환 /chat/completions endpoint를 사용합니다. Provider별 일부 기능은 제공되지 않을 수 있습니다. 자세한 내용은 NEAR AI Cloud 문서를 확인하세요.

Model
Model에 대한 직접 링크

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
nearai/anthropic/claude-haiku-4-5200K$1$5
nearai/anthropic/claude-opus-4-6200K$5$25
nearai/anthropic/claude-opus-4-71.0M$5$25
nearai/anthropic/claude-sonnet-4-5200K$3$16
nearai/anthropic/claude-sonnet-4-61.0M$3$15
nearai/black-forest-labs/FLUX.2-klein-4B128K$1$1
nearai/google/gemini-2.5-flash1.0M$0.30$3
nearai/google/gemini-2.5-flash-lite1.0M$0.10$0.40
nearai/google/gemini-2.5-pro1.0M$1$10
nearai/google/gemini-3-pro1.0M$1$15
nearai/google/gemini-3.1-flash-lite1.0M$0.25$2
nearai/google/gemini-3.5-flash1.0M$2$9
nearai/google/gemma-4-31B-it262K$0.13$0.40
nearai/openai/gpt-4.11.0M$2$8
nearai/openai/gpt-4.1-mini1.0M$0.40$2
nearai/openai/gpt-4.1-nano1.0M$0.10$0.40
nearai/openai/gpt-5400K$1$10
nearai/openai/gpt-5-mini400K$0.25$2
nearai/openai/gpt-5-nano400K$0.05$0.40
nearai/openai/gpt-5.1400K$1$10
nearai/openai/gpt-5.2400K$2$16
nearai/openai/gpt-5.41.1M$3$15
nearai/openai/gpt-5.4-mini400K$0.75$5
nearai/openai/gpt-5.4-nano400K$0.20$1
nearai/openai/gpt-5.51.1M$5$30
nearai/openai/gpt-oss-120b131K$0.15$0.55
nearai/openai/o3200K$2$8
nearai/openai/o3-mini200K$1$4
nearai/openai/o4-mini200K$1$4
nearai/openai/whisper-large-v3448$0.01
nearai/Qwen/Qwen3-30B-A3B-Instruct-2507262K$0.15$0.55
nearai/Qwen/Qwen3-Embedding-0.6B41K$0.01
nearai/Qwen/Qwen3-Reranker-0.6B41K$0.01$0.01
nearai/Qwen/Qwen3-VL-30B-A3B-Instruct256K$0.15$0.55
nearai/Qwen/Qwen3.5-122B-A10B131K$0.40$3
nearai/Qwen/Qwen3.6-35B-A3B-FP8262K$0.17$1
nearai/zai-org/GLM-5.1-FP8203K$0.85$3
37 available models

고급 구성
고급 구성에 대한 직접 링크

맞춤 헤더
맞춤 헤더에 대한 직접 링크

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
url: "https://cloud-api.near.ai/v1",
id: "nearai/Qwen/Qwen3-30B-A3B-Instruct-2507",
apiKey: process.env.NEARAI_API_KEY,
headers: {
"X-Custom-Header": "value"
}
}
});

동적 Model 선택
동적 Model 선택에 대한 직접 링크

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
? "nearai/zai-org/GLM-5.1-FP8"
: "nearai/Qwen/Qwen3-30B-A3B-Instruct-2507";
}
});