KosmoKrator

ai

HeyGen Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the HeyGen KosmoKrator integration.

7 functions 6 read 1 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.heygen.*. Use lua_read_doc("integrations.heygen") inside KosmoKrator to discover the same reference at runtime.

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

HeyGen — Lua API Reference

list_videos

List generated videos with pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of videos to return (default: 10, max: 100)
offsetintegernoNumber of videos to skip for pagination (default: 0)

Examples

-- List recent videos
local result = app.integrations.heygen.list_videos({
  limit = 10,
  offset = 0
})

for _, video in ipairs(result.data.videos) do
  print(video.video_id .. ": " .. video.status)
end

get_video

Get the status and details of a specific video.

Parameters

NameTypeRequiredDescription
video_idstringyesThe unique identifier of the video

Example

local result = app.integrations.heygen.get_video({
  video_id = "abc123"
})

print("Status: " .. result.data.status)
if result.data.video_url then
  print("Download: " .. result.data.video_url)
end

create_video

Generate a new AI video with avatars and voices. Returns a video_id to track generation progress.

Parameters

NameTypeRequiredDescription
video_inputsarrayyesArray of video input objects defining scenes
dimensionobjectnoVideo dimensions, e.g. {width = 1920, height = 1080}
testbooleannoGenerate a test/preview video (default: false)

Video Input Structure

Each video input defines a scene:

{
  character = {
    avatar_id = "avatar-id-here",
    voice_id = "voice-id-here"
  },
  script = "Your script text here",
  voice_settings = {
    speed = 1.0,
    stability = 0.5
  }
}

Examples

-- Create a simple avatar video
local result = app.integrations.heygen.create_video({
  video_inputs = {
    {
      character = {
        avatar_id = "avatar-abc123",
        voice_id = "voice-xyz789"
      },
      script = "Welcome to our product demo!"
    }
  },
  test = true
})

print("Video ID: " .. result.data.video_id)
-- Create a video with custom dimensions
local result = app.integrations.heygen.create_video({
  video_inputs = {
    {
      character = {
        avatar_id = "avatar-abc123",
        voice_id = "voice-xyz789"
      },
      script = "This is a landscape video."
    }
  },
  dimension = { width = 1920, height = 1080 },
  test = false
})

list_avatars

List all available talking avatars.

Parameters

None.

Example

local result = app.integrations.heygen.list_avatars({})

for _, avatar in ipairs(result.data.avatars) do
  print(avatar.avatar_id .. ": " .. avatar.avatar_name)
end

list_voices

List all available voices for video generation.

Parameters

None.

Example

local result = app.integrations.heygen.list_voices({})

for _, voice in ipairs(result.data.voices) do
  print(voice.voice_id .. ": " .. voice.display_name .. " (" .. voice.language .. ")")
end

get_current_user

Get the authenticated user’s account information.

Parameters

None.

Example

local result = app.integrations.heygen.get_current_user({})

print("Plan: " .. result.data.plan)
print("Remaining credits: " .. result.data.remaining_quota)

list_templates

List available video templates with pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of templates to return (default: 10, max: 100)
offsetintegernoNumber of templates to skip for pagination (default: 0)

Example

local result = app.integrations.heygen.list_templates({
  limit = 20,
  offset = 0
})

for _, template in ipairs(result.data.templates) do
  print(template.template_id .. ": " .. template.name)
end

Multi-Account Usage

If you have multiple HeyGen accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.heygen.function_name({...})

-- Explicit default (portable across setups)
app.integrations.heygen.default.function_name({...})

-- Named accounts
app.integrations.heygen.work.function_name({...})
app.integrations.heygen.personal.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# HeyGen — Lua API Reference

## list_videos

List generated videos with pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of videos to return (default: 10, max: 100) |
| `offset` | integer | no | Number of videos to skip for pagination (default: 0) |

### Examples

```lua
-- List recent videos
local result = app.integrations.heygen.list_videos({
  limit = 10,
  offset = 0
})

for _, video in ipairs(result.data.videos) do
  print(video.video_id .. ": " .. video.status)
end
```

---

## get_video

Get the status and details of a specific video.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `video_id` | string | yes | The unique identifier of the video |

### Example

```lua
local result = app.integrations.heygen.get_video({
  video_id = "abc123"
})

print("Status: " .. result.data.status)
if result.data.video_url then
  print("Download: " .. result.data.video_url)
end
```

---

## create_video

Generate a new AI video with avatars and voices. Returns a `video_id` to track generation progress.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `video_inputs` | array | yes | Array of video input objects defining scenes |
| `dimension` | object | no | Video dimensions, e.g. `{width = 1920, height = 1080}` |
| `test` | boolean | no | Generate a test/preview video (default: false) |

### Video Input Structure

Each video input defines a scene:

```lua
{
  character = {
    avatar_id = "avatar-id-here",
    voice_id = "voice-id-here"
  },
  script = "Your script text here",
  voice_settings = {
    speed = 1.0,
    stability = 0.5
  }
}
```

