KosmoKrator

rendering

Vega-Lite Lua API for KosmoKrator Agents

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

1 functions 0 read 1 write No credentials auth

Lua Namespace

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

Vega-Lite — Lua API Reference

render_vegalite

Render a Vega-Lite visualization to a PNG image. Pass a complete Vega-Lite JSON specification and get back a markdown image embed. Always use inline data with "data": {"values": [...]}. Never use "data": {"url": "..."}.

Parameters

NameTypeRequiredDescription
specstringyesComplete Vega-Lite JSON specification. Must include "data" with inline "values", "mark" type, and "encoding". Always use {"data": {"values": [...]}} for data.
titlestringnoChart title used as alt text (default: "Chart").
widthintegernoOutput width in pixels (default: 800, range: 200–4000).

Supported Mark Types

bar, line, point, area, rect, circle, square, arc, text, tick, rule, trail, boxplot

Always include "type" in encoding channels: "quantitative", "nominal", "ordinal", or "temporal".

Example

local result = app.integrations.vegalite.render_vegalite({
  spec = [[{
    "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
    "data": {
      "values": [
        {"category": "A", "value": 28},
        {"category": "B", "value": 55},
        {"category": "C", "value": 43}
      ]
    },
    "mark": "bar",
    "encoding": {
      "x": {"field": "category", "type": "nominal"},
      "y": {"field": "value", "type": "quantitative"}
    }
  }]],
  title = "Sample Bar Chart",
  width = 600
})

print(result)
Raw agent markdown
# Vega-Lite — Lua API Reference

## render_vegalite

Render a Vega-Lite visualization to a PNG image. Pass a complete Vega-Lite JSON specification and get back a markdown image embed. Always use inline data with `"data": {"values": [...]}`. Never use `"data": {"url": "..."}`.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `spec` | string | yes | Complete Vega-Lite JSON specification. Must include `"data"` with inline `"values"`, `"mark"` type, and `"encoding"`. Always use `{"data": {"values": [...]}}` for data. |
| `title` | string | no | Chart title used as alt text (default: `"Chart"`). |
| `width` | integer | no | Output width in pixels (default: 800, range: 200–4000). |

### Supported Mark Types

`bar`, `line`, `point`, `area`, `rect`, `circle`, `square`, `arc`, `text`, `tick`, `rule`, `trail`, `boxplot`

Always include `"type"` in encoding channels: `"quantitative"`, `"nominal"`, `"ordinal"`, or `"temporal"`.

### Example

```lua
local result = app.integrations.vegalite.render_vegalite({
  spec = [[{
    "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
    "data": {
      "values": [
        {"category": "A", "value": 28},
        {"category": "B", "value": 55},
        {"category": "C", "value": 43}
      ]
    },
    "mark": "bar",
    "encoding": {
      "x": {"field": "category", "type": "nominal"},
      "y": {"field": "value", "type": "quantitative"}
    }
  }]],
  title = "Sample Bar Chart",
  width = 600
})

print(result)
```

Metadata-Derived Lua Example

local result = app.integrations.vegalite.render_vegalite({
  spec = "example_spec",
  title = "example_title",
  width = 1
})
print(result)

Functions

render_vegalite

Render a Vega-Lite visualization to a PNG image. Pass a complete Vega-Lite JSON specification and get back a markdown image embed. IMPORTANT: Always use inline data with "data": {"values": [...]}. Never use "data": {"url": "..."}. Example spec: { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": {"values": [ {"category": "A", "value": 28}, {"category": "B", "value": 55}, {"category": "C", "value": 43} ]}, "mark": "bar", "encoding": { "x": {"field": "category", "type": "nominal"}, "y": {"field": "value", "type": "quantitative"} } } Supported mark types: bar, line, point, area, rect, circle, square, arc, text, tick, rule, trail, boxplot. Always include "type" in encoding channels: "quantitative", "nominal", "ordinal", or "temporal".

Operation
Write write
Full name
vegalite.render_vegalite
ParameterTypeRequiredDescription
spec string yes Complete Vega-Lite JSON specification. Must include "data" with inline "values", "mark" type, and "encoding". Always use {"data": {"values": [...]}} for data.
title string no Chart title used as alt text (default: "Chart").
width integer no Output width in pixels (default: 800, range: 200–4000).