Files API

Files API

Gemini는 텍스트, 이미지, 오디오를 포함한 다양한 유형의 입력 데이터를 동시에 처리할 수 있어요.

이 가이드는 Files API로 미디어 파일을 다루는 방법을 보여줘요. 기본 작업은 오디오 파일, 이미지, 비디오, 문서 및 기타 지원 파일 유형에서 동일해요.

파일 프롬프팅 지침은 파일 프롬프트 가이드 섹션을 확인하세요.

출처: 원문

본문

파일 업로드

Files API를 사용해 미디어 파일을 업로드할 수 있어요. 파일, 텍스트 프롬프트, 시스템 지침 등을 포함한 총 요청 크기가 100MB보다 클 때는 항상 Files API를 사용하세요. PDF 파일의 한도는 50MB예요.

다음 코드는 파일을 업로드한 다음 interactions.create 호출에서 그 파일을 사용해요.

from google import genai

client = genai.Client()

myfile = client.files.upload(file="path/to/sample.mp3")

interaction = client.interactions.create(
    model="gemini-3.8-flash",
    input=[
        {"type": "text", "text": "Describe this audio clip"},
        {"type": "audio", "uri": myfile.uri, "mime_type": myfile.mime_type}
    ]
)

print(interaction.output_text)
import { GoogleGenAI } from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const myfile = await client.files.upload({
    file: "path/to/sample.mp3",
    config: { mime_type: "audio/mpeg" },
  });

  const interaction = await client.interactions.create({
    model: "gemini-3.8-flash",
    input: [
      { type: "text", text: "Describe this audio clip" },
      { type: "audio", uri: myfile.uri, mime_type: myfile.mimeType }
    ]
  });
  console.log(interaction.output_text);
}

await main();
import com.google.genai.Client;
import com.google.genai.gaos.models.interactions.AudioContent;
import com.google.genai.gaos.models.interactions.AudioContentMimeType;
import com.google.genai.gaos.models.interactions.Content;
import com.google.genai.gaos.models.interactions.CreateModelInteraction;
import com.google.genai.gaos.models.interactions.Interaction;
import com.google.genai.gaos.models.interactions.InteractionsInput;
import com.google.genai.gaos.models.interactions.Model;
import com.google.genai.gaos.models.interactions.TextContent;
import com.google.genai.gaos.models.operations.CreateInteractionRequestBody;
import com.google.genai.types.File;
import com.google.genai.types.UploadFileConfig;
import java.util.Arrays;
import java.util.List;

Client client = new Client();

File myFile =
    client.files.upload(
        new java.io.File("path/to/sample.mp3"),
        UploadFileConfig.builder().mimeType("audio/mp3").build());

Content textContent = TextContent.builder().text("Describe this audio clip").build();
Content audioContent =
    AudioContent.builder()
        .uri(myFile.uri().orElse(""))
        .mimeType(AudioContentMimeType.of(myFile.mimeType().orElse("audio/mp3")))
        .build();

List<Content> contents = Arrays.asList(textContent, audioContent);

CreateModelInteraction params =
    CreateModelInteraction.builder()
        .model(Model.of("gemini-3.8-flash"))
        .input(InteractionsInput.ofContent(contents))
        .build();

Interaction interaction =
    client.interactions.create(CreateInteractionRequestBody.of(params)).interaction().get();

System.out.println(interaction.outputText().orElse(""));
package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
    "google.golang.org/genai/interactions/models/interactions"
    "google.golang.org/genai/interactions/models/operations"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    myFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", &genai.UploadFileConfig{
        MIMEType: "audio/mp3",
    })
    if err != nil {
        log.Fatal(err)
    }

    res, err := client.Interactions.Create(ctx, operations.CreateInteractionRequest{
        Body: operations.NewCreateInteractionRequestBody(interactions.CreateModelInteraction{
            Model: interactions.Model("gemini-3.8-flash"),
            Input: interactions.NewInteractionsInput([]interactions.Content{
                interactions.NewContent(interactions.TextContent{
                    Text: "Describe this audio clip",
                }),
                interactions.NewContent(interactions.AudioContent{
                    URI:      genai.Ptr(myFile.URI),
                    MimeType: interactions.AudioContentMimeType(myFile.MIMEType).ToPointer(),
                }),
            }),
        }),
    })
    if err != nil {
        log.Fatal(err)
    }
    if res.Interaction.OutputText != nil {
        fmt.Println(*res.Interaction.OutputText)
    }
}
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.
# The upload url is in the response headers dump them to a file.
curl "${BASE_URL}/upload/v1beta/files" \
  -H "x-goog-api-key: *** \
  -D "${tmp_header_file}" \
  -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)
