KosmoKrator

media

Mux Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write Bearer token auth

Lua Namespace

Agents call this integration through app.integrations.mux.*. Use lua_read_doc("integrations.mux") 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.

Mux — Lua API Reference

list_assets

List video assets stored in Mux.

Parameters

NameTypeRequiredDescription
limitintegernoMax assets to return (1–100, default: 25)
pageintegernoPage offset, 0-indexed (default: 0)

Example

local result = app.integrations.mux.list_assets({
  limit = 10,
  page = 0
})

for _, asset in ipairs(result.data) do
  print(asset.id .. " — " .. (asset.status or "unknown"))
end

get_asset

Retrieve details of a specific video asset.

Parameters

NameTypeRequiredDescription
asset_idstringyesThe ID of the asset to retrieve

Example

local result = app.integrations.mux.get_asset({
  asset_id = "abc123xyz"
})

print("Status: " .. result.data.status)
print("Duration: " .. (result.data.duration or 0) .. " seconds")

create_asset

Create a new video asset from an input URL.

Parameters

NameTypeRequiredDescription
inputstringyesURL of the video file to ingest
playback_policyarraynoPlayback policy: ["public"] or ["signed"]

Example

local result = app.integrations.mux.create_asset({
  input = "https://storage.example.com/video.mp4",
  playback_policy = { "public" }
})

print("Created asset: " .. result.data.id)

list_live_streams

List live streams in Mux.

Parameters

NameTypeRequiredDescription
limitintegernoMax live streams to return (1–100, default: 25)
pageintegernoPage offset, 0-indexed (default: 0)

Example

local result = app.integrations.mux.list_live_streams({
  limit = 10
})

for _, stream in ipairs(result.data) do
  print(stream.id .. " — " .. (stream.status or "unknown"))
end

get_live_stream

Retrieve details of a specific live stream.

Parameters

NameTypeRequiredDescription
live_stream_idstringyesThe ID of the live stream to retrieve

Example

local result = app.integrations.mux.get_live_stream({
  live_stream_id = "abc123xyz"
})

print("Status: " .. result.data.status)
print("Stream key: " .. (result.data.stream_key or "n/a"))

create_live_stream

Create a new live stream.

Parameters

NameTypeRequiredDescription
playback_policyarraynoPlayback policy: ["public"] or ["signed"]
new_asset_settingsobjectnoSettings for assets created from this stream

Example

local result = app.integrations.mux.create_live_stream({
  playback_policy = { "public" },
  new_asset_settings = {
    playback_policy = { "public" },
    mp4_support = "standard"
  }
})

print("Stream key: " .. result.data.stream_key)
print("Stream ID: " .. result.data.id)

get_current_user

Get realtime viewer data from Mux Data.

Parameters

None.

Example

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

for _, row in ipairs(result.data or {}) do
  print(row.view_id .. ": " .. row.viewer_count .. " viewers")
end

Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.mux.production.function_name({...})
app.integrations.mux.staging.function_name({...})

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

Raw agent markdown
# Mux — Lua API Reference

## list_assets

List video assets stored in Mux.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max assets to return (1–100, default: 25) |
| `page` | integer | no | Page offset, 0-indexed (default: 0) |

### Example

```lua
local result = app.integrations.mux.list_assets({
  limit = 10,
  page = 0
})

for _, asset in ipairs(result.data) do
  print(asset.id .. " — " .. (asset.status or "unknown"))
end
```

---

## get_asset

Retrieve details of a specific video asset.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `asset_id` | string | yes | The ID of the asset to retrieve |

### Example

```lua
local result = app.integrations.mux.get_asset({
  asset_id = "abc123xyz"
})

print("Status: " .. result.data.status)
print("Duration: " .. (result.data.duration or 0) .. " seconds")
```

---

## create_asset

Create a new video asset from an input URL.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `input` | string | yes | URL of the video file to ingest |
| `playback_policy` | array | no | Playback policy: `["public"]` or `["signed"]` |

### Example

```lua
local result = app.integrations.mux.create_asset({
  input = "https://storage.example.com/video.mp4",
  playback_policy = { "public" }
})

print("Created asset: " .. result.data.id)
```

