Create from a Custom Script
This snippet recreates the 📜 Create from a Custom Script recipe using PHP. Review the PHP guide for environment setup before running it.
<?php
$token = getenv('AUTOCONTENT_TOKEN') ?: 'YOUR_API_TOKEN';
$endpoint = 'https://api.autocontentapi.com/video/CreateShortsFromScript';
$payload = [
'script' => [
['avatarId' => 1, 'text' => 'Welcome back!'],
['avatarId' => 2, 'text' => 'Today we dig into productivity fundamentals.'],
],
'subtitles' => true,
];
$body = json_encode($payload);
if ($body === false) {
fwrite(STDERR, 'Failed to encode payload: ' . json_last_error_msg() . "\n");
exit(1);
}
$ch = curl_init($endpoint);
curl_setopt_array($ch, [
CURLOPT_HTTPHEADER => [
'Authorization: Bearer ' . $token,
'Content-Type: application/json',
'Accept: application/json',
],
CURLOPT_POST => true,
CURLOPT_POSTFIELDS => $body,
CURLOPT_RETURNTRANSFER => true,
]);
$response = curl_exec($ch);
if ($response === false) {
fwrite(STDERR, 'Request failed: ' . curl_error($ch) . "\n");
curl_close($ch);
exit(1);
}
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($status >= 400) {
fwrite(STDERR, "HTTP $status\n$response\n");
exit(1);
}
echo "Request accepted:\n" . $response . "\n";Replace YOUR_API_TOKEN (or set the AUTOCONTENT_TOKEN environment variable) before running the request.
This is the dedicated legacy Avatar/TTS flow. /content/Create video requests treat text as a NotebookLM instruction and do not preserve it as an exact narration script.
See also
Last updated