echo file_uri=$file_uri

# Now create an interaction using the Interactions API
curl -X POST "https://generativelanguage.googleapis.com/v1beta/interactions" \
    -H "x-goog-api-key: *** \
    -H 'Content-Type: application/json' \
    -d '{
      "model": "gemini-3.8-flash",
      "input": [
        {"type": "text", "text": "Describe this audio clip"},
        {"type": "audio", "uri": '$file_uri', "mime_type": "'${MIME_TYPE}'"}
      ]
    }' 2> /dev/null > response.json

cat response.json
echo

jq ".outputs[] | select(.type == \"text\") | .text" response.json

파일 메타데이터 가져오기

files.get을 호출해 API가 업로드된 파일을 성공적으로 저장했는지 확인하고 해당 메타데이터를 얻을 수 있어요.

from google import genai

client = genai.Client()

myfile = client.files.upload(file='path/to/sample.mp3')
file_name = myfile.name
myfile = client.files.get(name=file_name)
print(myfile)
import {
  GoogleGenAI,
} from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const myfile = await client.files.upload({
    file: "path/to/sample.mp3",
    config: { mime_type: "audio/mpeg" },
  });

  const fileName = myfile.name;
  const fetchedFile = await client.files.get({ name: fileName });
  console.log(fetchedFile);
}

await main();
import com.google.genai.Client;
import com.google.genai.types.File;
import com.google.genai.types.UploadFileConfig;

Client client = new Client();

File myFile =
    client.files.upload(
        new java.io.File("path/to/sample.mp3"),
        UploadFileConfig.builder().mimeType("audio/mp3").build());

String fileName = myFile.name().orElse("");
File fileMetadata = client.files.get(fileName, null);
System.out.println(fileMetadata);
package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    myFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", &genai.UploadFileConfig{
        MIMEType: "audio/mp3",
    })
    if err != nil {
        log.Fatal(err)
    }

    fileMetadata, err := client.Files.Get(ctx, myFile.Name, nil)
    if err != nil {
        log.Fatal(err)
    }
    fmt.Println(fileMetadata)
}
# file_info.json was created in the upload example
name=$(jq -r ".file.name" file_info.json)
# Get the file of interest to check state
curl https://generativelanguage.googleapis.com/v1beta/$name \
-H "x-goog-api-key: *** > file_info.json
# Print some information about the file you got
name=$(jq -r ".name" file_info.json)
echo name=$name
file_uri=$(jq -r ".uri" file_info.json)
echo file_uri=$file_uri

업로드된 파일 나열

다음 코드는 업로드된 모든 파일의 목록을 가져와요.

from google import genai

client = genai.Client()

print('My files:')
for f in client.files.list():
    print(' ', f.name)
import {
  GoogleGenAI,
} from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const listResponse = await client.files.list({ config: { pageSize: 10 } });
  for await (const file of listResponse) {
    console.log(file.name);
  }
}

await main();
import com.google.genai.Client;
import com.google.genai.types.File;

Client client = new Client();

System.out.println("My files:");
for (File f : client.files.list(null)) {
  System.out.println("  " + f.name().orElse(""));
}
package main

import (
    "context"
    "fmt"
    "log"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    fmt.Println("My files:")
    for f, err := range client.Files.All(ctx) {
        if err != nil {
            log.Fatal(err)
        }
        fmt.Println(" ", f.Name)
    }
}
echo "My files: "

