data
Mux Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Mux KosmoKrator integration.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.
Call Lua from the Headless CLI
Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic
Mux workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.mux.list_assets({limit = 1, page = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("mux"))' --json
kosmo integrations:lua --eval 'print(docs.read("mux.list_assets"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local mux = app.integrations.mux
local result = mux.list_assets({limit = 1, page = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.mux, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.mux.default.* or app.integrations.mux.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Mux, use the narrower mcp:lua command.
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json 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
| 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
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
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
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
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
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
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. local result = app.integrations.mux.list_assets({limit = 1, page = 1})
print(result) Functions
list_assets Read
List video assets stored in Mux. Returns a paginated list of assets with their IDs, status, duration, and playback information.
- Lua path
app.integrations.mux.list_assets- Full name
mux.mux_list_assets
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of assets to return (1–100, default: 25). |
page | integer | no | Page offset for pagination (0-indexed, default: 0). |
get_asset Read
Retrieve details of a specific video asset by its ID, including status, playback IDs, duration, and tracks.
- Lua path
app.integrations.mux.get_asset- Full name
mux.mux_get_asset
| Parameter | Type | Required | Description |
|---|---|---|---|
asset_id | string | yes | The ID of the asset to retrieve. |
create_asset Write
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).
- Lua path
app.integrations.mux.create_asset- Full name
mux.mux_create_asset
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
list_live_streams Read
List live streams in Mux. Returns a paginated list of live streams with their IDs, status, stream key, and playback information.
- Lua path
app.integrations.mux.list_live_streams- Full name
mux.mux_list_live_streams
| Parameter | Type | Required | Description |
|---|---|---|---|
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). |
get_live_stream Read
Retrieve details of a specific live stream by its ID, including status, stream key, playback IDs, and reconnect window.
- Lua path
app.integrations.mux.get_live_stream- Full name
mux.mux_get_live_stream
| Parameter | Type | Required | Description |
|---|---|---|---|
live_stream_id | string | yes | The ID of the live stream to retrieve. |
create_live_stream Write
Create a new live stream in Mux. Returns the stream key and playback information. Optionally set playback policy and asset creation settings.
- Lua path
app.integrations.mux.create_live_stream- Full name
mux.mux_create_live_stream
| Parameter | Type | Required | Description |
|---|---|---|---|
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"}). |
get_realtime_data Read
Get realtime viewer data from Mux Data, including current viewer counts across all properties and views.
- Lua path
app.integrations.mux.get_realtime_data- Full name
mux.mux_get_current_user
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||