Vertex AI의 프롬프트 재작성 도구에서 Veo 사용 중지

Veo는 프롬프트 수정 도구라고도 하는 LLM 기반 프롬프트 개선 도구를 제공합니다. 프롬프트 재작성 도구는 프롬프트를 재작성하여 동영상 설명, 카메라 모션, 스크립트, 음향 효과를 프롬프트에 추가하는 옵션을 제공합니다. 프롬프트가 더 구체적일수록 동영상 품질이 높아집니다.

프롬프트 개선을 사용 중지하면 동영상 품질과 출력이 제공된 프롬프트와 얼마나 유사한지에 영향을 줄 수 있습니다. 이 기능은 veo-2.0-generate-001에서 기본적으로 사용 설정되어 있습니다.

수정된 프롬프트는 원래 프롬프트의 길이가 30단어 미만인 경우에만 API 응답을 통해 제공됩니다.

동영상 생성에 효과적인 텍스트 프롬프트 작성에 대한 자세한 내용은 Veo 프롬프트 가이드를 참조하세요.

시작하기 전에

  1. Sign in to your Google Cloud account. If you're new to Google Cloud, create an account to evaluate how our products perform in real-world scenarios. New customers also get $300 in free credits to run, test, and deploy workloads.
  2. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  3. Enable the Vertex AI API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  4. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

    Roles required to select or create a project

    • Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
    • Create a project: To create a project, you need the Project Creator (roles/resourcemanager.projectCreator), which contains the resourcemanager.projects.create permission. Learn how to grant roles.

    Go to project selector

  5. Enable the Vertex AI API.

    Roles required to enable APIs

    To enable APIs, you need the Service Usage Admin IAM role (roles/serviceusage.serviceUsageAdmin), which contains the serviceusage.services.enable permission. Learn how to grant roles.

    Enable the API

  6. 환경에 대한 인증을 설정하세요.

    Select the tab for how you plan to use the samples on this page:

    Console

    When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.

    REST

    로컬 개발 환경에서 이 페이지의 REST API 샘플을 사용하려면 gcloud CLI에 제공한 사용자 인증 정보를 사용합니다.

      Google Cloud CLI를 설치합니다. 설치 후 다음 명령어를 실행하여 Google Cloud CLI를 초기화합니다.

      gcloud init

      외부 ID 공급업체(IdP)를 사용하는 경우 먼저 제휴 ID로 gcloud CLI에 로그인해야 합니다.

    자세한 내용은 Google Cloud 인증 문서의 REST 사용을 위한 인증을 참조하세요.

    프롬프트 수정 도구 사용 중지

    프롬프트 개선 기능을 사용 중지하려면 다음 단계를 따르세요.

    콘솔

    1. Google Cloud 콘솔에서 Vertex AI Studio > Media Studio 페이지로 이동합니다.

      Media Studio로 이동

    2. Veo를 클릭합니다.

    3. 설정에서 프롬프트 개선 사용 설정 전환 버튼을 클릭합니다.

    4. 프롬프트 작성 상자에 프롬프트를 입력한 다음 생성을 클릭합니다.

    Python

    설치

    pip install --upgrade google-genai

    자세한 내용은 SDK 참고 문서를 참조하세요.

    Vertex AI에서 Gen AI SDK를 사용하도록 환경 변수를 설정합니다.

    # Replace the `GOOGLE_CLOUD_PROJECT` and `GOOGLE_CLOUD_LOCATION` values
    # with appropriate values for your project.
    export GOOGLE_CLOUD_PROJECT=GOOGLE_CLOUD_PROJECT
    export GOOGLE_CLOUD_LOCATION=global
    export GOOGLE_GENAI_USE_VERTEXAI=True

    import time
    from google import genai
    from google.genai.types import GenerateVideosConfig
    
    client = genai.Client()
    
    # TODO(developer): Update and un-comment below line
    # output_gcs_uri = "gs://your-bucket/your-prefix"
    
    operation = client.models.generate_videos(
        model="veo-2.0-generate-001",
        prompt="a cat reading a book",
        config=GenerateVideosConfig(
            aspect_ratio="16:9",
            output_gcs_uri=output_gcs_uri,
            number_of_videos=1,
            duration_seconds=5,
            person_generation="dont_allow",
            enhance_prompt=False,
        ),
    )
    
    while not operation.done:
        time.sleep(15)
        operation = client.operations.get(operation)
        print(operation)
    
    if operation.response:
        print(operation.result.generated_videos[0].video.uri)
    
    # Example response:
    # gs://your-bucket/your-prefix

    REST

    환경을 설정하면 REST를 사용하여 텍스트 프롬프트를 테스트할 수 있습니다. 다음 샘플은 요청을 게시자 모델 엔드포인트에 전송합니다.

    Veo API에 대한 자세한 내용은 Vertex AI 기반 Veo API를 참조하세요.

    1. 다음 명령어를 사용하여 동영상 생성 요청을 전송합니다. 이 요청은 장기 실행 작업을 시작하고 지정한 Cloud Storage 버킷에 출력을 저장합니다.

    요청 데이터를 사용하기 전에 다음을 바꿉니다.

    • PROJECT_ID: Google Cloud 프로젝트 ID
    • MODEL_ID: 사용할 모델 ID. 사용 가능한 값은 다음과 같습니다.
      • veo-2.0-generate-001
    • TEXT_PROMPT: 동영상 생성을 안내하는 데 사용되는 텍스트 프롬프트
    • OUTPUT_STORAGE_URI: (선택사항) 출력 동영상을 저장할 Cloud Storage 버킷입니다. 제공하지 않으면 응답으로 동영상 바이트가 반환됩니다. 예를 들면 gs://video-bucket/output/입니다.
    • RESPONSE_COUNT: 생성할 동영상 파일의 수. 허용되는 정수 값: 1~4.
    • DURATION: 생성할 동영상 파일의 길이. 허용되는 정수 값은 5~8입니다.
    • ENHANCED_PROMPT: 향상된 프롬프트를 사용할지 여부입니다. 다음 중 하나를 사용할 수 있습니다.
      • True: (기본값) Gemini를 사용하여 프롬프트를 개선합니다.
      • False: Gemini를 사용하여 프롬프트를 개선하지 마세요.
    • 추가 선택적 파라미터

      사용 사례에 따라 다음 선택적 변수를 사용하세요. "parameters": {} 객체에 다음 파라미터 중 일부 또는 전부를 추가합니다.

      "parameters": {
        "aspectRatio": "ASPECT_RATIO",
        "negativePrompt": "NEGATIVE_PROMPT",
        "personGeneration": "PERSON_SAFETY_SETTING",
        // "resolution": RESOLUTION, // Veo 3 models only
        "sampleCount": RESPONSE_COUNT,
        "seed": SEED_NUMBER
      }
      • ASPECT_RATIO: 선택사항: 생성된 동영상의 가로세로 비율을 설명하는 문자열 값입니다. 다음 값을 사용할 수 있습니다.
        • 가로 모드용 "16:9"
        • 세로 모드용 "9:16"

        기본값은 "16:9"입니다.

      • NEGATIVE_PROMPT: 선택사항: 모델이 생성하지 않도록 하려는 콘텐츠를 설명하는 문자열 값입니다.
      • PERSON_SAFETY_SETTING: 선택사항: 사람 또는 얼굴 생성의 안전 설정을 제어하는 문자열 값입니다. 다음 값을 사용할 수 있습니다.
        • "allow_adult": 성인 인물 및 얼굴만 생성합니다.
        • "disallow": 사람이나 얼굴을 생성하지 않습니다.

        기본값은 "allow_adult"입니다.

      • RESOLUTION: 선택사항: 생성된 동영상의 해상도를 제어하는 문자열 값입니다. Veo 3 모델에서만 지원됩니다. 다음 값을 사용할 수 있습니다.
        • "720p"
        • "1080p"

        기본값은 "720p"입니다.

      • RESPONSE_COUNT: 선택사항입니다. 생성할 동영상 수를 설명하는 정수 값입니다. 허용되는 값의 범위는 1~4입니다.
      • SEED_NUMBER: 선택사항입니다. 모델이 확정적 동영상을 생성하는 데 사용하는 uint32 값입니다. 다른 파라미터를 변경하지 않고 요청에 시드 수를 지정하면 모델에서 동일한 동영상을 생성합니다. 허용되는 값의 범위는 0~4294967295입니다.

    HTTP 메서드 및 URL:

    POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:predictLongRunning

    JSON 요청 본문:

    {
      "instances": [
        {
          "prompt": "TEXT_PROMPT"
        }
      ],
      "parameters": {
        "storageUri": "OUTPUT_STORAGE_URI",
        "sampleCount": "RESPONSE_COUNT",
        "durationSeconds": "DURATION",
        "enhancePrompt": ENHANCED_PROMPT
      }
    }
    

    요청을 보내려면 다음 옵션 중 하나를 선택합니다.

    curl

    요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

    curl -X POST \
    -H "Authorization: Bearer $(gcloud auth print-access-token)" \
    -H "Content-Type: application/json; charset=utf-8" \
    -d @request.json \
    "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:predictLongRunning"

    PowerShell

    요청 본문을 request.json 파일에 저장하고 다음 명령어를 실행합니다.

    $cred = gcloud auth print-access-token
    $headers = @{ "Authorization" = "Bearer $cred" }

    Invoke-WebRequest `
    -Method POST `
    -Headers $headers `
    -ContentType: "application/json; charset=utf-8" `
    -InFile request.json `
    -Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID:predictLongRunning" | Select-Object -Expand Content
    이 요청은 고유한 작업 ID가 포함된 전체 작업 이름을 반환합니다. 이 전체 작업 이름을 사용하여 동영상 생성 요청 상태를 폴링합니다.
    {
      "name": "projects/PROJECT_ID/locations/us-central1/publishers/google/models/MODEL_ID/operations/a1b07c8e-7b5a-4aba-bb34-3e1ccb8afcc8"
    }
    

    다음 단계