curl "https://generativelanguage.googleapis.com/v1beta/files" \
  -H "x-goog-api-key: ***

업로드된 파일 삭제

파일은 48시간 후 자동으로 삭제돼요. 업로드된 파일을 수동으로 삭제할 수도 있어요.

from google import genai

client = genai.Client()

myfile = client.files.upload(file='path/to/sample.mp3')
client.files.delete(name=myfile.name)
import {
  GoogleGenAI,
} from "@google/genai";

const client = new GoogleGenAI({});

async function main() {
  const myfile = await client.files.upload({
    file: "path/to/sample.mp3",
    config: { mime_type: "audio/mpeg" },
  });

  const fileName = myfile.name;
  await client.files.delete({ name: fileName });
}

await main();
import com.google.genai.Client;
import com.google.genai.types.File;
import com.google.genai.types.UploadFileConfig;

Client client = new Client();

File myFile =
    client.files.upload(
        new java.io.File("path/to/sample.mp3"),
        UploadFileConfig.builder().mimeType("audio/mp3").build());

client.files.delete(myFile.name().orElse(""), null);
package main

import (
    "context"
    "log"

    "google.golang.org/genai"
)

func main() {
    ctx := context.Background()
    client, err := genai.NewClient(ctx, nil)
    if err != nil {
        log.Fatal(err)
    }

    myFile, err := client.Files.UploadFromPath(ctx, "path/to/sample.mp3", &genai.UploadFileConfig{
        MIMEType: "audio/mp3",
    })
    if err != nil {
        log.Fatal(err)
    }

    if _, err := client.Files.Delete(ctx, myFile.Name, nil); err != nil {
        log.Fatal(err)
    }
}
curl --request "DELETE" https://generativelanguage.googleapis.com/v1beta/$name \
  -H "x-goog-api-key: ***

사용 정보

Files API를 사용해 미디어 파일을 업로드하고 상호작용할 수 있어요. Files API는 프로젝트당 최대 20GB의 파일을 저장할 수 있으며, 파일당 최대 크기는 2GB예요. 파일은 48시간 동안 저장돼요.

그 시간 동안 API를 사용해 파일에 대한 메타데이터를 얻을 수 있어요. 그러나 사용자가 업로드한 파일은 다운로드할 수 없어요. 비디오 같은 모델이 생성한 파일은 files.download 메서드로 다운로드할 수 있어요. Files API는 Gemini API를 사용할 수 있는 모든 지역에서 무료로 제공돼요.

파일 프롬프팅 전략

이 섹션은 Gemini API에서 미디어 파일을 프롬프트와 함께 사용하는 방법에 대한 지침과 모범 사례를 제공해요.

프롬프트에서 다양한 유형의 데이터를 사용할 수 있다는 것은 Gemini API로 처리할 수 있는 작업 측면에서 더 많은 유연성을 제공해요. 예를 들어 모델에 맛있는 식사의 사진을 보내고 그 식사에 대한 짧은 블로그를 작성하도록 요청할 수 있어요.

프롬프트 응답
이 사진을 바탕으로 짧고 매력적인 블로그 게시물을 작성해. 사진 속 식사에 대한 설명과 내 밀프레프(meal prep) 여정에 대한 이야기를 포함해야 해. Meal prepping is a great way to save time and money, and it can also help you to eat healthier. This meal is a great example of a healthy and delicious meal that can be prepped ahead of time. This meal features brown rice, roasted vegetables, and chicken teriyaki. The brown rice is a healthy and complex carbohydrate that will give you sustained energy. The roasted vegetables are a great way to get your daily dose of vitamins and minerals, and the chicken teriyaki is a delicious and protein-rich option. This meal is also straightforward to prepare. Simply cook the brown rice, roast the vegetables, and cook the chicken teriyaki. Once everything is cooked, divide it into meal prep containers and store them in the refrigerator. You can then grab a container and go on busy mornings! If you're looking for a healthy and delicious meal that can be prepped ahead of time, this meal is a great option. It's packed with nutrients and flavor, and it's sure to keep you feeling full and satisfied. Here's to healthy and delicious meal prepping!

