본문으로 건너뛰기

Google logoGoogle

Mastra의 Model 라우터를 통해 41개의 Google Model에 액세스하세요. 인증은 다음 환경 변수 중 하나를 사용하여 자동으로 처리됩니다.GOOGLE_API_KEY, GOOGLE_GENERATIVE_AI_API_KEY.

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

.env
GOOGLE_API_KEY=your-api-key
GOOGLE_GENERATIVE_AI_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: "google/deep-research-max-preview-04-2026"
});

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

Model
Model에 대한 직접 링크

ModelContextToolsReasoningImageAudioVideoInput $/1MOutput $/1M
google/deep-research-max-preview-04-2026131K$2$12
google/deep-research-preview-04-2026131K$2$12
google/gemini-2.5-computer-use-preview-10-2025131K$1$10
google/gemini-2.5-flash1.0M$0.30$3
google/gemini-2.5-flash-image33K$0.30$30
google/gemini-2.5-flash-lite1.0M$0.10$0.40
google/gemini-2.5-flash-preview-tts8K$0.50$10
google/gemini-2.5-pro1.0M$1$10
google/gemini-2.5-pro-preview-tts8K$1$20
google/gemini-3-flash-preview1.0M$0.50$3
google/gemini-3-pro-image131K$2$120
google/gemini-3-pro-image-preview131K$2$120
google/gemini-3.1-flash-image66K$0.50$60
google/gemini-3.1-flash-image-preview66K$0.50$60
google/gemini-3.1-flash-lite1.0M$0.25$2
google/gemini-3.1-flash-lite-image66K$0.25$30
google/gemini-3.1-flash-live-preview131K$0.75$5
google/gemini-3.1-flash-tts-preview8K$1$20
google/gemini-3.1-pro-preview1.0M$2$12
google/gemini-3.1-pro-preview-customtools1.0M$2$12
google/gemini-3.5-flash1.0M$2$9
google/gemini-3.5-flash-lite1.0M$0.30$3
google/gemini-3.5-live-translate-preview16K$4$21
google/gemini-3.6-flash1.0M$2$8
google/gemini-embedding-0012K$0.15
google/gemini-embedding-28K$0.20
google/gemini-flash-latest1.0M$2$9
google/gemini-flash-lite-latest1.0M$0.25$2
google/gemini-omni-flash-preview131K$2$18
google/gemini-robotics-er-1.6-preview131K$1$5
google/gemma-4-26b-a4b-it262K
google/gemma-4-31b-it262K
google/lyria-3-clip-preview1.0M
google/lyria-3-pro-preview1.0M
google/veo-3.1-fast-generate-preview480
google/veo-3.1-generate-preview480
google/veo-3.1-lite-generate-preview480
37 available models

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

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

src/mastra/agents/my-agent.ts
const agent = new Agent({
id: "custom-agent",
name: "custom-agent",
model: {
id: "google/deep-research-max-preview-04-2026",
apiKey: process.env.GOOGLE_API_KEY,GOOGLE_GENERATIVE_AI_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
? "google/veo-3.1-lite-generate-preview"
: "google/deep-research-max-preview-04-2026";
}
});

공급자 옵션
공급자 옵션에 대한 직접 링크

Google은 다음을 통해 Provider별 옵션을 지원합니다.providerOptions parameter:

const response = await agent.generate("Hello!", {
providerOptions: {
google: {
// See available options in the table below
}
}
});

사용 가능한 옵션
사용 가능한 옵션에 대한 직접 링크

responseModalities?:

("TEXT" | "IMAGE")[] | undefined

thinkingConfig?:

{ thinkingBudget?: number | undefined; includeThoughts?: boolean | undefined; thinkingLevel?: "minimal" | "low" | "medium" | "high" | undefined; } | undefined

cachedContent?:

string | undefined

structuredOutputs?:

boolean | undefined

safetySettings?:

{ category: "HARM_CATEGORY_UNSPECIFIED" | "HARM_CATEGORY_HATE_SPEECH" | "HARM_CATEGORY_DANGEROUS_CONTENT" | "HARM_CATEGORY_HARASSMENT" | "HARM_CATEGORY_SEXUALLY_EXPLICIT" | "HARM_CATEGORY_CIVIC_INTEGRITY"; threshold: "HARM_BLOCK_THRESHOLD_UNSPECIFIED" | ... 4 more ... | "OFF"; }[] | undefined

threshold?:

"HARM_BLOCK_THRESHOLD_UNSPECIFIED" | "BLOCK_LOW_AND_ABOVE" | "BLOCK_MEDIUM_AND_ABOVE" | "BLOCK_ONLY_HIGH" | "BLOCK_NONE" | "OFF" | undefined

audioTimestamp?:

boolean | undefined

labels?:

Record<string, string> | undefined

mediaResolution?:

"MEDIA_RESOLUTION_UNSPECIFIED" | "MEDIA_RESOLUTION_LOW" | "MEDIA_RESOLUTION_MEDIUM" | "MEDIA_RESOLUTION_HIGH" | undefined

imageConfig?:

{ aspectRatio?: "1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "4:5" | "5:4" | "9:16" | "16:9" | "21:9" | "1:8" | "8:1" | "1:4" | "4:1" | undefined; imageSize?: "1K" | "2K" | "4K" | "512" | undefined; personGeneration?: "PERSON_GENERATION_UNSPECIFIED" | ... 3 more ... | undefined; prominentPeople?: "PROMINENT_PEOPLE_UNSPEC...

retrievalConfig?:

{ latLng?: { latitude: number; longitude: number; } | undefined; } | undefined

streamFunctionCallArguments?:

boolean | undefined

serviceTier?:

"standard" | "flex" | "priority" | undefined

sharedRequestType?:

"standard" | "flex" | "priority" | undefined

requestType?:

"shared" | undefined

직접 공급자 설치
직접 공급자 설치에 대한 직접 링크

이 Provider는 Mastra Model 라우터 문자열 대신 사용할 수 있는 독립 실행형 패키지로 직접 설치할 수도 있습니다. 자세한 내용은 패키지 문서를 참조하세요.

npm install @ai-sdk/google

자세한 공급자별 설명서는 다음을 참조하세요.AI SDK Google provider docs.