---

## list_live_streams

List live streams in Mux.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max live streams to return (1–100, default: 25) |
| `page` | integer | no | Page offset, 0-indexed (default: 0) |

### Example

```lua
local result = app.integrations.mux.list_live_streams({
  limit = 10
})

for _, stream in ipairs(result.data) do
  print(stream.id .. " — " .. (stream.status or "unknown"))
end
```

---

## get_live_stream

Retrieve details of a specific live stream.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `live_stream_id` | string | yes | The ID of the live stream to retrieve |

### Example

```lua
local result = app.integrations.mux.get_live_stream({
  live_stream_id = "abc123xyz"
})

print("Status: " .. result.data.status)
print("Stream key: " .. (result.data.stream_key or "n/a"))
```

---

## create_live_stream

Create a new live stream.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `playback_policy` | array | no | Playback policy: `["public"]` or `["signed"]` |
| `new_asset_settings` | object | no | Settings for assets created from this stream |

### Example

```lua
local result = app.integrations.mux.create_live_stream({
  playback_policy = { "public" },
  new_asset_settings = {
    playback_policy = { "public" },
    mp4_support = "standard"
  }
})

print("Stream key: " .. result.data.stream_key)
print("Stream ID: " .. result.data.id)
```

---

## get_current_user

Get realtime viewer data from Mux Data.

### Parameters

None.

### Example

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

for _, row in ipairs(result.data or {}) do
  print(row.view_id .. ": " .. row.viewer_count .. " viewers")
end
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations.mux.production.function_name({...})
app.integrations.mux.staging.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.mux.mux_list_assets({
  limit = 1,
  page = 1
})
print(result)

Functions

mux_list_assets

List video assets stored in Mux. Returns a paginated list of assets with their IDs, status, duration, and playback information.

Operation
Read read
Full name
mux.mux_list_assets
ParameterTypeRequiredDescription
limit integer no Maximum number of assets to return (1–100, default: 25).
page integer no Page offset for pagination (0-indexed, default: 0).

mux_get_asset

Retrieve details of a specific video asset by its ID, including status, playback IDs, duration, and tracks.

Operation
Read read
Full name
mux.mux_get_asset
ParameterTypeRequiredDescription
asset_id string yes The ID of the asset to retrieve.

mux_create_asset

Create a new video asset in Mux from an input URL. The asset is ingested and encoded asynchronously. Optionally set a playback policy (public or signed).

Operation
Write write
Full name
mux.mux_create_asset
ParameterTypeRequiredDescription
input string yes The URL of the video file to ingest (e.g., "https://storage.example.com/video.mp4").
playback_policy array no Playback policy for the asset. Use ["public"] for unrestricted access or ["signed"] for signed URLs. Defaults to the workspace default.

mux_list_live_streams

List live streams in Mux. Returns a paginated list of live streams with their IDs, status, stream key, and playback information.

Operation
Read read
Full name
mux.mux_list_live_streams
ParameterTypeRequiredDescription
limit integer no Maximum number of live streams to return (1–100, default: 25).
page integer no Page offset for pagination (0-indexed, default: 0).

mux_get_live_stream

Retrieve details of a specific live stream by its ID, including status, stream key, playback IDs, and reconnect window.

Operation
Read read
Full name
mux.mux_get_live_stream
ParameterTypeRequiredDescription
live_stream_id string yes The ID of the live stream to retrieve.

mux_create_live_stream

Create a new live stream in Mux. Returns the stream key and playback information. Optionally set playback policy and asset creation settings.

Operation
Write write
Full name
mux.mux_create_live_stream
ParameterTypeRequiredDescription
playback_policy array no Playback policy for the live stream. Use ["public"] for unrestricted access or ["signed"] for signed URLs. Defaults to the workspace default.
new_asset_settings object no Settings applied to assets created from this live stream. Supports any Mux asset creation parameters (e.g., {"playback_policy": ["public"], "mp4_support": "standard"}).

mux_get_current_user

Get realtime viewer data from Mux Data, including current viewer counts across all properties and views.

Operation
Read read
Full name
mux.mux_get_current_user
ParameterTypeRequiredDescription
No parameters.