미디어 파일을 사용하는 프롬프트에서 원하는 출력을 얻는 데 어려움이 있다면, 원하는 결과를 얻는 데 도움이 되는 몇 가지 전략이 있어요. 다음 섹션은 멀티모달 입력을 사용하는 프롬프트를 개선하기 위한 설계 접근 방식과 트러블슈팅 팁을 제공해요.

다음 모범 사례를 따르면 멀티모달 프롬프트를 개선할 수 있어요.

  • 프롬프트 설계 기본 사항: 지침을 구체적으로 작성하세요. 오해의 여지가 거의 없는 명확하고 간결한 지침을 만드세요. 프롬프트에 몇 가지 예시를 추가하세요. 달성하려는 것을 설명하는 현실적인 few-shot 예시를 사용하세요. 단계별로 나누세요. 복잡한 작업을 관리 가능한 하위 목표로 나누어 모델을 과정을 통해 안내하세요. 출력 형식을 지정하세요. 프롬프트에서 Markdown, JSON, HTML 등 원하는 형식으로 출력을 요청하세요. 단일 이미지 프롬프트에서는 이미지를 먼저 배치하세요. Gemini는 이미지와 텍스트 입력을 어떤 순서로든 처리할 수 있지만, 단일 이미지가 포함된 프롬프트에서는 그 이미지(또는 비디오)를 텍스트 프롬프트 앞에 배치하는 것이 더 잘 작동할 수 있어요. 그러나 이미지가 의미를 위해 텍스트와 고도로 번갈아 필요로 하는 프롬프트의 경우 가장 자연스러운 순서를 사용하세요.
  • 멀티모달 프롬프트 트러블슈팅: 모델이 이미지의 관련 부분에서 정보를 끌어오지 않는 경우: 프롬프트가 이미지의 어떤 측면에서 정보를 끌어내길 원하는지 힌트를 주세요. 모델 출력이 너무 일반적인 경우(이미지/비디오 입력에 충분히 맞춰지지 않은 경우): 프롬프트 시작 부분에서 작업 지침을 제공하기 전에 모델에게 이미지(들)나 비디오를 설명하도록 요청하거나, 모델에게 이미지에 무엇이 있는지 참조하도록 요청해 보세요. 어떤 부분이 실패했는지 트러블슈팅하려면: 모델에게 이미지를 설명하도록 요청하거나, 추론을 설명하도록 요청해 모델의 초기 이해도를 가늠하세요. 프롬프트가 환각 콘텐츠를 만드는 경우: temperature 설정을 낮추거나 모델에게 더 짧은 설명을 요청해 추가 세부 사항을 추정할 가능성을 줄여 보세요. 샘플링 매개변수 조정: 모델의 창의성을 조정하기 위해 다양한 temperature 설정과 top-k 선택을 실험해 보세요.

지침을 구체적으로 작성하기

프롬프트는 명확하고 상세할 때 가장 성공적이에요. 특정 출력을 염두에 두고 있다면 원하는 출력을 얻기 위해 그 요구사항을 프롬프트에 포함하는 것이 좋아요.

공항 게시판 이미지의 경우 모델에게 그냥 "이 이미지를 설명해"라고 요청하면 일반적인 설명이 생성될 수 있어요. 이미지에서 시간과 도시를 파싱해야 한다면 그 요청을 프롬프트에 직접 포함할 수 있어요.

프롬프트 모델 응답
이 이미지를 설명해. The image shows an airport arrivals and departures board.

업데이트된 프롬프트 / 개선된 응답

이 이미지에 표시된 공항 게시판에서 시간과 도시를 파싱해 목록으로 만들어.

10:50 Moscow
11:05 Edinburgh
11:05 London
11:10 Bucharest
11:30 Kiev
11:35 Dublin
11:45 East Midlands
12:15 Sofia
12:30 London
12:30 Newcastle
12:40 St Petersburg
12:40 London
12:45 Manchester

몇 가지 예시 추가하기

