Skip to main content
Version: Latest

Topic to Video

Describe the process of creating video content by conveying the topic.


1. Make a request

Please request project creation by delivering the topic and options.

1-1. API endpoint

https://app.aistudios.com/api/odin/v3/automation/topic_to_video

1-2. Request parameter

keydesctyperequireddefault
topicTopic for creating videosStringtrue-
optionsConfiguration for video generationJsonfalse
options.languageThe language used in the video
The language code follows the ISO 639-1 standard.
Stringfalse-
options.durationVideo Time
(30 | 60 | 90 | 120 | 150 | 180)
Numberfalse-
options.objectiveObjectives of video footage (e.g. publicity, education, explanation)Stringfalse-
options.audienceTarget audience for video footage (e.g. marketers, students)Stringfalse-
options.toneThe tone of a video video (e.g. clearly, formally)Stringfalse-
options.speedVideo playback speed relative to original speed
(0.5 ~ 1.5)
Numberfalse1
options.mediaImage information used to create video
(search | free | premium | generative)
Stringfalse-
options.useGenerativeHighQualityEnabling High-Definition AI Media
(valid only for options.media='generative')
(true | false)
Booleanfalsefalse
options.styleStyle information
(valid only for options.media='generative')
(realistic | digitalPainting | sketch | oilPainting | pixelArt | watercolor | lowPoly | cyberpunk | fantasy | anime)
Stringfalserealistic
options.templateIdtemplate id to use for video creationStringfalse-
options.modelmodel id to use for video generationStringfalse-
options.voiceOnlyOnly the voice of the model used to create the video
(true | false)
Booleanfalsefalse

1-3. Response Parameters

keydesctype
projectIdID of the video project createdString
automationJobIdJob ID requested to create a videoString

1-4. Sample Request

curl https://app.aistudios.com/api/odin/v3/automation/topic_to_video  \
-H "Authorization: ${API KEY}" \
-H "Content-Type: application/json" \
-X POST \
-d '{
"topic" : "What is K-culture?",
"options" : {
"language": "en",
"speed": 1,
"media": "generative",
"useGenerativeHighQuality": true,
"style": "digitalPainting",
"templateId": "## template id ##",
"model": "## model id ##",
"voiceOnly": false
}
}'


2. Check the progress of project creation

Create a video after request Check your current progress.

2-1. Api endpoint

GET https://app.aistudios.com/api/odin/v3/automation/progress?projectId=${projectId}

2-2. Response Parameters

KeyDescriptionType
stateCurrent state of the automation processString
progressVideo Generation Completion RateNumber

2-3. Sample request

import axios from "axios";

const projectId = "your_project_id";
const token = "your_api_key";

axios.get(`https://app.aistudios.com/api/odin/v3/automation/progress/${projectId}`, {}, {
headers: {
"Authorization": token,
"Content-Type": "application/json"
}
})
.then((res) => {
console.log(res.data)
})
.catch((error) => {
console.error(error)
});


3. Export

Use Project Export to Project a video of a created project.



4. Full Code

const API_HOST = 'https://app.aistudios.com'

const GET_TOKEN_API_PATH = '/api/odin/v3/auth/token'
const CREATE_API_PATH = '/api/odin/v3/automation/topic_to_video'
const CREATE_PROGRESS_API_PATH = '/api/odin/v3/automation/progress'
const EXPORT_API_PATH = '/api/odin/v3/editor/project/export'
const EXPORT_PROGRESS_API_PATH = '/api/odin/v3/editor/progress'

const appId = '## your appId ##'
const userKey = '## your userKey ##'

const topic = "What is K-culture?";
const options = {
"language": "en",
// "duration": 60,
// "objective": "education",
// "audience": "students",
// "tone": "clearly",
"speed": 1,
// "media": "generative",
// "useGenerativeHighQuality": true,
// "style": "digitalPainting",
"templateId": "## template id ##",
"model": "## model id ##", // Michael
"voiceOnly": false,
};

const delay = async (ms = 1000 * 60) => {
await new Promise(r => setTimeout(r, ms))
}

const main = async () => {
try {
/**
* get api token
*/
const token = await fetch(
`${API_HOST}${GET_TOKEN_API_PATH}`,
{
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
appId,
userKey
})
}
)
.then((response) => response.json())
.then((response) => {
if (response.success == true) {
return response.data.token
} else {
console.error(`import authentication token error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
});

console.log('token : ', token);

/**
* create project
*/
const projectId = await fetch(
`${API_HOST}${CREATE_API_PATH}`,
{
method: 'POST',
headers: {
Authorization: token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"topic": topic,
"options": options
})
}
)
.then((response) => response.json())
.then((response) => {
if (response.success == true) {
return response.data.projectId
} else {
console.error(`create project error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
});

console.log('request create project, projectId : ', projectId);

/**
* project progress
*/
let isCreateProjectFinish = false

while (!isCreateProjectFinish) {
const progressData = await fetch(
`${API_HOST}${CREATE_PROGRESS_API_PATH}/?projectId=${projectId}`,
{
method: 'GET',
headers: {
Authorization: token,
},
},
)
.then((response) => response.json())
.then((response) => {
if (response.success === true) {
return response.data
} else {
console.error(`project progress error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
})

console.log('project creation progress, state: ', progressData.state, ', progress : ', progressData.progress);

if (progressData.state === "finish" && progressData.progress === 100) {
isCreateProjectFinish = true
} else {
await delay()
}
}

/**
* export project
*/
await fetch(
`${API_HOST}${EXPORT_API_PATH}`,
{
method: 'POST',
headers: {
Authorization: token,
'Content-Type': 'application/json',
},
body: JSON.stringify({
"projectId": projectId
})
}
)
.then((response) => response.json())
.then((response) => {
if (response.success == true) {
return response.data.projectId
} else {
console.error(`export project error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
});

console.log('request export project');


/**
* export progress
*/
let isExportFinish = false
let videoUrl = ''

while (!isExportFinish) {
const progressData = await fetch(
`${API_HOST}${EXPORT_PROGRESS_API_PATH}/${projectId}`,
{
method: 'GET',
headers: {
Authorization: token,
}
},
)
.then((response) => response.json())
.then((response) => {
if (response.success === true) {
return response.data
} else {
console.error(`export progress error, code:`, response.error.code, `, msg:`, response.error.msg);
throw Error(response);
}
})

console.log(`export `, progressData.state, `, progress : `, progressData.progress)

if (progressData.progress < 100) {
await delay()
} else {
videoUrl = progressData.downloadUrl
isExportFinish = true
}
}

console.log('videoUrl :', videoUrl);
} catch (error) {
// ...
}

console.log('finish');
}

main()