Welcome to the comprehensive documentation for the Generative Language API (version v1beta). This document provides detailed information, including descriptions and curl examples, for every available function.
API Base URL: https://generativelanguage.googleapis.com/
The batches resource deals with long-running operations.
Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns UNIMPLEMENTED.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/batches - Path Parameter:
name:string(required). The name of the operation's parent resource. Must match the pattern^batches$.
- Query Parameters:
filter:string. The standard list filter.pageSize:integer. The standard list page size.pageToken:string. The standard list page token.
- Response Body: ListOperationsResponse
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/batches?filter=done%3Dtrue&pageSize=10&key=[YOUR_API_KEY]"Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/batches/{batchesId} - Path Parameter:
name:string(required). The name of the operation resource. Must match the pattern^batches/[^/]+$.
- Response Body: Operation
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/batches/operation-12345?key=[YOUR_API_KEY]"Deletes a long-running operation. This method indicates that the client is no longer interested in the operation result. It does not cancel the operation. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.
- HTTP Request:
DELETE https://generativelanguage.googleapis.com/v1beta/batches/{batchesId} - Path Parameter:
name:string(required). The name of the operation resource to be deleted. Must match the pattern^batches/[^/]+$.
- Response Body: Empty
Example curl request:
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/batches/operation-12345?key=[YOUR_API_KEY]"Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns google.rpc.Code.UNIMPLEMENTED.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/batches/{batchesId}:cancel - Path Parameter:
name:string(required). The name of the operation resource to be cancelled. Must match the pattern^batches/[^/]+$.
- Response Body: Empty
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/batches/operation-12345:cancel?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{}'The models resource provides access to the generative models.
Generates a model response given an input GenerateContentRequest. Refer to the text generation guide for detailed usage information.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:generateContent - Path Parameter:
model:string(required). The name of theModelto use for generating the completion. Format:models/{model}.
- Request Body: GenerateContentRequest
- Response Body: GenerateContentResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-001:generateContent?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts":[{
"text": "Explain why the sky is blue."
}]
}]
}'Generates a grounded answer from the model given an input GenerateAnswerRequest.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:generateAnswer - Path Parameter:
model:string(required). The name of theModelto use for generating the grounded response. Format:models/{model}.
- Request Body: GenerateAnswerRequest
- Response Body: GenerateAnswerResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-001:generateAnswer?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"contents": [{"parts":[{"text": "What are the main ingredients in a margarita?"}]}],
"answerStyle": "VERBOSE",
"inlinePassages": {
"passages": [{
"id": "passage-1",
"content": {
"parts": [{
"text": "A classic margarita cocktail is made with tequila, orange liqueur (like Cointreau or Triple Sec), and fresh lime juice. It is often served with a salted rim."
}]
}
}]
}
}'Generates a streamed response from the model given an input GenerateContentRequest.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:streamGenerateContent - Path Parameter:
model:string(required). The name of theModelto use for generating the completion. Format:models/{model}.
- Request Body: GenerateContentRequest
- Response Body: A stream of GenerateContentResponse objects.
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-001:streamGenerateContent?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts":[{
"text": "Write a long, epic poem about a journey to the center of the Earth."
}]
}]
}'Generates a text embedding vector from the input Content using the specified Gemini Embedding model.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:embedContent - Path Parameter:
model:string(required). The model's resource name. Format:models/{model}.
- Request Body: EmbedContentRequest
- Response Body: EmbedContentResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/embedding-001:embedContent?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"content": {
"parts": [{
"text": "This is a sentence to be embedded."
}]
},
"taskType": "RETRIEVAL_DOCUMENT"
}'Generates multiple embedding vectors from the input Content which consists of a batch of strings represented as EmbedContentRequest objects.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:batchEmbedContents - Path Parameter:
model:string(required). The model's resource name. Format:models/{model}.
- Request Body: BatchEmbedContentsRequest
- Response Body: BatchEmbedContentsResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/embedding-001:batchEmbedContents?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"requests": [
{
"model": "models/embedding-001",
"content": {"parts": [{"text": "First document."}]},
"taskType": "RETRIEVAL_DOCUMENT"
},
{
"model": "models/embedding-001",
"content": {"parts": [{"text": "Second document."}]},
"taskType": "RETRIEVAL_DOCUMENT"
}
]
}'Runs a model's tokenizer on input Content and returns the token count. Refer to the tokens guide to learn more about tokens.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:countTokens - Path Parameter:
model:string(required). The model's resource name. Format:models/{model}.
- Request Body: CountTokensRequest
- Response Body: CountTokensResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-001:countTokens?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts":[{
"text": "How many tokens are in this sentence?"
}]
}]
}'Gets information about a specific Model such as its version number, token limits, and other metadata.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/models/{modelsId} - Path Parameter:
name:string(required). The resource name of the model. Format:models/{model}.
- Response Body: Model
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/models/gemini-1.5-flash-001?key=[YOUR_API_KEY]"Lists the Models available through the Gemini API.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/models - Query Parameters:
pageSize:integer. The maximum number ofModelsto return (per page).pageToken:string. A page token, received from a previousListModelscall.
- Response Body: ListModelsResponse
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/models?pageSize=50&key=[YOUR_API_KEY]"Generates a response from the model given an input message.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:generateText - Path Parameter:
model:string(required). The name of theModelorTunedModelto use. Example:models/text-bison-001.
- Request Body: GenerateTextRequest
- Response Body: GenerateTextResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/text-bison-001:generateText?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"prompt": {
"text": "Once upon a time"
},
"temperature": 0.7,
"candidateCount": 1
}'Generates an embedding from the model given an input message.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:embedText - Path Parameter:
model:string(required). The model name to use. Example:models/embedding-gecko-001.
- Request Body: EmbedTextRequest
- Response Body: EmbedTextResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/embedding-gecko-001:embedText?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"text": "Embed this sentence."
}'Generates multiple embeddings from the model given input text in a synchronous call.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:batchEmbedText - Path Parameter:
model:string(required). The name of theModelto use. Example:models/embedding-gecko-001.
- Request Body: BatchEmbedTextRequest
- Response Body: BatchEmbedTextResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/embedding-gecko-001:batchEmbedText?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"texts": [
"This is the first sentence.",
"Here is a second one."
]
}'Runs a model's tokenizer on a text and returns the token count.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/models/{modelsId}:countTextTokens - Path Parameter:
model:string(required). The model's resource name.
- Request Body: CountTextTokensRequest
- Response Body: CountTextTokensResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/models/text-bison-001:countTextTokens?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"prompt": {
"text": "Count the tokens in this text."
}
}'The tunedModels resource allows you to manage your fine-tuned models.
Creates a tuned model. Check intermediate tuning progress through the operations service.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/tunedModels - Query Parameter:
tunedModelId:string. Optional. The unique id for the tuned model.
- Request Body: TunedModel
- Response Body: Operation
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/tunedModels?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"displayName": "My Sentence Translator",
"baseModel": "models/gemini-1.5-flash-001",
"tuningTask": {
"trainingData": {
"examples": {
"examples": [
{
"textInput": "The cat sat on the mat.",
"output": "Le chat était assis sur le tapis."
},
{
"textInput": "I love to read books.",
"output": "J'adore lire des livres."
}
]
}
},
"hyperparameters": {
"epochCount": 5
}
}
}'Gets information about a specific TunedModel.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/tunedModels/{tunedModelsId} - Path Parameter:
name:string(required). The resource name of the model. Format:tunedModels/my-model-id.
- Response Body: TunedModel
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/tunedModels/sentence-translator-u3b7m?key=[YOUR_API_KEY]"Lists created tuned models.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/tunedModels - Query Parameters:
pageSize:integer. The maximum number ofTunedModelsto return.pageToken:string. A page token from a previous call.filter:string. A filter to search over the tuned model's description and display name.
- Response Body: ListTunedModelsResponse
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/tunedModels?pageSize=10&filter=owner:me&key=[YOUR_API_KEY]"Updates a tuned model.
- HTTP Request:
PATCH https://generativelanguage.googleapis.com/v1beta/tunedModels/{tunedModelsId} - Path Parameter:
name:string(required). The tuned model name. Example:tunedModels/sentence-translator-u3b7m.
- Query Parameter:
updateMask:string. The list of fields to update.
- Request Body: TunedModel
- Response Body: TunedModel
Example curl request:
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/tunedModels/sentence-translator-u3b7m?updateMask=displayName&key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"displayName": "My Awesome French Translator"
}'Deletes a tuned model.
- HTTP Request:
DELETE https://generativelanguage.googleapis.com/v1beta/tunedModels/{tunedModelsId} - Path Parameter:
name:string(required). The resource name of the model. Format:tunedModels/my-model-id.
- Response Body: Empty
Example curl request:
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/tunedModels/sentence-translator-u3b7m?key=[YOUR_API_KEY]"Transfers ownership of the tuned model. This is the only way to change ownership of the tuned model. The current owner will be downgraded to writer role.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/tunedModels/{tunedModelsId}:transferOwnership - Path Parameter:
name:string(required). The resource name of the tuned model to transfer ownership. Format:tunedModels/my-model-id.
- Request Body: TransferOwnershipRequest
- Response Body: TransferOwnershipResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/tunedModels/my-model-id:transferOwnership?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"emailAddress": "[email protected]"
}'Generates a model response from a tuned model given an input GenerateContentRequest.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/tunedModels/{tunedModelsId}:generateContent - Path Parameter:
model:string(required). The name of theTunedModelto use. Format:tunedModels/{tuned_model_id}.
- Request Body: GenerateContentRequest
- Response Body: GenerateContentResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/tunedModels/sentence-translator-u3b7m:generateContent?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"contents": [{
"parts":[{
"text": "The quick brown fox jumps over the lazy dog."
}]
}]
}'The files resource allows you to upload and manage files for use with the API.
Creates a File. This is done by uploading the file content.
- HTTP Request:
POST https://generativelanguage.googleapis.com/upload/v1beta/files - Media Upload: This endpoint supports media uploads. You would typically use a client library to handle the multipart upload.
- Request Body: CreateFileRequest
- Response Body: CreateFileResponse
Example curl request (for a small file):
# This is a simplified example. For larger files, a resumable upload is recommended.
# The following assumes 'my-file.txt' and 'metadata.json' exist in the current directory.
# metadata.json content: { "file": { "displayName": "My Awesome File" } }
curl -X POST "https://generativelanguage.googleapis.com/upload/v1beta/files?key=[YOUR_API_KEY]" \
-H "Content-Type: multipart/related; boundary=foo_bar_baz" \
--data-binary @- <<EOF
--foo_bar_baz
Content-Type: application/json; charset=UTF-8
$(cat metadata.json)
--foo_bar_baz
Content-Type: text/plain
$(cat my-file.txt)
--foo_bar_baz--
EOFLists the metadata for Files owned by the requesting project.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/files - Query Parameters:
pageSize:integer. Maximum number ofFiles to return per page (max 100).pageToken:string. A page token from a previousListFilescall.
- Response Body: ListFilesResponse
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/files?pageSize=10&key=[YOUR_API_KEY]"Gets the metadata for the given File.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/files/{filesId} - Path Parameter:
name:string(required). The name of theFileto get. Example:files/abc-123.
- Response Body: File
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/files/abc-123?key=[YOUR_API_KEY]"Deletes the File.
- HTTP Request:
DELETE https://generativelanguage.googleapis.com/v1beta/files/{filesId} - Path Parameter:
name:string(required). The name of theFileto delete. Example:files/abc-123.
- Response Body: Empty
Example curl request:
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/files/abc-123?key=[YOUR_API_KEY]"The corpora resource manages collections of documents for semantic search and retrieval. A project can have up to 5 corpora.
Creates an empty Corpus.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora - Request Body: Corpus
- Response Body: Corpus
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"displayName": "My Research Papers"
}'Gets information about a specific Corpus.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId} - Path Parameter:
name:string(required). The name of theCorpus. Example:corpora/my-corpus-123.
- Response Body: Corpus
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c?key=[YOUR_API_KEY]"Updates a Corpus. Currently, this only supports updating displayName.
- HTTP Request:
PATCH https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId} - Path Parameter:
name:string(required). TheCorpusresource name.
- Query Parameter:
updateMask:string(required). The list of fields to update.
- Request Body: Corpus
- Response Body: Corpus
Example curl request:
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c?updateMask=displayName&key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"displayName": "Updated Research Papers Collection"
}'Deletes a Corpus.
- HTTP Request:
DELETE https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId} - Path Parameter:
name:string(required). The resource name of theCorpus.
- Query Parameter:
force:boolean. If set to true, anyDocuments and objects related to thisCorpuswill also be deleted.
- Response Body: Empty
Example curl request:
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c?force=true&key=[YOUR_API_KEY]"Lists all Corpora owned by the user.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/corpora - Query Parameters:
pageSize:integer. The maximum number ofCorporato return (max 20).pageToken:string. A page token from a previousListCorporacall.
- Response Body: ListCorporaResponse
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/corpora?pageSize=10&key=[YOUR_API_KEY]"Performs semantic search over a Corpus.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}:query - Path Parameter:
name:string(required). The name of theCorpusto query.
- Request Body: QueryCorpusRequest
- Response Body: QueryCorpusResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c:query?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"query": "What are the latest advancements in AI?",
"resultsCount": 5
}'The documents sub-resource manages documents within a corpus.
Creates an empty Document.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents - Path Parameter:
parent:string(required). The name of theCorpuswhere thisDocumentwill be created.
- Request Body: Document
- Response Body: Document
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c/documents?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"displayName": "Paper on Neural Networks"
}'Gets information about a specific Document.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId} - Path Parameter:
name:string(required). The name of theDocumentto retrieve.
- Response Body: Document
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c/documents/paper-on-neural-networks-456b789c123d?key=[YOUR_API_KEY]"Updates a Document.
- HTTP Request:
PATCH https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId} - Path Parameter:
name:string(required). TheDocumentresource name.
- Query Parameter:
updateMask:string(required). The list of fields to update.
- Request Body: Document
- Response Body: Document
Example curl request:
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c/documents/paper-on-neural-networks-456b789c123d?updateMask=displayName&key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"displayName": "2024 Paper on Advanced Neural Networks"
}'Deletes a Document.
- HTTP Request:
DELETE https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId} - Path Parameter:
name:string(required). The resource name of theDocument.
- Query Parameter:
force:boolean. If true, deletes relatedChunks as well.
- Response Body: Empty
Example curl request:
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c/documents/paper-on-neural-networks-456b789c123d?force=true&key=[YOUR_API_KEY]"Lists all Documents in a Corpus.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents - Path Parameter:
parent:string(required). The name of theCorpus.
- Query Parameters:
pageSize:integer. The maximum number ofDocuments to return.pageToken:string. A page token from a previous call.
- Response Body: ListDocumentsResponse
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c/documents?pageSize=10&key=[YOUR_API_KEY]"Performs semantic search over a Document.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}:query - Path Parameter:
name:string(required). The name of theDocumentto query.
- Request Body: QueryDocumentRequest
- Response Body: QueryDocumentResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora/my-research-papers-123a456b789c/documents/paper-on-neural-networks-456b789c123d:query?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"query": "What is a convolutional layer?",
"resultsCount": 3
}'The chunks sub-resource manages chunks of text within a document.
Creates a Chunk.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks - Path Parameter:
parent:string(required). The name of theDocumentfor the chunk.
- Request Body: Chunk
- Response Body: Chunk
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"data": {
"stringValue": "This is the first paragraph of the document, which will be stored as a chunk."
}
}'Batch create Chunks.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchCreate - Path Parameter:
parent:string(required). The parentDocument.
- Request Body: BatchCreateChunksRequest
- Response Body: BatchCreateChunksResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks:batchCreate?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"requests": [
{
"parent": "corpora/my-corpus-123/documents/the-doc-abc",
"chunk": { "data": { "stringValue": "Chunk number one." } }
},
{
"parent": "corpora/my-corpus-123/documents/the-doc-abc",
"chunk": { "data": { "stringValue": "Chunk number two." } }
}
]
}'Gets information about a specific Chunk.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId} - Path Parameter:
name:string(required). The name of theChunk.
- Response Body: Chunk
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk-id?key=[YOUR_API_KEY]"Updates a Chunk.
- HTTP Request:
PATCH https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId} - Path Parameter:
name:string(required). TheChunkresource name.
- Query Parameter:
updateMask:string(required). List of fields to update.
- Request Body: Chunk
- Response Body: Chunk
Example curl request:
curl -X PATCH "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk-id?updateMask=data&key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"data": { "stringValue": "This is the updated content for the chunk." }
}'Batch update Chunks.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchUpdate - Path Parameter:
parent:string(required). The parentDocument.
- Request Body: BatchUpdateChunksRequest
- Response Body: BatchUpdateChunksResponse
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks:batchUpdate?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"requests": [
{
"chunk": {
"name": "corpora/my-corpus-123/documents/the-doc-abc/chunks/chunk-one-id",
"data": { "stringValue": "Updated content for chunk one." }
},
"updateMask": "data"
},
{
"chunk": {
"name": "corpora/my-corpus-123/documents/the-doc-abc/chunks/chunk-two-id",
"data": { "stringValue": "Updated content for chunk two." }
},
"updateMask": "data"
}
]
}'Deletes a Chunk.
- HTTP Request:
DELETE https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks/{chunksId} - Path Parameter:
name:string(required). The resource name of theChunk.
- Response Body: Empty
Example curl request:
curl -X DELETE "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks/some-chunk-id?key=[YOUR_API_KEY]"Batch delete Chunks.
- HTTP Request:
POST https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks:batchDelete - Path Parameter:
parent:string(required). The parentDocument.
- Request Body: BatchDeleteChunksRequest
- Response Body: Empty
Example curl request:
curl -X POST "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks:batchDelete?key=[YOUR_API_KEY]" \
-H "Content-Type: application/json" \
-d '{
"requests": [
{ "name": "corpora/my-corpus-123/documents/the-doc-abc/chunks/chunk-one-id" },
{ "name": "corpora/my-corpus-123/documents/the-doc-abc/chunks/chunk-two-id" }
]
}'Lists all Chunks in a Document.
- HTTP Request:
GET https://generativelanguage.googleapis.com/v1beta/corpora/{corporaId}/documents/{documentsId}/chunks - Path Parameter:
parent:string(required). TheDocumentname.
- Query Parameters:
pageSize:integer. The maximum number ofChunks to return.pageToken:string. A page token from a previous call.
- Response Body: ListChunksResponse
Example curl request:
curl "https://generativelanguage.googleapis.com/v1beta/corpora/my-corpus-123/documents/the-doc-abc/chunks?pageSize=50&key=[YOUR_API_KEY]"