Gemini 모델은 원하는 출력을 이해하기 위해 예시로 사용할 수 있는 여러 입력을 받을 수 있어요. 이 예시를 추가하면 모델이 패턴을 식별하고 주어진 이미지와 응답 사이의 관계를 새 예시에 적용하는 데 도움이 돼요. 이를 "few-shot" 학습이라고도 해요.

다음 예시에서 초기 출력은 문장 형식으로 작성되었고 국가(브라질)도 포함돼요. 출력을 다른 형식이나 스타일로, 그리고 국가가 아닌 도시만 원한다고 가정해 보세요. 프롬프트에 few-shot 예시를 추가하면 모델이 원하는 방식으로 응답하도록 유도할 수 있어요.

프롬프트 / 모델 응답

도시와 랜드마크를 함께 판별해.

The landmark is the Christ the Redeemer statue in Rio de Janeiro, Brazil.

업데이트된 프롬프트 개선된 응답
도시와 랜드마크를 함께 판별해. city: Rome, landmark: the Colosseum.
city: Beijing, landmark: Forbidden City
city: Rio de Janeiro, landmark: Christ the Redeemer statue

단계별로 나누기

시각적 이해와 추론이 모두 필요한 복잡한 작업의 경우 작업을 더 작고 간단한 단계로 나누는 것이 도움이 될 수 있어요. 또는 프롬프트에서 모델에게 직접 "단계별로 생각하라"고 요청하는 것도 효과적일 수 있어요.

프롬프트 모델 응답
언제 화장지를 다 쓸까? Soon, you only have 3 rolls left.
업데이트된 프롬프트 개선된 응답
먼저 이 사진에 화장지가 몇 개인지 세어. 그다음 일반인이 하루에 화장지를 얼마나 쓰는지 판단해. 이 화장지들이 얼마나 오래갈지 계산해. There are 3 rolls of toilet paper in this picture. A typical person uses about 20 sheets of toilet paper per day. If each roll contains 200 sheets, then each roll will last for about 10 days. Therefore, the 3 rolls will last for about a month.

수학 문제나 다른 유형의 단어 문제는 모델에게 단계별로 생각하도록 요청하기 좋은 후보예요.

프롬프트 응답
수열에서 4번째 항은 무엇인가? -135

모델의 응답은 부정확해요. 개선 방법 중 하나는 프롬프트에 답하기 전에 문제를 파싱하도록 모델에게 요청하는 것이에요.

프롬프트 응답
먼저 이미지의 수식을 파싱해. 그런 다음 수식을 바탕으로 "수열에서 4번째 항은 무엇인가?"에 답해. Click to expand the result $$ b(n) = b(n-1) * (-3) $$ $$ b(1) = 15 $$ Substitute n = 4 into the formula: $$ b(4) = b(4-1) * (-3) $$ $$ b(4) = b(3) * (-3) $$ We don't know the value of b(3), so substitute n = 3 into the formula: $$ b(3) = b(3-1) * (-3) $$ $$ b(3) = b(2) * (-3) $$ We don't know the value of b(2), so substitute n = 2 into the formula: $$ b(2) = b(2-1) * (-3) $$ $$ b(2) = b(1) * (-3) $$ We know the value of b(1) is 15, so substitute it into the formula: $$ b(2) = 15 * (-3) $$ $$ b(2) = -45 $$ Now that we know the value of b(2), substitute it into the formula for b(3): $$ b(3) = b(2) * (-3) $$ $$ b(3) = -45 * (-3) $$ $$ b(3) = 135 $$ Now that we know the value of b(3), substitute it into the formula for b(4): $$ b(4) = b(3) * (-3) $$ $$ b(4) = 135 * (-3) $$ $$ b(4) = -405 $$ Therefore, the 4th term in the sequence is -405.

이 모델 응답은 정확해요. 이제 응답을 더 간결하게 만들려면 모델에게 단계별로 생각하도록 요청할 수 있어요.

업데이트된 프롬프트 / 개선된 응답

수열에서 4번째 항은 무엇인가? 단계별로 생각해.

