Craft AI Modules Google
const { aiModules } = MODULES;Table of Contents
- aiModules
- ALLOWED_GEMINI_MODELS
- validateGeminiModel
- GeminiGenerationConfig
- GeminiSafetySetting
- GeminiCandidate
- GeminiResponse
- GeminiStreamChunk
- RagOptions
- CraftExtra
- FunctionDeclaration
- StandardGeminiTools
- FunctionCallingConfig
- StandardGeminiToolConfig
- GeminiContentParams
- GeminiStreamParams
- FunctionCall
- FunctionResponse
- GeminiResultValue
- InlineData
- ContentPart
- Content
- StreamChunk
- ThinkingConfig
- GenerationConfig
- EmbeddingsResultValue
- MultiEmbedding
- MultiEmbeddingsResultValue
- TextEmbeddingInstance
- TextEmbeddingParameters
- RerankRecord
- RankedRecord
- RerankResultValue
aiModules
Standard AI modules for GCP services
gcpGeminiGenerateContent
Geminiにリクエストを送信する
Parameters
paramsGeminiContentParams パラメータ
Returns Promise<GeminiResultValue>
gcpGeminiGenerateContentStream
Geminiにストリーミングリクエストを送信する
Parameters
paramsGeminiStreamParams パラメータ
Returns Promise<void>
gcpEmbeddingsText
TextEmbeddingsにリクエストを送信する
Parameters
paramObjectparam.textstring テキストの内容 (deprecated, use instances instead)param.instancesArray<TextEmbeddingInstance>? インスタンスの配列param.parametersTextEmbeddingParameters? パラメータparam.modelstring? モデル名 (optional) - ‘text-multilingual-embedding-002’, ‘text-embedding-004’, ‘gemini-embedding-001’
Returns Promise<EmbeddingsResultValue>
gcpEmbeddingsMulti
MultiModalEmbeddingsにリクエストを送信する
Parameters
paramObject
- Throws Error failed. text or bytesBase64Encoded is required
Returns Promise<MultiEmbeddingsResultValue>
gcpRerank
GCP Rerank APIにリクエストを送信する
Parameters
paramObjectparam.querystring 検索クエリparam.recordsArray<RerankRecord> ランク付けするレコードの配列param.modelstring? モデル名(デフォルト: semantic-ranker-512@latest)。利用可能なモデル: semantic-ranker-512@latest, semantic-ranker-default-004, semantic-ranker-fast-004param.ignoreRecordDetailsInResponseboolean? レコードのタイトルとコンテンツも返さないか(デフォルト: true)param.topNnumber? 返される上位レコードの数(デフォルト: 10)
- Throws Error failed. query and records are required
Returns Promise<RerankResultValue>
ALLOWED_GEMINI_MODELS
Standard版で利用可能なGeminiモデル
validateGeminiModel
Geminiモデルのバリデーション
Parameters
modelstring モデル名
- Throws Error モデルが許可されていない場合
GeminiGenerationConfig
Type: Object
Properties
maxOutputTokensnumber? 最大出力トークン数temperaturenumber? 温度パラメータ (0-2)topPnumber? Top-p サンプリングresponseMimeTypestring? レスポンスのMIMEタイプresponseSchemaObject? レスポンススキーマthinkingConfigObject? Thinking mode設定thinkingConfig.includeThoughtsboolean? 思考プロセスを含めるかthinkingConfig.thinkingBudgetnumber? 思考用トークン予算(Gemini 2.5モデル用、0-32768)thinkingConfig.thinkingLevel("minimal"|"low"|"medium"|"high")? 思考レベル(Gemini 3/3.1モデル用、デフォルト’high’、無効化不可)。* gemini-3-flash-preview: ‘minimal’ | ‘low’ | ‘medium’ | ‘high’ サポート- gemini-3.1-pro-preview: ‘low’ | ‘medium’ | ‘high’ サポート
- gemini-3.1-flash-lite-preview: ‘minimal’ | ‘low’ | ‘medium’ | ‘high’ サポート
GeminiSafetySetting
Type: Object
Properties
category("HARM_CATEGORY_HARASSMENT"|"HARM_CATEGORY_HATE_SPEECH"|"HARM_CATEGORY_SEXUALLY_EXPLICIT"|"HARM_CATEGORY_DANGEROUS_CONTENT") 安全性カテゴリthreshold("BLOCK_NONE"|"BLOCK_ONLY_HIGH"|"BLOCK_MEDIUM_AND_ABOVE"|"BLOCK_LOW_AND_ABOVE") ブロック閾値
GeminiCandidate
Type: Object
Properties
GeminiResponse
Type: Object
Properties
-
candidatesArray<GeminiCandidate> 候補リスト -
usageMetadataObject 使用量メタデータ -
groundingMetadataObject? グラウンディングメタデータ
GeminiStreamChunk
Type: Object
Properties
deltaObject? デルタコンテンツfinishReasonstring? 終了理由groundingMetadataObject? グラウンディングメタデータusageMetadataObject? 使用量メタデータ(最終チャンク)
RagOptions
Type: Object
Properties
corpusIdstring RAG IDvectorDistanceThresholdnumber? ベクトル距離の閾値llmRankerModelstring? LLMランカーのモデル名rankServiceModelstring? ランクサービスのモデル名topKnumber? トップK
CraftExtra
Type: Object
Properties
ragOptionsRagOptions? RAGオプション
FunctionDeclaration
Type: Object
Properties
StandardGeminiTools
Type: Object
Properties
functionDeclarationsArray<FunctionDeclaration>? Function calling宣言
FunctionCallingConfig
Type: Object
Properties
mode("AUTO"|"ANY"|"NONE")? Function calling modeallowedFunctionNamesArray<string>? 許可する関数名のリスト
StandardGeminiToolConfig
Type: Object
Properties
functionCallingConfigFunctionCallingConfig? Function calling設定
GeminiContentParams
Type: Object
Properties
modelstring モデル(必須) 利用可能なモデル:* ‘gemini-2.5-flash’: Gemini 2.5 Flash- ’gemini-2.5-flash-lite’: Gemini 2.5 Flash Lite
- ’gemini-2.5-pro’: Gemini 2.5 Pro
- ’gemini-3-flash-preview’: Gemini 3 Flash Preview(マルチモーダル+推論、thinkingLevel: minimal/low/medium/high)
- ‘gemini-3.1-pro-preview’: Gemini 3.1 Pro Preview(高度な推論、thinkingLevel: low/medium/high)
- ‘gemini-3.1-flash-lite-preview’: Gemini 3.1 Flash Lite Preview(軽量版、thinkingLevel: minimal/low/medium/high)
contentsArray<Content> 会話のメッセージ配列。各要素はContentオブジェクト(Content, ContentPart型を参照)systemInstructionstring? システムインストラクションgenerationConfigGeminiGenerationConfig? 生成設定safetySettingsArray<GeminiSafetySetting>? 安全性設定toolsStandardGeminiTools? ツール設定(Function callingのみ)toolConfigStandardGeminiToolConfig? ツール設定(Function calling設定のみ)craftExtraCraftExtra? Craft固有の追加設定(RAGオプションなど)
GeminiStreamParams
Extends GeminiContentParams
Type: Object
FunctionCall
Type: Object
Properties
FunctionResponse
Type: Object
Properties
GeminiResultValue
Type: Object
Properties
-
usageMetadataObject 使用量メタデータ -
-
candidates[].contentObject 回答の内容candidates[].content.rolestring 役割candidates[].content.partsArray<Object> 回答の部分candidates[].content.partsstring [].text - 回答のテキストcandidates[].content.partsFunctionCall [].functionCall - functionCallcandidates[].content.partsFunctionResponse [].functionResponse - functionResponse
-
candidates[].finishReasonstring 回答終了理由
-
InlineData
Type: Object
Properties
mimeTypestring MIMEタイプ(例: ‘image/png’, ‘image/jpeg’, ‘application/pdf’)datastring Base64エンコードされたデータ
ContentPart
Type: Object
Properties
textstring? テキストコンテンツinlineDataInlineData? インラインデータ(画像、PDF等)functionCallFunctionCall? 関数呼び出し(モデルからの応答に含まれる)functionResponseFunctionResponse? 関数の実行結果(ユーザーからの入力として使用)thoughtSignaturestring? Gemini 3モデル用の思考署名。 マルチターン会話で推論コンテキストを維持するために使用。 モデルからのレスポンスに含まれ、次のリクエストにそのまま含める必要あり(改変不可)。 Function Callingでは必須(ない場合400エラー)。
Content
Type: Object
Properties
role("user"|"model") メッセージの送信者。‘user’はユーザー、‘model’はAIモデルpartsArray<ContentPart> メッセージの内容(複数のパーツで構成可能)
Examples
// テキストのみのユーザーメッセージ{ role: 'user', parts: [{ text: 'こんにちは' }] }// 画像を含むユーザーメッセージ{ role: 'user', parts: [ { text: 'この画像について説明してください' }, { inlineData: { mimeType: 'image/jpeg', data: 'base64encodeddata...' } } ]}// Function Callingを使用した会話// 1. ユーザーの質問{ role: 'user', parts: [{ text: '東京の天気を教えて' }] }// 2. モデルからの関数呼び出し要求(レスポンス){ role: 'model', parts: [{ functionCall: { name: 'getWeather', args: { location: '東京' } } }] }// 3. ユーザーからの関数実行結果{ role: 'user', parts: [{ functionResponse: { name: 'getWeather', response: { temp: 25, condition: '晴れ' } } }] }// 4. モデルの最終回答(レスポンス){ role: 'model', parts: [{ text: '東京の現在の天気は晴れで、気温は25度です。' }] }StreamChunk
Type: Object
Properties
ThinkingConfig
Type: Object
Properties
GenerationConfig
Type: Object
Properties
maxOutputTokensnumber? 最大出力トークン数temperaturenumber? 生成時の多様性を制御するパラメータtopPnumber? 確率の高いトークンから選択する閾値responseMimeTypestring? レスポンスタイプresponseSchemaObject? レスポンス構造を定義するスキーマthinkingConfigThinkingConfig? 思考処理の設定
EmbeddingsResultValue
Type: Object
Properties
MultiEmbedding
Type: Object
Properties
textEmbeddingArray<number>? The text embedding array.imageEmbeddingArray<number>? The image embedding array.
MultiEmbeddingsResultValue
Type: Object
Properties
predictionsArray<MultiEmbedding> An array of embedding objects.
TextEmbeddingInstance
Type: Object
Properties
contentstring コンテンツtitlestring? タイトル (optional) - RETRIEVAL_DOCUMENTタスクタイプでのみ使用可能task_typestring? タスクタイプ (optional) - 以下の値が使用可能。デフォルトは ‘RETRIEVAL_QUERY’:* ‘RETRIEVAL_QUERY’: 検索クエリ用- ’RETRIEVAL_DOCUMENT’: 検索対象のドキュメント用
- ’SEMANTIC_SIMILARITY’: 意味的類似性の比較用
- ’CLASSIFICATION’: 分類タスク用
- ’CLUSTERING’: クラスタリングタスク用
- ’QUESTION_ANSWERING’: 質問応答システム用
- ’FACT_VERIFICATION’: 事実検証用
- ’CODE_RETRIEVAL_QUERY’: コード検索クエリ用
TextEmbeddingParameters
Type: Object
Properties
RerankRecord
Type: Object
Properties
RankedRecord
Type: Object
Properties
idstring レコードのIDtitlestring? レコードのタイトル。ignoreRecordDetailsInResponse が true の場合は省略される。contentstring? レコードのコンテンツ。ignoreRecordDetailsInResponse が true の場合は省略される。scorenumber ランキングスコア
RerankResultValue
Type: Object
Properties
recordsArray<RankedRecord> ランク付けされたレコードの配列