### Examples

```lua
-- Create a simple avatar video
local result = app.integrations.heygen.create_video({
  video_inputs = {
    {
      character = {
        avatar_id = "avatar-abc123",
        voice_id = "voice-xyz789"
      },
      script = "Welcome to our product demo!"
    }
  },
  test = true
})

print("Video ID: " .. result.data.video_id)
```

```lua
-- Create a video with custom dimensions
local result = app.integrations.heygen.create_video({
  video_inputs = {
    {
      character = {
        avatar_id = "avatar-abc123",
        voice_id = "voice-xyz789"
      },
      script = "This is a landscape video."
    }
  },
  dimension = { width = 1920, height = 1080 },
  test = false
})
```

---

## list_avatars

List all available talking avatars.

### Parameters

None.

### Example

```lua
local result = app.integrations.heygen.list_avatars({})

for _, avatar in ipairs(result.data.avatars) do
  print(avatar.avatar_id .. ": " .. avatar.avatar_name)
end
```

---

## list_voices

List all available voices for video generation.

### Parameters

None.

### Example

```lua
local result = app.integrations.heygen.list_voices({})

for _, voice in ipairs(result.data.voices) do
  print(voice.voice_id .. ": " .. voice.display_name .. " (" .. voice.language .. ")")
end
```

---

## get_current_user

Get the authenticated user's account information.

### Parameters

None.

### Example

```lua
local result = app.integrations.heygen.get_current_user({})

print("Plan: " .. result.data.plan)
print("Remaining credits: " .. result.data.remaining_quota)
```

---

## list_templates

List available video templates with pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of templates to return (default: 10, max: 100) |
| `offset` | integer | no | Number of templates to skip for pagination (default: 0) |

### Example

```lua
local result = app.integrations.heygen.list_templates({
  limit = 20,
  offset = 0
})

for _, template in ipairs(result.data.templates) do
  print(template.template_id .. ": " .. template.name)
end
```

---

## Multi-Account Usage

If you have multiple HeyGen accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.heygen.function_name({...})

-- Explicit default (portable across setups)
app.integrations.heygen.default.function_name({...})

-- Named accounts
app.integrations.heygen.work.function_name({...})
app.integrations.heygen.personal.function_name({...})
```

All functions are identical across accounts — only the credentials differ.

Metadata-Derived Lua Example

local result = app.integrations.heygen.heygen_list_videos({
  limit = 1,
  offset = 1
})
print(result)

Functions

heygen_list_videos

List generated videos from HeyGen. Returns video IDs, statuses, and metadata. Use limit and offset for pagination.

Operation
Read read
Full name
heygen.heygen_list_videos
ParameterTypeRequiredDescription
limit integer no Maximum number of videos to return (default: 10, max: 100).
offset integer no Number of videos to skip for pagination (default: 0).

heygen_get_video

Get the status and details of a specific HeyGen video. Returns the video status (pending, processing, completed, failed), download URL when ready, and metadata.

Operation
Read read
Full name
heygen.heygen_get_video
ParameterTypeRequiredDescription
video_id string yes The unique identifier of the video to retrieve.

heygen_create_video

Generate a new AI video on HeyGen. Provide video_inputs defining scenes (avatar, voice, script), optional dimensions, and test mode. Returns a video_id to track generation progress.

Operation
Write write
Full name
heygen.heygen_create_video
ParameterTypeRequiredDescription
video_inputs array yes Array of video input objects. Each defines a scene with properties like character (avatar_id, voice_id), voice_settings, script, and background. Example: [{"character":{"avatar_id":"...","voice_id":"..."},"script":"Hello world"}]
dimension array no Video dimensions as an object with width and height. Example: {"width": 1920, "height": 1080}. Defaults to 1920x1080 if omitted.
test boolean no Set to true to generate a test (preview) video. Defaults to false.

heygen_list_avatars

List all available talking avatars from HeyGen. Returns avatar IDs, names, preview images, and supported styles. Use avatar IDs when creating videos.

Operation
Read read
Full name
heygen.heygen_list_avatars
ParameterTypeRequiredDescription
No parameters.

heygen_list_voices

List all available voices from HeyGen. Returns voice IDs, display names, supported languages, gender, and preview audio URLs. Use voice IDs when creating videos.

Operation
Read read
Full name
heygen.heygen_list_voices
ParameterTypeRequiredDescription
No parameters.

heygen_get_current_user

Get the current authenticated HeyGen user's account information, including plan details, remaining credits, and usage statistics.

Operation
Read read
Full name
heygen.heygen_get_current_user
ParameterTypeRequiredDescription
No parameters.

heygen_list_templates

List available video templates from HeyGen. Returns template IDs, names, thumbnails, and metadata. Use limit and offset for pagination.

Operation
Read read
Full name
heygen.heygen_list_templates
ParameterTypeRequiredDescription
limit integer no Maximum number of templates to return (default: 10, max: 100).
offset integer no Number of templates to skip for pagination (default: 0).