The first term is 15.
The second term is b(1) * (-3) = 15 * (-3) = -45.
The third term is b(2) * (-3) = -45 * (-3) = 135.
The fourth term is b(3) * (-3) = 135 * (-3) = -405.

출력 형식 지정

흔한 문제는 모델 출력이 특정 형식(예: Markdown, JSON, HTML)이어야 하는 경우인데, 특히 모델 출력을 다운스트림 작업에서 처리해야 할 때 그래요. 프롬프트에서 모델에게 그렇게 지시해 해당 형식으로 출력을 생성해 보게 할 수 있어요. 다음은 두 가지 예시예요.

프롬프트 모델 응답
이 이미지의 표를 Markdown 형식으로 파싱해. ```none
프롬프트 모델 응답
다음 속성 목록을 JSON 형식으로 제공해: 재료, 요리 유형, 채식 여부 json { "ingredients": [ "rice", "shrimp", "clams", "mussels", "peas", "tomatoes", "onions", "garlic", "olive oil", "paprika", "salt", "pepper" ], "type of cuisine": "Spanish", "vegetarian": false }

단일 이미지 프롬프트에서는 이미지를 먼저 배치하기

Gemini는 프롬프트 내에서 이미지와 텍스트를 어떤 순서로든 해석할 수 있지만, 텍스트 프롬프트 앞에 단일 이미지를 배치하면 더 나은 결과를 얻을 수 있어요.

다음 샘플에서 각 프롬프트에서 텍스트 앞에 이미지가 먼저 오는 것을 볼 수 있어요.

멀티모달 프롬프트 트러블슈팅

도움이 되는 응답을 얻지 못하면 프롬프트를 트러블슈팅해야 할 수 있어요. 시도할 수 있는 몇 가지 전략이 있어요.

모델이 이미지의 관련 부분에서 정보를 끌어오지 않는 경우

더 구체적인 응답을 얻으려면 프롬프트가 이미지의 어떤 측면에서 정보를 끌어내기를 원하는지 지적할 수 있어요.

프롬프트 모델 응답
이 기저귀들은 아기에게 며칠이나 쓸 수 있을까? The diapers will last for 198 days before they run out.
업데이트된 프롬프트 개선된 응답
이 기저귀들이 다 떨어지기까지 얼마나 오래 쓸 수 있을까? 상자에 표시된 무게로 아이의 나이를 판단하고, 상자의 총 기저귀 수를 사용해. 총 수를 아이가 하루에 쓰는 기저귀 수로 나누어. The box contains 198 diapers. The box states the diapers are for a child weighing 22-37 lbs. The average child in this weight range is likely between 1 and 2 years old. A 2-year-old typically goes through 6 diapers per day, therefore, the diapers will last around 33 days (198/6).
모델 출력이 너무 일반적이고 이미지 입력에 충분히 맞춰지지 않은 경우

모델이 응답을 이미지(들)에 맞추도록 돕기 위해 추론 작업을 수행하기 전에 이미지를 설명하도록 요청해 보세요.

프롬프트 모델 응답
이 이미지들의 공통점은 무엇인가? All four images are examples of landscape photography.
업데이트된 프롬프트 개선된 응답
먼저 각 이미지에 무엇이 있는지 자세히 설명해. 이 이미지들의 공통점은 무엇인가? The first image shows a person packing a suitcase. The second image shows an empty hallway in a shopping mall. The third image shows a roll of toilet paper. The fourth image shows a dark and stormy sea. The commonality between these images is that they are all examples of liminal spaces. Liminal spaces are places or situations that are in between two other places or situations. They are often characterized by a sense of uncertainty or ambiguity. The first image shows the person in between being at home and being on a trip. The second image shows the hallway in between two stores. The third image is of toilet paper, which can represent a bathroom. A bathroom is a transitional space between private and public realms. It's a place where we prepare ourselves to enter or leave the outside world. The fourth image shows the sea in between being calm and being stormy. Liminal spaces can be both exciting and unsettling. They can be a place of new beginning or a place of endings. They can be a place of reflection or a place of action.

모델에게 이미지에 무엇이 있는지 명시적으로 참조하도록 요청해 볼 수도 있어요.

업데이트된 프롬프트 개선된 응답
이 이미지들의 공통점은 무엇인가? 응답에서 이미지에 있는 것을 참조해. All of the images are related to travel. The first image shows a person packing a suitcase, the second image shows an empty hallway in a shopping mall, the third image shows a stack of toilet paper, and the fourth image shows a dark and stormy sea. These images are all related to travel because they are all things that people need or use when they travel. The first image shows a person packing a suitcase, which is something that people do when they are going on a trip. The second image shows an empty hallway in a shopping mall, which is a place where people often go to buy things for their trips. The third image shows a stack of toilet paper, which is something that people often use when they are traveling. The fourth image shows a dark and stormy sea, which is something that people often encounter when they are traveling.

같은 팁이 이미지의 창의적 출력에도 적용돼요. 다음 토끼 예시에서 모델에게 이미지의 측면을 포함하도록 명시적으로 요청하면 출력을 개선할 수 있어요.

프롬프트 모델 응답
이 이미지에 대한 시를 써줄래? Little bunny, so soft and brown, Hopping through the field, up and down. Your ears so long, your tail so small, You're the cutest creature of them all. You nibble on the grass, so green and sweet, And hop away when you see me. But I'll always be your friend, Little bunny, until the very end.

업데이트된 프롬프트 / 개선된 응답

이 이미지에 대한 묘사적이고 극적인 시를 써주고 위치를 포함해.

Little bunny on the green,
          Ears so long, so keen.
          What do you see out there,
          In the distance, where you stare?

Is it the ocean blue,
          Sparkling in the sun's hue?
          Or the waves that crash and roar,
          A rhythm that you adore?

Little bunny, tell me true,
          What captures your attention so?
          Is it the salty breeze,
          Or the seagulls' cries that please?

Perhaps it's the vastness of it all,
          A world so big and small.
          A place where dreams can roam,
          And adventures can be sown.

Little bunny, I wonder what you dream,
          As you sit on the grass, so serene.
          Do you yearn to explore the deep,
          Or stay on land, where you can leap?

Whatever it may be, little bunny,
          Keep that spark of wonder burning brightly.
          For in your dreams and aspirations,
          Lies a world waiting for your creation.
프롬프트의 어떤 부분이 실패했는지 트러블슈팅하기

프롬프트가 실패한 이유가 모델이 이미지를 이해하지 못한 것인지, 아니면 이미지를 이해했지만 이후 올바른 추론 단계를 수행하지 못한 것인지 알기 어려울 수 있어요.

그 이유를 구분하려면 모델에게 이미지에 무엇이 있는지 설명하도록 요청하세요.

다음 예시에서 차와 함께 잘 어울리는 것처럼 보이지 않는 스낵(예: 팝콘)으로 모델이 응답한다면, 먼저 모델이 이미지에 차가 있다는 것을 올바르게 인식했는지 트러블슈팅할 수 있어요.

프롬프트 트러블슈팅용 프롬프트
이거랑 잘 어울리는 1분만에 만들 수 있는 스낵은 뭐야? 이 이미지에 무엇이 있는지 설명해.

또 다른 전략은 모델에게 추론을 설명하도록 요청하는 것이에요. 그렇게 하면 어떤 부분의 추론이 무너졌는지 좁힐 수 있어요.

프롬프트 트러블슈팅용 프롬프트
이거랑 잘 어울리는 1분만에 만들 수 있는 스낵은 뭐야? 이거랑 잘 어울리는 1분만에 만들 수 있는 스낵은 뭐야? 이유를 설명해줘.

다음 단계

  • Google AI Studio로 직접 멀티모달 프롬프트를 작성해 보세요.
  • 미디어 파일 업로드 및 프롬프트 포함에 대한 자세한 내용은 Vision, Audio, 문서 처리 가이드를 참조하세요.
  • 샘플링 매개변수 조정 같은 프롬프트 설계에 대한 더 많은 안내는 프롬프트 전략 페이지를 참조하세요.

더 알아보기 (Learn more)