Skip to main content

Minimal request

{
  "model": "veo-3.1-generate-preview",
  "prompt": "An 8-second Api.Go product demo animation"
}

cURL example

curl "https://generativelanguage.googleapis.com/v1beta/models/veo-3.1-generate-preview:predictLongRunning" \
  -H "x-goog-api-key: $GEMINI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "An 8-second Api.Go product demo animation"
  }'

Python example

import requests

create_response = requests.post(
    "https://generativelanguage.googleapis.com/v1beta/models/veo-3.1-generate-preview:predictLongRunning",
    headers={
        "x-goog-api-key": "<GEMINI_API_KEY>",
        "Content-Type": "application/json",
    },
    json={"prompt": "An 8-second Api.Go product demo animation"},
)

operation = create_response.json()
print(operation)

Node.js example

const createResponse = await fetch(
  "https://generativelanguage.googleapis.com/v1beta/models/veo-3.1-generate-preview:predictLongRunning",
  {
    method: "POST",
    headers: {
      "x-goog-api-key": process.env.GEMINI_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({
      prompt: "An 8-second Api.Go product demo animation"
    }),
  }
);

const operation = await createResponse.json();
console.log(operation);

Best practices

  • The initial request returns an operation handle, not the final video
  • Polling and state mapping should live on the server
  • Retrieve the final asset only after the operation is complete