Generate text using AI
curl --request POST \
--url https://api.videodb.io/collection/{collection_id}/generate/text/ \
--header 'Content-Type: application/json' \
--header 'x-access-token: <api-key>' \
--data '
{
"prompt": "Summarize the content of this video",
"video_id": "m-12345",
"model_name": "gpt-4",
"max_tokens": 500,
"temperature": 0.7,
"callback_url": "https://webhook.example.com/callback"
}
'const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'Summarize the content of this video',
video_id: 'm-12345',
model_name: 'gpt-4',
max_tokens: 500,
temperature: 0.7,
callback_url: 'https://webhook.example.com/callback'
})
};
fetch('https://api.videodb.io/collection/{collection_id}/generate/text/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.videodb.io/collection/{collection_id}/generate/text/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Summarize the content of this video',
'video_id' => 'm-12345',
'model_name' => 'gpt-4',
'max_tokens' => 500,
'temperature' => 0.7,
'callback_url' => 'https://webhook.example.com/callback'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-access-token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.videodb.io/collection/{collection_id}/generate/text/"
payload := strings.NewReader("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-access-token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.videodb.io/collection/{collection_id}/generate/text/")
.header("x-access-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.videodb.io/collection/{collection_id}/generate/text/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-access-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}"
response = http.request(request)
puts response.read_body$headers=@{}
$headers.Add("x-access-token", "<api-key>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.videodb.io/collection/{collection_id}/generate/text/' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"prompt": "Summarize the content of this video",
"video_id": "m-12345",
"model_name": "gpt-4",
"max_tokens": 500,
"temperature": 0.7,
"callback_url": "https://webhook.example.com/callback"
}'import Foundation
let parameters = [
"prompt": "Summarize the content of this video",
"video_id": "m-12345",
"model_name": "gpt-4",
"max_tokens": 500,
"temperature": 0.7,
"callback_url": "https://webhook.example.com/callback"
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.videodb.io/collection/{collection_id}/generate/text/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"x-access-token": "<api-key>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))using RestSharp;
var options = new RestClientOptions("https://api.videodb.io/collection/{collection_id}/generate/text/");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("x-access-token", "<api-key>");
request.AddJsonBody("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
using RestSharp;
var options = new RestClientOptions("https://api.videodb.io/collection/{collection_id}/generate/text/");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("x-access-token", "<api-key>");
request.AddJsonBody("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'Summarize the content of this video',
video_id: 'm-12345',
model_name: 'gpt-4',
max_tokens: 500,
temperature: 0.7,
callback_url: 'https://webhook.example.com/callback'
})
};
fetch('https://api.videodb.io/collection/{collection_id}/generate/text/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.videodb.io/collection/{collection_id}/generate/text/");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "x-access-token: <api-key>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}");
CURLcode ret = curl_easy_perform(hnd);CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.videodb.io/collection/{collection_id}/generate/text/");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "x-access-token: <api-key>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}");
CURLcode ret = curl_easy_perform(hnd);val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}")
val request = Request.Builder()
.url("https://api.videodb.io/collection/{collection_id}/generate/text/")
.post(body)
.addHeader("x-access-token", "<api-key>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute(){
"success": true,
"status": "processing",
"data": {
"id": "job-123",
"output_url": "https://api.videodb.io/async-response/job-123"
}
}Generate Text with AI
Generate text content using AI language models for captions, scripts, and summaries
POST
/
collection
/
{collection_id}
/
generate
/
text
/
Generate text using AI
curl --request POST \
--url https://api.videodb.io/collection/{collection_id}/generate/text/ \
--header 'Content-Type: application/json' \
--header 'x-access-token: <api-key>' \
--data '
{
"prompt": "Summarize the content of this video",
"video_id": "m-12345",
"model_name": "gpt-4",
"max_tokens": 500,
"temperature": 0.7,
"callback_url": "https://webhook.example.com/callback"
}
'const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'Summarize the content of this video',
video_id: 'm-12345',
model_name: 'gpt-4',
max_tokens: 500,
temperature: 0.7,
callback_url: 'https://webhook.example.com/callback'
})
};
fetch('https://api.videodb.io/collection/{collection_id}/generate/text/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.videodb.io/collection/{collection_id}/generate/text/",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'prompt' => 'Summarize the content of this video',
'video_id' => 'm-12345',
'model_name' => 'gpt-4',
'max_tokens' => 500,
'temperature' => 0.7,
'callback_url' => 'https://webhook.example.com/callback'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json",
"x-access-token: <api-key>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.videodb.io/collection/{collection_id}/generate/text/"
payload := strings.NewReader("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("x-access-token", "<api-key>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.videodb.io/collection/{collection_id}/generate/text/")
.header("x-access-token", "<api-key>")
.header("Content-Type", "application/json")
.body("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.videodb.io/collection/{collection_id}/generate/text/")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["x-access-token"] = '<api-key>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}"
response = http.request(request)
puts response.read_body$headers=@{}
$headers.Add("x-access-token", "<api-key>")
$headers.Add("Content-Type", "application/json")
$response = Invoke-WebRequest -Uri 'https://api.videodb.io/collection/{collection_id}/generate/text/' -Method POST -Headers $headers -ContentType 'application/json' -Body '{
"prompt": "Summarize the content of this video",
"video_id": "m-12345",
"model_name": "gpt-4",
"max_tokens": 500,
"temperature": 0.7,
"callback_url": "https://webhook.example.com/callback"
}'import Foundation
let parameters = [
"prompt": "Summarize the content of this video",
"video_id": "m-12345",
"model_name": "gpt-4",
"max_tokens": 500,
"temperature": 0.7,
"callback_url": "https://webhook.example.com/callback"
] as [String : Any?]
let postData = try JSONSerialization.data(withJSONObject: parameters, options: [])
let url = URL(string: "https://api.videodb.io/collection/{collection_id}/generate/text/")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.timeoutInterval = 10
request.allHTTPHeaderFields = [
"x-access-token": "<api-key>",
"Content-Type": "application/json"
]
request.httpBody = postData
let (data, _) = try await URLSession.shared.data(for: request)
print(String(decoding: data, as: UTF8.self))using RestSharp;
var options = new RestClientOptions("https://api.videodb.io/collection/{collection_id}/generate/text/");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("x-access-token", "<api-key>");
request.AddJsonBody("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
using RestSharp;
var options = new RestClientOptions("https://api.videodb.io/collection/{collection_id}/generate/text/");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddHeader("x-access-token", "<api-key>");
request.AddJsonBody("{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
const options = {
method: 'POST',
headers: {'x-access-token': '<api-key>', 'Content-Type': 'application/json'},
body: JSON.stringify({
prompt: 'Summarize the content of this video',
video_id: 'm-12345',
model_name: 'gpt-4',
max_tokens: 500,
temperature: 0.7,
callback_url: 'https://webhook.example.com/callback'
})
};
fetch('https://api.videodb.io/collection/{collection_id}/generate/text/', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.videodb.io/collection/{collection_id}/generate/text/");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "x-access-token: <api-key>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}");
CURLcode ret = curl_easy_perform(hnd);CURL *hnd = curl_easy_init();
curl_easy_setopt(hnd, CURLOPT_CUSTOMREQUEST, "POST");
curl_easy_setopt(hnd, CURLOPT_WRITEDATA, stdout);
curl_easy_setopt(hnd, CURLOPT_URL, "https://api.videodb.io/collection/{collection_id}/generate/text/");
struct curl_slist *headers = NULL;
headers = curl_slist_append(headers, "x-access-token: <api-key>");
headers = curl_slist_append(headers, "Content-Type: application/json");
curl_easy_setopt(hnd, CURLOPT_HTTPHEADER, headers);
curl_easy_setopt(hnd, CURLOPT_POSTFIELDS, "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}");
CURLcode ret = curl_easy_perform(hnd);val client = OkHttpClient()
val mediaType = MediaType.parse("application/json")
val body = RequestBody.create(mediaType, "{\n \"prompt\": \"Summarize the content of this video\",\n \"video_id\": \"m-12345\",\n \"model_name\": \"gpt-4\",\n \"max_tokens\": 500,\n \"temperature\": 0.7,\n \"callback_url\": \"https://webhook.example.com/callback\"\n}")
val request = Request.Builder()
.url("https://api.videodb.io/collection/{collection_id}/generate/text/")
.post(body)
.addHeader("x-access-token", "<api-key>")
.addHeader("Content-Type", "application/json")
.build()
val response = client.newCall(request).execute(){
"success": true,
"status": "processing",
"data": {
"id": "job-123",
"output_url": "https://api.videodb.io/async-response/job-123"
}
}Generate text content using AI language models. Use the basic default, a mini, pro, or ultra built-in, or a self-hosted model name, and get results as plain text or JSON.
import json
import videodb
conn = videodb.connect(api_key="your_api_key")
coll = conn.get_collection()
# Generate plain text
script_response = coll.generate_text(
prompt="Write a 30-second commercial script for a coffee brand",
model_name="pro",
response_type="text"
)
script = (
script_response
if isinstance(script_response, str)
else script_response.get("output", script_response)
)
print(script)
# Generate JSON response
data_response = coll.generate_text(
prompt="Extract key points from a video summary",
model_name="pro",
response_type="json"
)
json_output = (
data_response
if isinstance(data_response, str)
else data_response.get("output", data_response)
)
data = json.loads(json_output) if isinstance(json_output, str) else json_output
print(data)
import { connect } from 'videodb';
const conn = connect({ apiKey: 'your_api_key' });
const coll = await conn.getCollection();
// Generate plain text
const scriptResult = await coll.generateText(
"Write a 30-second commercial script for a coffee brand",
"pro",
"text"
);
const script = typeof scriptResult === "string"
? scriptResult
: scriptResult.output;
if (typeof script !== "string") {
throw new Error("Expected a text response.");
}
console.log(script);
// Generate JSON response
const jsonResult = await coll.generateText(
"Extract key points from a video summary",
"pro",
"json"
);
const jsonOutput = typeof jsonResult === "string"
? jsonResult
: jsonResult.output;
const data = typeof jsonOutput === "string"
? JSON.parse(jsonOutput)
: jsonOutput;
console.log(data);
- Model options:
basic(default),mini,pro, andultrabuilt-ins, or a self-hosted model name - Response types:
textfor plain text orjsonfor JSON-formatted output generate_text()returns a string or object; some responses wrap the generated value inoutput. Parse JSON text when structured data is needed- Text generation supports
waitand callback options - Useful for generating captions, scripts, summaries, and extracted data
Generative Media Guide
Learn about all AI generation capabilities
Text Prompts Tutorial
Master text prompting strategies for generation
Authorizations
API key for authentication (sk-xxx format)
Path Parameters
Example:
"default"
Body
application/json