Tool: embed_content
Converts text or multimodal input into a high-dimensional vector representation (embedding), which is essential for tasks like semantic search, clustering, and Retrieval-Augmented Generation (RAG).
The following sample demonstrate how to use curl to invoke the embed_content MCP tool.
| Curl Request |
|---|
curl --location 'https://aiplatform.googleapis.com/mcp/generate' \ --header 'content-type: application/json' \ --header 'accept: application/json, text/event-stream' \ --data '{ "method": "tools/call", "params": { "name": "embed_content", "arguments": { // provide these details according to the tool's MCP specification } }, "jsonrpc": "2.0", "id": 1 }' |
Input Schema
Request message for PredictionService.EmbedContent.
EmbedContentRequest
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
model |
Required. The name of the publisher model requested to serve the prediction. Format: |
Union field
|
|
content |
Required. The content to be embedded. |
Union field
|
|
title |
Optional. Deprecated: Please use EmbedContentConfig.title instead. The title for the text. |
Union field
|
|
taskType |
Optional. Deprecated: Please use EmbedContentConfig.task_type instead. The task type of the embedding. |
Union field
|
|
outputDimensionality |
Optional. Deprecated: Please use EmbedContentConfig.output_dimensionality instead. Reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. |
Union field
|
|
autoTruncate |
Optional. Deprecated: Please use EmbedContentConfig.auto_truncate instead. Whether to silently truncate the input content if it's longer than the maximum sequence length. |
Union field
|
|
embedContentConfig |
Optional. Configuration for the EmbedContent request. |
Content
| JSON representation |
|---|
{
"role": string,
"parts": [
{
object ( |
| Fields | |
|---|---|
role |
Optional. The producer of the content. Must be either 'user' or 'model'. If not set, the service will default to 'user'. |
parts[] |
Required. A list of A |
Part
| JSON representation |
|---|
{ "thought": boolean, "thoughtSignature": string, "mediaResolution": { object ( |
| Fields | |
|---|---|
thought |
Optional. Indicates whether the |
thoughtSignature |
Optional. An opaque signature for the thought so it can be reused in subsequent requests. A base64-encoded string. |
mediaResolution |
per part media resolution. Media resolution for the input media. |
audioTranscription |
Optional. Audio (input or output) transcription. This is only set when this Part contains audio data. |
Union field
|
|
text |
Optional. The text content of the part. When sent from the VSCode Gemini Code Assist extension, references to @mentioned items will be converted to markdown boldface text. For example |
inlineData |
Optional. The inline data content of the part. This can be used to include images, audio, or video in a request. |
fileData |
Optional. The URI-based data of the part. This can be used to include files from Google Cloud Storage. |
functionCall |
Optional. A predicted function call returned from the model. This contains the name of the function to call and the arguments to pass to the function. |
functionResponse |
Optional. The result of a function call. This is used to provide the model with the result of a function call that it predicted. |
executableCode |
Optional. Code generated by the model that is intended to be executed. |
codeExecutionResult |
Optional. The result of executing the |
Union field
|
|
videoMetadata |
Optional. Video metadata. The metadata should only be specified while the video data is presented in inline_data or file_data. |
Blob
| JSON representation |
|---|
{ "mimeType": string, "data": string, "displayName": string } |
| Fields | |
|---|---|
mimeType |
Required. The IANA standard MIME type of the source data. |
data |
Required. The raw bytes of the data. A base64-encoded string. |
displayName |
Optional. The display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in |
FileData
| JSON representation |
|---|
{ "mimeType": string, "fileUri": string, "displayName": string } |
| Fields | |
|---|---|
mimeType |
Required. The IANA standard MIME type of the source data. |
fileUri |
Required. The URI of the file in Google Cloud Storage. |
displayName |
Optional. The display name of the file. Used to provide a label or filename to distinguish files. This field is only returned in |
FunctionCall
| JSON representation |
|---|
{
"id": string,
"name": string,
"args": {
object
},
"partialArgs": [
{
object ( |
| Fields | |
|---|---|
id |
Optional. The unique id of the function call. If populated, the client to execute the |
name |
Optional. The name of the function to call. Matches |
args |
Optional. The function parameters and values in JSON object format. See |
partialArgs[] |
Optional. The partial argument value of the function call. If provided, represents the arguments/fields that are streamed incrementally. |
willContinue |
Optional. Whether this is the last part of the FunctionCall. If true, another partial message for the current FunctionCall is expected to follow. |
Struct
| JSON representation |
|---|
{ "fields": { string: value, ... } } |
| Fields | |
|---|---|
fields |
Unordered map of dynamically typed values. An object containing a list of |
FieldsEntry
| JSON representation |
|---|
{ "key": string, "value": value } |
| Fields | |
|---|---|
key |
|
value |
|
Value
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field kind. The kind of value. kind can be only one of the following: |
|
nullValue |
Represents a JSON |
numberValue |
Represents a JSON number. Must not be |
stringValue |
Represents a JSON string. |
boolValue |
Represents a JSON boolean ( |
structValue |
Represents a JSON object. |
listValue |
Represents a JSON array. |
ListValue
| JSON representation |
|---|
{ "values": [ value ] } |
| Fields | |
|---|---|
values[] |
Repeated field of dynamically typed values. |
PartialArg
| JSON representation |
|---|
{ "jsonPath": string, "willContinue": boolean, // Union field |
| Fields | |
|---|---|
jsonPath |
Required. A JSON Path (RFC 9535) to the argument being streamed. https://datatracker.ietf.org/doc/html/rfc9535. e.g. "$.foo.bar[0].data". |
willContinue |
Optional. Whether this is not the last part of the same json_path. If true, another PartialArg message for the current json_path is expected to follow. |
Union field delta. The delta of field value being streamed. delta can be only one of the following: |
|
nullValue |
Optional. Represents a null value. |
numberValue |
Optional. Represents a double value. |
stringValue |
Optional. Represents a string value. |
boolValue |
Optional. Represents a boolean value. |
FunctionResponse
| JSON representation |
|---|
{
"id": string,
"name": string,
"response": {
object
},
"parts": [
{
object ( |
| Fields | |
|---|---|
id |
Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call |
name |
Required. The name of the function to call. Matches |
response |
Required. The function response in JSON object format. Use "output" key to specify function output and "error" key to specify error details (if any). If "output" and "error" keys are not specified, then whole "response" is treated as function output. |
parts[] |
Optional. Ordered |
FunctionResponsePart
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field data. The data of the function response part. data can be only one of the following: |
|
inlineData |
Inline media bytes. |
fileData |
URI based data. |
FunctionResponseBlob
| JSON representation |
|---|
{ "mimeType": string, "data": string, "displayName": string } |
| Fields | |
|---|---|
mimeType |
Required. The IANA standard MIME type of the source data. |
data |
Required. Raw bytes. A base64-encoded string. |
displayName |
Optional. Display name of the blob. Used to provide a label or filename to distinguish blobs. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. |
FunctionResponseFileData
| JSON representation |
|---|
{ "mimeType": string, "fileUri": string, "displayName": string } |
| Fields | |
|---|---|
mimeType |
Required. The IANA standard MIME type of the source data. |
fileUri |
Required. URI. |
displayName |
Optional. Display name of the file data. Used to provide a label or filename to distinguish file datas. This field is only returned in PromptMessage for prompt management. It is currently used in the Gemini GenerateContent calls only when server side tools (code_execution, google_search, and url_context) are enabled. |
ExecutableCode
| JSON representation |
|---|
{ "language": enum ( |
| Fields | |
|---|---|
language |
Required. Programming language of the |
code |
Required. The code to be executed. |
Union field
|
|
id |
Optional. Unique identifier of the |
CodeExecutionResult
| JSON representation |
|---|
{ "outcome": enum ( |
| Fields | |
|---|---|
outcome |
Required. Outcome of the code execution. |
output |
Optional. Contains stdout when code execution is successful, stderr or other description otherwise. |
Union field
|
|
id |
Optional. The identifier of the |
VideoMetadata
| JSON representation |
|---|
{ "startOffset": string, "endOffset": string, "fps": number } |
| Fields | |
|---|---|
startOffset |
Optional. The start offset of the video. A duration in seconds with up to nine fractional digits, ending with ' |
endOffset |
Optional. The end offset of the video. A duration in seconds with up to nine fractional digits, ending with ' |
fps |
Optional. The frame rate of the video sent to the model. If not specified, the default value is 1.0. The valid range is (0.0, 24.0]. |
Duration
| JSON representation |
|---|
{ "seconds": string, "nanos": integer } |
| Fields | |
|---|---|
seconds |
Signed seconds of the span of time. Must be from -315,576,000,000 to +315,576,000,000 inclusive. Note: these bounds are computed from: 60 sec/min * 60 min/hr * 24 hr/day * 365.25 days/year * 10000 years |
nanos |
Signed fractions of a second at nanosecond resolution of the span of time. Durations less than one second are represented with a 0 |
MediaResolution
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
level |
The tokenization quality used for given media. |
AudioTranscription
| JSON representation |
|---|
{
"text": string,
"speakerLabel": string,
"words": [
{
object ( |
| Fields | |
|---|---|
text |
Required. The transcription text of this audio segment. |
speakerLabel |
Optional. A label identifying the speaker of this audio segment (e.g. "spk_1", "spk_2"). Present when diarization is set. |
words[] |
Optional. Detailed word-level transcriptions and timing details. Present when word_timestamp is set. |
WordInfo
| JSON representation |
|---|
{ "word": string, "startOffset": string, "endOffset": string } |
| Fields | |
|---|---|
word |
Required. Transcript of the word. |
startOffset |
Optional. Start offset in time of the word relative to the start of the audio. A duration in seconds with up to nine fractional digits, ending with ' |
endOffset |
Optional. End offset in time of the word relative to the start of the audio. A duration in seconds with up to nine fractional digits, ending with ' |
EmbedContentConfig
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
title |
Optional. The title for the text. Only applicable to text-only embedding models. |
Union field
|
|
taskType |
Optional. The task type of the embedding. Only applicable to text-only embedding models. |
Union field
|
|
autoTruncate |
Optional. Whether to silently truncate the input content if it's longer than the maximum sequence length. Only applicable to text-only embedding models. |
Union field
|
|
outputDimensionality |
Optional. Reduced dimension for the output embedding. If set, excessive values in the output embedding are truncated from the end. |
Union field
|
|
documentOcr |
Optional. Whether to enable OCR for document content. |
Union field
|
|
audioTrackExtraction |
Optional. Whether to extract audio from video content. |
NullValue
Represents a JSON null.
NullValue is a sentinel, using an enum with only one value to represent the null value for the Value type union.
A field of type NullValue with any value other than 0 is considered invalid. Most ProtoJSON serializers will emit a Value with a null_value set as a JSON null regardless of the integer value, and so will round trip to a 0 value.
| Enums | |
|---|---|
NULL_VALUE |
Null value. |
Language
Supported programming languages for the generated code.
| Enums | |
|---|---|
LANGUAGE_UNSPECIFIED |
Unspecified language. This value should not be used. |
PYTHON |
Python >= 3.10, with numpy and simpy available. |
Outcome
Enumeration of possible outcomes of the code execution.
| Enums | |
|---|---|
OUTCOME_UNSPECIFIED |
Unspecified status. This value should not be used. |
OUTCOME_OK |
Code execution completed successfully. output contains the stdout, if any. |
OUTCOME_FAILED |
Code execution failed. output contains the stderr and stdout, if any. |
OUTCOME_DEADLINE_EXCEEDED |
Code execution ran for too long, and was cancelled. There may or may not be a partial output present. |
Level
The media resolution level.
| Enums | |
|---|---|
MEDIA_RESOLUTION_UNSPECIFIED |
Media resolution has not been set. |
MEDIA_RESOLUTION_LOW |
Media resolution set to low. |
MEDIA_RESOLUTION_MEDIUM |
Media resolution set to medium. |
MEDIA_RESOLUTION_HIGH |
Media resolution set to high. |
MEDIA_RESOLUTION_ULTRA_HIGH |
Media resolution set to ultra high. This is for image only. |
EmbeddingTaskType
Represents a downstream task the embeddings will be used for.
| Enums | |
|---|---|
UNSPECIFIED |
Unset value, which will default to one of the other enum values. |
RETRIEVAL_QUERY |
Specifies the given text is a query in a search/retrieval setting. |
RETRIEVAL_DOCUMENT |
Specifies the given text is a document from the corpus being searched. |
SEMANTIC_SIMILARITY |
Specifies the given text will be used for STS. |
CLASSIFICATION |
Specifies that the given text will be classified. |
CLUSTERING |
Specifies that the embeddings will be used for clustering. |
QUESTION_ANSWERING |
Specifies that the embeddings will be used for question answering. |
FACT_VERIFICATION |
Specifies that the embeddings will be used for fact verification. |
CODE_RETRIEVAL_QUERY |
Specifies that the embeddings will be used for code retrieval. |
Output Schema
Response message for PredictionService.EmbedContent.
EmbedContentResponse
| JSON representation |
|---|
{ "embedding": { object ( |
| Fields | |
|---|---|
embedding |
The embedding generated from the input content. |
usageMetadata |
Usage metadata about the response(s). |
truncated |
Whether the input content was truncated before generating the embedding. |
Embedding
| JSON representation |
|---|
{ "values": [ number ] } |
| Fields | |
|---|---|
values[] |
Embedding vector values. |
UsageMetadata
| JSON representation |
|---|
{ "promptTokenCount": integer, "candidatesTokenCount": integer, "totalTokenCount": integer, "toolUsePromptTokenCount": integer, "thoughtsTokenCount": integer, "cachedContentTokenCount": integer, "promptTokensDetails": [ { object ( |
| Fields | |
|---|---|
promptTokenCount |
The total number of tokens in the prompt. This includes any text, images, or other media provided in the request. When |
candidatesTokenCount |
The total number of tokens in the generated candidates. |
totalTokenCount |
The total number of tokens for the entire request. This is the sum of |
toolUsePromptTokenCount |
Output only. The number of tokens in the results from tool executions, which are provided back to the model as input, if applicable. |
thoughtsTokenCount |
Output only. The number of tokens that were part of the model's generated "thoughts" output, if applicable. |
cachedContentTokenCount |
Output only. The number of tokens in the cached content that was used for this request. |
promptTokensDetails[] |
Output only. A detailed breakdown of the token count for each modality in the prompt. |
cacheTokensDetails[] |
Output only. A detailed breakdown of the token count for each modality in the cached content. |
candidatesTokensDetails[] |
Output only. A detailed breakdown of the token count for each modality in the generated candidates. |
toolUsePromptTokensDetails[] |
Output only. A detailed breakdown by modality of the token counts from the results of tool executions, which are provided back to the model as input. |
trafficType |
Output only. The traffic type for this request. |
ModalityTokenCount
| JSON representation |
|---|
{
"modality": enum ( |
| Fields | |
|---|---|
modality |
The modality that this token count applies to. |
tokenCount |
The number of tokens counted for this modality. |
Modality
The modality of a Part of a Content message. A modality is the type of media, such as an image or a video. It is used to categorize the content of a Part for token counting purposes.
| Enums | |
|---|---|
MODALITY_UNSPECIFIED |
When a modality is not specified, it is treated as TEXT. |
TEXT |
The Part contains plain text. |
IMAGE |
The Part contains an image. |
VIDEO |
The Part contains a video. |
AUDIO |
The Part contains audio. |
DOCUMENT |
The Part contains a document, such as a PDF. |
TrafficType
The type of traffic that this request was processed with, indicating which quota gets consumed.
| Enums | |
|---|---|
TRAFFIC_TYPE_UNSPECIFIED |
Unspecified request traffic type. |
ON_DEMAND |
Type for Pay-As-You-Go traffic. |
ON_DEMAND_PRIORITY |
Type for Priority Pay-As-You-Go traffic. |
ON_DEMAND_FLEX |
Type for Flex traffic. |
PROVISIONED_THROUGHPUT |
Type for Provisioned Throughput traffic. |
Tool Annotations
Destructive Hint: ❌ | Idempotent Hint: ✅ | Read Only Hint: ✅ | Open World Hint: ❌