फ़ाइल इनपुट के तरीके
इस गाइड में, Gemini API को अनुरोध भेजते समय, मीडिया फ़ाइलें शामिल करने के अलग-अलग तरीकों के बारे में बताया गया है. जैसे, इमेज, ऑडियो, वीडियो, और दस्तावेज़. नए तरीके, Gemini API के सभी एंडपॉइंट पर काम करते हैं. इनमें बैच, इंटरैक्शन, और Live API शामिल हैं. सही तरीका चुनना, आपकी फ़ाइल के साइज़, डेटा सेव करने की जगह, और फ़ाइल का इस्तेमाल कितनी बार किया जाएगा, इस पर निर्भर करता है.
इनपुट के तौर पर कोई फ़ाइल शामिल करने का सबसे आसान तरीका है कि स्थानीय फ़ाइल को पढ़ा जाए और उसे किसी प्रॉम्प्ट में शामिल किया जाए. यहां दिए गए उदाहरण में, स्थानीय पीडीएफ़ फ़ाइल को पढ़ने का तरीका बताया गया है. इस तरीके से, सिर्फ़ 50 एमबी तक की पीडीएफ़ फ़ाइलें शामिल की जा सकती हैं. फ़ाइल इनपुट के टाइप और सीमाओं की पूरी सूची देखने के लिए, इनपुट के तरीकों की तुलना करने वाली टेबल देखें.
Python
from google import genai
import pathlib
client = genai.Client()
filepath = pathlib.Path('my_local_file.pdf')
prompt = "Summarize this document"
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input=[
{"type": "text", "text": prompt},
{"type": "document", "data": filepath.read_bytes(), "mime_type": "application/pdf"}
]
)
# Print the model's text response
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
import * as fs from 'node:fs';
const client = new GoogleGenAI({});
const prompt = "Summarize this document";
async function main() {
const filePath = 'my_local_file.pdf';
const interaction = await client.interactions.create({
model: "gemini-3-flash-preview",
input: [
{ type: "text", text: prompt },
{
type: "document",
data: fs.readFileSync(filePath).toString("base64"),
mimeType: "application/pdf"
}
]
});
const modelStep = interaction.steps.find(s => s.type === 'model_output');
if (modelStep) {
for (const contentBlock of modelStep.content) {
if (contentBlock.type === 'text') console.log(contentBlock.text);
}
}
}
main();
REST
# Encode the local file to base64
B64_CONTENT=$(base64 -w 0 my_local_file.pdf)
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": [
{"type": "text", "text": "Summarize this document"},
{
"type": "document",
"data": "'${B64_CONTENT}'",
"mimeType": "application/pdf"
}
]
}'
इनपुट के तरीकों की तुलना
यहां दी गई टेबल में, इनपुट के हर तरीके की तुलना, फ़ाइल की सीमाओं, और सबसे सही इस्तेमाल के उदाहरणों से की गई है. ध्यान दें कि फ़ाइल के टाइप और उसे प्रोसेस करने के लिए इस्तेमाल किए गए मॉडल या टोकनाइज़र के हिसाब से, फ़ाइल के साइज़ की सीमा अलग-अलग हो सकती है.
| तरीका | इन स्थितियों में बेहतर है | अधिकतम फ़ाइल आकार | फ़ाइल सेव करने की अवधि |
|---|---|---|---|
| इनलाइन डेटा | तेज़ी से टेस्ट करने, छोटी फ़ाइलों, रीयल-टाइम ऐप्लिकेशन के लिए. | हर अनुरोध या पेलोड के लिए 100 एमबी (पीडीएफ़ के लिए 50 एमबी) |
कोई नहीं (हर अनुरोध के साथ भेजा जाता है) |
| File API से अपलोड करना | बड़ी फ़ाइलों, एक से ज़्यादा बार इस्तेमाल की जाने वाली फ़ाइलों के लिए. | हर फ़ाइल के लिए दो जीबी, हर प्रोजेक्ट के लिए 20 जीबी तक |
48 घंटे |
| File API से GCS यूआरआई रजिस्टर करना | Google Cloud Storage में पहले से मौजूद बड़ी फ़ाइलों, एक से ज़्यादा बार इस्तेमाल की जाने वाली फ़ाइलों के लिए. | हर फ़ाइल के लिए दो जीबी, स्टोरेज की कोई सीमा नहीं | कोई नहीं (हर अनुरोध के लिए फ़ेच किया जाता है). एक बार रजिस्टर करने पर, 30 दिनों तक ऐक्सेस मिल सकता है. |
| एक्सटर्नल यूआरएल | सार्वजनिक डेटा या क्लाउड बकेट (AWS, Azure, GCS) में मौजूद डेटा को फिर से अपलोड किए बिना इस्तेमाल करने के लिए. | हर अनुरोध/पेलोड के लिए 100 एमबी | कोई नहीं (हर अनुरोध के लिए फ़ेच किया जाता है) |
इनलाइन डेटा
छोटी फ़ाइलों (100 एमबी से कम या पीडीएफ़ के लिए 50 एमबी) के लिए, डेटा को सीधे अनुरोध के पेलोड में पास किया जा सकता है. यह तरीका, तेज़ी से टेस्ट करने या रीयल-टाइम, ट्रांज़िएंट डेटा को मैनेज करने वाले ऐप्लिकेशन के लिए सबसे आसान है. बेस64 एनकोड की गई स्ट्रिंग के तौर पर डेटा उपलब्ध कराया जा सकता है या स्थानीय फ़ाइलों को सीधे पढ़कर डेटा उपलब्ध कराया जा सकता है.
स्थानीय फ़ाइल से पढ़ने के उदाहरण के लिए, इस पेज की शुरुआत में दिया गया उदाहरण देखें.
किसी यूआरएल से फ़ेच करना
किसी यूआरएल से फ़ाइल फ़ेच की जा सकती है, उसे बाइट में बदला जा सकता है, और उसे इनपुट में शामिल किया जा सकता है.
Python
from google import genai
import httpx
client = genai.Client()
doc_url = "https://discovery.ucl.ac.uk/id/eprint/10089234/1/343019_3_art_0_py4t4l_convrt.pdf"
doc_data = httpx.get(doc_url).content
prompt = "Summarize this document"
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input=[
{"type": "document", "data": doc_data, "mime_type": "application/pdf"},
{"type": "text", "text": prompt}
]
)
# Print the model's text response
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const docUrl = 'https://discovery.ucl.ac.uk/id/eprint/10089234/1/343019_3_art_0_py4t4l_convrt.pdf';
const prompt = "Summarize this document";
async function main() {
const pdfResp = await fetch(docUrl)
.then((response) => response.arrayBuffer());
const interaction = await client.interactions.create({
model: "gemini-3-flash-preview",
input: [
{ type: "text", text: prompt },
{
type: "document",
data: Buffer.from(pdfResp).toString("base64"),
mimeType: "application/pdf"
}
]
});
const modelStep = interaction.steps.find(s => s.type === 'model_output');
if (modelStep) {
for (const contentBlock of modelStep.content) {
if (contentBlock.type === 'text') console.log(contentBlock.text);
}
}
}
main();
REST
DOC_URL="https://discovery.ucl.ac.uk/id/eprint/10089234/1/343019_3_art_0_py4t4l_convrt.pdf"
PROMPT="Summarize this document"
DISPLAY_NAME="base64_pdf"
# Download the PDF
wget -O "${DISPLAY_NAME}.pdf" "${DOC_URL}"
# Check for FreeBSD base64 and set flags accordingly
if [[ "$(base64 --version 2>&1)" = *"FreeBSD"* ]]; then
B64FLAGS="--input"
else
B64FLAGS="-w0"
fi
# Base64 encode the PDF
ENCODED_PDF=$(base64 $B64FLAGS "${DISPLAY_NAME}.pdf")
# Generate content using interactions
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": [
{"type": "document", "data": "'$ENCODED_PDF'", "mimeType": "application/pdf"},
{"type": "text", "text": "'$PROMPT'"}
]
}' 2> /dev/null > response.json
cat response.json
echo
jq ".steps[] | select(.type == \"model_output\") | .content[] | select(.type == \"text\") | .text" response.json
Gemini File API
File API, दो जीबी तक की बड़ी फ़ाइलों या एक से ज़्यादा अनुरोधों में इस्तेमाल की जाने वाली फ़ाइलों के लिए डिज़ाइन किया गया है.
फ़ाइल अपलोड करने का स्टैंडर्ड तरीका
Gemini API पर कोई स्थानीय फ़ाइल अपलोड करें. इस तरीके से अपलोड की गई फ़ाइलें, अस्थायी तौर पर (48 घंटे) सेव की जाती हैं. साथ ही, मॉडल की मदद से उन्हें आसानी से वापस पाने के लिए प्रोसेस किया जाता है.
Python
from google import genai
client = genai.Client()
# Upload the file
audio_file = client.files.upload(file="path/to/your/sample.mp3")
prompt = "Describe this audio clip"
# Use the uploaded file in an interaction
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input=[
{"type": "text", "text": prompt},
{"type": "audio", "uri": audio_file.uri, "mime_type": audio_file.mime_type}
]
)
# Print the model's text response
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
JavaScript
import { GoogleGenAI } from "@google/genai";
const client = new GoogleGenAI({});
const prompt = "Describe this audio clip";
async function main() {
const filePath = "path/to/your/sample.mp3";
const myfile = await client.files.upload({
file: filePath,
config: { mimeType: "audio/mpeg" },
});
const interaction = await client.interactions.create({
model: "gemini-3-flash-preview",
input: [
{ type: "text", text: prompt },
{ type: "audio", uri: myfile.uri, mimeType: myfile.mimeType }
]
});
const modelStep = interaction.steps.find(s => s.type === 'model_output');
if (modelStep) {
for (const contentBlock of modelStep.content) {
if (contentBlock.type === 'text') console.log(contentBlock.text);
}
}
}
await main();
REST
AUDIO_PATH="path/to/sample.mp3"
MIME_TYPE=$(file -b --mime-type "${AUDIO_PATH}")
NUM_BYTES=$(wc -c < "${AUDIO_PATH}")
DISPLAY_NAME=AUDIO
tmp_header_file=upload-header.tmp
# Initial resumable request defining metadata.
curl "https://generativelanguage.googleapis.com/upload/v1beta/files" \
-D "${tmp_header_file}" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H "X-Goog-Upload-Protocol: resumable" \
-H "X-Goog-Upload-Command: start" \
-H "X-Goog-Upload-Header-Content-Length: ${NUM_BYTES}" \
-H "X-Goog-Upload-Header-Content-Type: ${MIME_TYPE}" \
-H "Content-Type: application/json" \
-d "{'file': {'display_name': '${DISPLAY_NAME}'}}" 2> /dev/null
upload_url=$(grep -i "x-goog-upload-url: " "${tmp_header_file}" | cut -d" " -f2 | tr -d "\r")
rm "${tmp_header_file}"
# Upload the actual bytes.
curl "${upload_url}" \
-H "Content-Length: ${NUM_BYTES}" \
-H "X-Goog-Upload-Offset: 0" \
-H "X-Goog-Upload-Command: upload, finalize" \
--data-binary "@${AUDIO_PATH}" 2> /dev/null > file_info.json
file_uri=$(jq ".file.uri" file_info.json)
# Now use in an interaction
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H "x-goog-api-key: $GEMINI_API_KEY" \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": [
{"type": "text", "text": "Describe this audio clip"},
{"type": "audio", "uri": '$file_uri', "mimeType": "'${MIME_TYPE}'"}
]
}'
Google Cloud Storage में मौजूद फ़ाइलें रजिस्टर करना
अगर आपका डेटा पहले से ही Google Cloud Storage में मौजूद है, तो उसे डाउनलोड करके फिर से अपलोड करने की ज़रूरत नहीं है. उसे सीधे File API से रजिस्टर किया जा सकता है.
हर बकेट को सर्विस एजेंट का ऐक्सेस दें
अपने Google Cloud प्रोजेक्ट में Gemini API चालू करें.
सर्विस एजेंट बनाएं:
gcloud beta services identity create --service=generativelanguage.googleapis.com --project=<your_project>Gemini API के सर्विस एजेंट को, आपकी स्टोरेज बकेट पढ़ने की अनुमतियां दें.
उपयोगकर्ता को, उन स्टोरेज बकेट के लिए इस सर्विस एजेंट को
Storage Object ViewerIAM की भूमिका असाइन करनी होगी जिनका इस्तेमाल करना है.
डिफ़ॉल्ट रूप से, यह ऐक्सेस कभी खत्म नहीं होता. हालांकि, इसे किसी भी समय बदला जा सकता है. अनुमतियां देने के लिए, Google Cloud Storage IAM SDK के कमांड भी इस्तेमाल किए जा सकते हैं.
अपनी सेवा की पुष्टि करें
ज़रूरी शर्तें
- एपीआई चालू करना
- सही अनुमतियों वाला कोई सेवा खाता या एजेंट बनाना.
सबसे पहले, आपको उस सेवा के तौर पर पुष्टि करनी होगी जिसके पास स्टोरेज ऑब्जेक्ट व्यूअर की अनुमतियां हैं. यह इस बात पर निर्भर करता है कि आपकी फ़ाइल मैनेजमेंट का कोड किस एनवायरमेंट में चलेगा.
Google Cloud के बाहर
अगर आपका कोड Google Cloud के बाहर चल रहा है, जैसे कि आपके डेस्कटॉप पर, तो Google Cloud Console से खाते के क्रेडेंशियल डाउनलोड करें. इसके लिए, यह तरीका अपनाएं:
- सेवा खाते के कंसोल पर जाएं
- काम का सेवा खाता चुनें
- पासकोड टैब चुनें और पासकोड जोड़ें, नया पासकोड बनाएं को चुनें
- JSON पासकोड टाइप चुनें और ध्यान दें कि फ़ाइल आपके कंप्यूटर पर कहां डाउनलोड हुई है.
इसके बाद, पुष्टि करने के लिए ये कमांड इस्तेमाल करें. इन कमांड से यह माना जाता है कि आपका सेवा खाता, मौजूदा डायरेक्ट्री में है और उसका नाम
service-account.jsonहै.Python
from google.oauth2.service_account import Credentials GCS_READ_SCOPES = [ 'https://www.googleapis.com/auth/devstorage.read_only', 'https://www.googleapis.com/auth/cloud-platform' ] SERVICE_ACCOUNT_FILE = 'service-account.json' credentials = Credentials.from_service_account_file( SERVICE_ACCOUNT_FILE, scopes=GCS_READ_SCOPES )Javascript
const { GoogleAuth } = require('google-auth-library'); const GCS_READ_SCOPES = [ 'https://www.googleapis.com/auth/devstorage.read_only', 'https://www.googleapis.com/auth/cloud-platform' ]; const SERVICE_ACCOUNT_FILE = 'service-account.json'; const auth = new GoogleAuth({ keyFile: SERVICE_ACCOUNT_FILE, scopes: GCS_READ_SCOPES });CLI
gcloud auth application-default login \ --client-id-file=service-account.json \ --scopes='https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/devstorage.read_only'Google Cloud पर
अगर आपका कोड सीधे Google Cloud में चल रहा है, जैसे कि Cloud Run फ़ंक्शन या Compute Engine इंस्टेंस का इस्तेमाल करके, तो आपके पास इंप्लिसिट क्रेडेंशियल होंगे. हालांकि, सही स्कोप देने के लिए, आपको फिर से पुष्टि करनी होगी.
Python
इस कोड से यह माना जाता है कि सेवा ऐसे एनवायरमेंट में चल रही है जहां ऐप्लिकेशन के डिफ़ॉल्ट क्रेडेंशियल अपने-आप हासिल किए जा सकते हैं. जैसे, Cloud Run या Compute Engine.
import google.auth GCS_READ_SCOPES = [ 'https://www.googleapis.com/auth/devstorage.read_only', 'https://www.googleapis.com/auth/cloud-platform' ] credentials, project = google.auth.default(scopes=GCS_READ_SCOPES)JavaScript
इस कोड से यह माना जाता है कि सेवा ऐसे एनवायरमेंट में चल रही है जहां ऐप्लिकेशन के डिफ़ॉल्ट क्रेडेंशियल अपने-आप हासिल किए जा सकते हैं. जैसे, Cloud Run या Compute Engine.
const { GoogleAuth } = require('google-auth-library'); const auth = new GoogleAuth({ scopes: [ 'https://www.googleapis.com/auth/devstorage.read_only', 'https://www.googleapis.com/auth/cloud-platform' ] });CLI
यह एक इंटरैक्टिव कमांड है. Compute Engine जैसी सेवाओं के लिए, कॉन्फ़िगरेशन लेवल पर चल रही सेवा में स्कोप जोड़े जा सकते हैं. उदाहरण के लिए, उपयोगकर्ता मैनेज करने वाली सेवा दस्तावेज़ देखें.
gcloud auth application-default login \ --scopes="https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/devstorage.read_only"फ़ाइल रजिस्टर करना (Files API)
फ़ाइलें रजिस्टर करने के लिए, Files API का इस्तेमाल करें. इससे Files API का पाथ जनरेट होता है. इसका इस्तेमाल सीधे Gemini API में किया जा सकता है.
Python
from google import genai # Note that you must provide an API key in the GEMINI_API_KEY # environment variable, but it is unused for the registration endpoint. client = genai.Client(credentials=credentials) registered_gcs_files = client.files.register_files( uris=["gs://my_bucket/some_object.pdf", "gs://bucket2/object2.txt"] ) prompt = "Summarize this file." # call interactions.create for each file for f in registered_gcs_files.files: print(f.name) interaction = client.interactions.create( model="gemini-3-flash-preview", input=[ {"type": "text", "text": prompt}, {"type": "document", "uri": f.uri, "mime_type": f.mime_type} ], ) # Print the model's text response for step in interaction.steps: if step.type == "model_output": for content_block in step.content: if content_block.type == "text": print(content_block.text)JavaScript
import { GoogleGenAI } from "@google/genai"; const ai = new GoogleGenAI({ auth: auth }); async function main() { const registeredGcsFiles = await ai.files.registerFiles({ uris: ["gs://my_bucket/some_object.pdf", "gs://bucket2/object2.txt"] }); const prompt = "Summarize this file."; for (const file of registeredGcsFiles.files) { console.log(file.name); const interaction = await ai.interactions.create({ model: "gemini-3-flash-preview", input: [ { type: "text", text: prompt }, { type: "document", uri: file.uri, mimeType: file.mimeType } ] }); const modelStep = interaction.steps.find(s => s.type === 'model_output'); if (modelStep) { for (const contentBlock of modelStep.content) { if (contentBlock.type === 'text') console.log(contentBlock.text); } } } } main();CLI
access_token=$(gcloud auth application-default print-access-token) project_id=$(gcloud config get-value project) curl -X POST https://generativelanguage.googleapis.com/v1beta/files:register \ -H 'Content-Type: application/json' \ -H "Authorization: Bearer ${access_token}" \ -H "x-goog-user-project: ${project_id}" \ -d '{"uris": ["gs://bucket/object1", "gs://bucket/object2"]}'
एक्सटर्नल एचटीटीपी / साइन किए गए यूआरएल
सार्वजनिक तौर पर ऐक्सेस किए जा सकने वाले एचटीटीपीएस यूआरएल या पहले से साइन किए गए यूआरएल को सीधे अपने अनुरोध में पास किया जा सकता है. प्रोसेसिंग के दौरान, Gemini API सुरक्षित तरीके से कॉन्टेंट फ़ेच करेगा. यह 100 एमबी तक की उन फ़ाइलों के लिए सही है जिन्हें आपको फिर से अपलोड नहीं करना है.
Python
from google import genai
uri = "https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf"
prompt = "Summarize this file"
client = genai.Client()
interaction = client.interactions.create(
model="gemini-3-flash-preview",
input=[
{"type": "document", "uri": uri, "mime_type": "application/pdf"},
{"type": "text", "text": prompt}
]
)
# Print the model's text response
for step in interaction.steps:
if step.type == "model_output":
for content_block in step.content:
if content_block.type == "text":
print(content_block.text)
Javascript
import { GoogleGenAI } from '@google/genai';
const client = new GoogleGenAI({});
const uri = "https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf";
async function main() {
const interaction = await client.interactions.create({
model: 'gemini-3-flash-preview',
input: [
{ type: "document", uri: uri, mimeType: "application/pdf" },
{ type: "text", text: "summarize this file" }
]
});
const modelStep = interaction.steps.find(s => s.type === 'model_output');
if (modelStep) {
for (const contentBlock of modelStep.content) {
if (contentBlock.type === 'text') console.log(contentBlock.text);
}
}
}
main();
REST
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
-H 'x-goog-api-key: $GEMINI_API_KEY' \
-H 'Content-Type: application/json' \
-d '{
"model": "gemini-3-flash-preview",
"input": [
{"type": "text", "text": "Summarize this pdf"},
{
"type": "document",
"uri": "https://ontheline.trincoll.edu/images/bookdown/sample-local-pdf.pdf",
"mimeType": "application/pdf"
}
]
}'
सुलभता
पक्का करें कि आपके दिए गए यूआरएल, ऐसे पेजों पर न ले जाएं जिनके लिए लॉगिन करने की ज़रूरत हो या जिन पर paywall लागू किया गया हो. निजी डेटाबेस के लिए, पक्का करें कि आपने सही ऐक्सेस अनुमतियों और समयसीमा के साथ साइन किया गया यूआरएल बनाया हो.
सुरक्षा जांच
सिस्टम, यूआरएल पर कॉन्टेंट मॉडरेशन की जांच करता है, ताकि यह पक्का किया जा सके कि वे सुरक्षा और नीति के मानकों के मुताबिक हैं. अगर यूआरएल इस जांच में पास नहीं होता है, तो आपको url_retrieval_status की वैल्यू URL_RETRIEVAL_STATUS_UNSAFE मिलेगी.
इस तरह के कॉन्टेंट प्रोसेस किए जा सकते हैं
इस्तेमाल किए जा सकने वाले फ़ाइल टाइप और सीमाओं की यह सूची, शुरुआती दिशा-निर्देश के तौर पर दी गई है. यह पूरी सूची नहीं है. इस्तेमाल किए जा सकने वाले टाइप का सेट बदल सकता है. साथ ही, इस्तेमाल किए जा रहे मॉडल और टोकनाइज़र के वर्शन के हिसाब से, यह अलग-अलग हो सकता है. इस्तेमाल न किए जा सकने वाले टाइप की वजह से गड़बड़ी होगी. इसके अलावा, इन फ़ाइल टाइप के लिए कॉन्टेंट वापस पाने की सुविधा, सिर्फ़ सार्वजनिक तौर पर ऐक्सेस किए जा सकने वाले यूआरएल के लिए उपलब्ध है.
टेक्स्ट फ़ाइल के टाइप
text/htmltext/csstext/plaintext/xmltext/csvtext/rtftext/javascript
ऐप्लिकेशन फ़ाइल के टाइप
application/jsonapplication/pdf
इमेज फ़ाइल के टाइप
image/bmpimage/jpegimage/pngimage/webp
सबसे सही तरीके
- सही तरीका चुनें: छोटी, ट्रांज़िएंट फ़ाइलों के लिए, इनलाइन डेटा का इस्तेमाल करें. बड़ी या बार-बार इस्तेमाल की जाने वाली फ़ाइलों के लिए, File API का इस्तेमाल करें. ऑनलाइन होस्ट किए गए डेटा के लिए, एक्सटर्नल यूआरएल का इस्तेमाल करें.
- MIME टाइप तय करें: फ़ाइल डेटा को सही तरीके से प्रोसेस करने के लिए, हमेशा फ़ाइल डेटा का सही MIME टाइप दें.
- गड़बड़ियों को मैनेज करें: नेटवर्क में आने वाली समस्याओं, फ़ाइल ऐक्सेस करने में आने वाली समस्याओं या एपीआई से जुड़ी गड़बड़ियों जैसी संभावित समस्याओं को मैनेज करने के लिए, अपने कोड में गड़बड़ी को मैनेज करने की सुविधा लागू करें.
सीमाएं
- फ़ाइल के साइज़ की सीमाएं, तरीके (तुलना करने वाली टेबल देखें) और फ़ाइल के टाइप के हिसाब से अलग-अलग होती हैं.
- इनलाइन डेटा से, अनुरोध के पेलोड का साइज़ बढ़ जाता है.
- File API से अपलोड की गई फ़ाइलें, अस्थायी तौर पर सेव होती हैं और 48 घंटे बाद खत्म हो जाती हैं.
- एक्सटर्नल यूआरएल से फ़ेच करने की सीमा, हर पेलोड के लिए 100 एमबी है. साथ ही, यह सुविधा सिर्फ़ कुछ खास तरह के कॉन्टेंट के लिए उपलब्ध है.
आगे क्या करना है
- Google AI Studio का इस्तेमाल करके, मल्टीमॉडल प्रॉम्प्ट लिखें.
- अपने प्रॉम्प्ट में फ़ाइलें शामिल करने के बारे में जानने के लिए, Vision, ऑडियो, और दस्तावेज़ प्रोसेसिंग की गाइड देखें.