KosmoKrator

data

AssemblyAI Lua API for KosmoKrator Agents

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

Lua Namespace

Agents call this integration through app.integrations.assemblyai.*. Use lua_read_doc("integrations.assemblyai") 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 AssemblyAI workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.assemblyai.transcribe_audio({audio_url = "example_audio_url", language_code = "example_language_code", speaker_labels = true, auto_chapters = true, entity_detection = true, sentiment_analysis = true, summarization = true, punctuate = true}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("assemblyai"))' --json
kosmo integrations:lua --eval 'print(docs.read("assemblyai.transcribe_audio"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local assemblyai = app.integrations.assemblyai
local result = assemblyai.transcribe_audio({audio_url = "example_audio_url", language_code = "example_language_code", speaker_labels = true, auto_chapters = true, entity_detection = true, sentiment_analysis = true, summarization = true, punctuate = true})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.assemblyai, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.assemblyai.default.* or app.integrations.assemblyai.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need AssemblyAI, use the narrower mcp:lua command.

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.

AssemblyAI — Lua API Reference

Namespace: app.integrations.assemblyai

This integration covers AssemblyAI’s REST JSON APIs for pre-recorded transcription, transcript exports, temporary Streaming STT tokens, and LLM Gateway chat completions.

Transcripts

local created = app.integrations.assemblyai.transcribe({
  audio_url = "https://example.test/meeting.mp3",
  speech_models = { "universal-3-pro", "universal-2" },
  speaker_labels = true,
  sentiment_analysis = true,
  auto_chapters = true
})

local transcript = app.integrations.assemblyai.get_transcript({
  id = created.id
})

local list = app.integrations.assemblyai.list_transcripts({
  limit = 10,
  after_id = "previous_transcript_id"
})

transcribe forwards AssemblyAI transcript options such as language detection, speech models, diarization, summarization, content safety, PII redaction, custom spelling, keyterms, webhooks, and audio start/end offsets.

Transcript Exports

local paragraphs = app.integrations.assemblyai.get_paragraphs({
  id = "transcript_id"
})

local sentences = app.integrations.assemblyai.get_sentences({
  id = "transcript_id"
})

local subtitles = app.integrations.assemblyai.get_subtitles({
  id = "transcript_id",
  format = "vtt",
  chars_per_caption = 40
})

print(subtitles.content)

Use get_redacted_audio only for transcripts created with redact_pii_audio = true.

local redacted = app.integrations.assemblyai.get_redacted_audio({
  id = "transcript_id"
})

Delete Transcript

local deleted = app.integrations.assemblyai.delete_transcript({
  id = "transcript_id"
})

Deleting a transcript removes transcript data and any uploaded file associated with that transcript.

Upload

local upload = app.integrations.assemblyai.upload({
  file_path = "/tmp/recording.mp3"
})

local created = app.integrations.assemblyai.transcribe({
  audio_url = upload.upload_url
})

Streaming Token

local token = app.integrations.assemblyai.create_streaming_token({
  expires_in_seconds = 60,
  max_session_duration_seconds = 3600
})

Use the returned token as the token query parameter when connecting to wss://streaming.assemblyai.com/v3/ws.

LLM Gateway Chat

local response = app.integrations.assemblyai.llm_gateway_chat({
  model = "claude-sonnet-4-5-20250929",
  prompt = "Summarize this meeting transcript in five bullets.",
  max_tokens = 1000,
  temperature = 0.2
})

print(response.choices[1].message.content)

You can pass messages, tools, tool_choice, response_format, fallbacks, and fallback_config using the current AssemblyAI LLM Gateway shape.

Multi-Account Usage

app.integrations.assemblyai.transcribe({...})
app.integrations.assemblyai.default.transcribe({...})
app.integrations.assemblyai.production.transcribe({...})
Raw agent markdown
# AssemblyAI — Lua API Reference

Namespace: `app.integrations.assemblyai`

This integration covers AssemblyAI's REST JSON APIs for pre-recorded transcription, transcript exports, temporary Streaming STT tokens, and LLM Gateway chat completions.

## Transcripts

```lua
local created = app.integrations.assemblyai.transcribe({
  audio_url = "https://example.test/meeting.mp3",
  speech_models = { "universal-3-pro", "universal-2" },
  speaker_labels = true,
  sentiment_analysis = true,
  auto_chapters = true
})

local transcript = app.integrations.assemblyai.get_transcript({
  id = created.id
})

local list = app.integrations.assemblyai.list_transcripts({
  limit = 10,
  after_id = "previous_transcript_id"
})
```

`transcribe` forwards AssemblyAI transcript options such as language detection, speech models, diarization, summarization, content safety, PII redaction, custom spelling, keyterms, webhooks, and audio start/end offsets.

## Transcript Exports

```lua
local paragraphs = app.integrations.assemblyai.get_paragraphs({
  id = "transcript_id"
})

local sentences = app.integrations.assemblyai.get_sentences({
  id = "transcript_id"
})

local subtitles = app.integrations.assemblyai.get_subtitles({
  id = "transcript_id",
  format = "vtt",
  chars_per_caption = 40
})

print(subtitles.content)
```

Use `get_redacted_audio` only for transcripts created with `redact_pii_audio = true`.

```lua
local redacted = app.integrations.assemblyai.get_redacted_audio({
  id = "transcript_id"
})
```

## Delete Transcript

```lua
local deleted = app.integrations.assemblyai.delete_transcript({
  id = "transcript_id"
})
```

Deleting a transcript removes transcript data and any uploaded file associated with that transcript.

## Upload

```lua
local upload = app.integrations.assemblyai.upload({
  file_path = "/tmp/recording.mp3"
})

local created = app.integrations.assemblyai.transcribe({
  audio_url = upload.upload_url
})
```

## Streaming Token

```lua
local token = app.integrations.assemblyai.create_streaming_token({
  expires_in_seconds = 60,
  max_session_duration_seconds = 3600
})
```

Use the returned token as the `token` query parameter when connecting to `wss://streaming.assemblyai.com/v3/ws`.

## LLM Gateway Chat

```lua
local response = app.integrations.assemblyai.llm_gateway_chat({
  model = "claude-sonnet-4-5-20250929",
  prompt = "Summarize this meeting transcript in five bullets.",
  max_tokens = 1000,
  temperature = 0.2
})

print(response.choices[1].message.content)
```

You can pass `messages`, `tools`, `tool_choice`, `response_format`, `fallbacks`, and `fallback_config` using the current AssemblyAI LLM Gateway shape.

## Multi-Account Usage

```lua
app.integrations.assemblyai.transcribe({...})
app.integrations.assemblyai.default.transcribe({...})
app.integrations.assemblyai.production.transcribe({...})
```
Metadata-derived Lua example
local result = app.integrations.assemblyai.transcribe_audio({audio_url = "example_audio_url", language_code = "example_language_code", speaker_labels = true, auto_chapters = true, entity_detection = true, sentiment_analysis = true, summarization = true, punctuate = true})
print(result)

Functions

transcribe_audio Write

Submit an audio or video file URL for AI transcription. Supports speech-to-text, speaker diarization, summarization, sentiment analysis, and more. Returns a transcript ID to poll for results.

Lua path
app.integrations.assemblyai.transcribe_audio
Full name
assemblyai.assemblyai_transcribe
ParameterTypeRequiredDescription
audio_url string yes URL of the audio or video file to transcribe. Can also be an AssemblyAI upload URL from the upload tool.
language_code string no Language code (e.g., "en_us", "es", "fr"). Defaults to auto-detection if omitted.
speaker_labels boolean no Enable speaker diarization to identify who spoke and when.
auto_chapters boolean no Automatically break the transcript into chapters.
entity_detection boolean no Detect entities like dates, locations, and organizations in the transcript.
sentiment_analysis boolean no Analyze sentiment (positive, negative, neutral) for each sentence.
summarization boolean no Generate a summary of the transcript.
punctuate boolean no Add punctuation to the transcript.
format_text boolean no Format text with capitalization and paragraph breaks.
webhook_url string no URL to receive a webhook when the transcript is complete.
custom_topics array no List of custom topics to detect in the audio.
topics array no Enable topic detection with AssemblyAI's built-in topics.
get_transcript Read

Retrieve a transcript by ID. Returns the transcription text, status (queued, processing, completed, error), confidence score, and any enabled AI features like speaker labels, chapters, or sentiment analysis.

Lua path
app.integrations.assemblyai.get_transcript
Full name
assemblyai.assemblyai_get_transcript
ParameterTypeRequiredDescription
id string yes The transcript ID returned by the transcribe tool.
delete_transcript Write

Delete an AssemblyAI transcript and remove associated uploaded file data from AssemblyAI systems.

Lua path
app.integrations.assemblyai.delete_transcript
Full name
assemblyai.assemblyai_delete_transcript
ParameterTypeRequiredDescription
id string yes Transcript ID.
get_paragraphs Read

Get a completed transcript split into semantic paragraphs with timestamps and words.

Lua path
app.integrations.assemblyai.get_paragraphs
Full name
assemblyai.assemblyai_get_paragraphs
ParameterTypeRequiredDescription
id string yes Transcript ID.
get_sentences Read

Get a completed transcript split into semantic sentences with timestamps and words.

Lua path
app.integrations.assemblyai.get_sentences
Full name
assemblyai.assemblyai_get_sentences
ParameterTypeRequiredDescription
id string yes Transcript ID.
get_subtitles Read

Export a completed transcript as SRT or VTT subtitle text.

Lua path
app.integrations.assemblyai.get_subtitles
Full name
assemblyai.assemblyai_get_subtitles
ParameterTypeRequiredDescription
id string yes Transcript ID.
format string no Subtitle format: srt or vtt. Defaults to srt.
chars_per_caption integer no Maximum characters per caption.
get_redacted_audio Read

Get redacted audio for a transcript created with redact_pii_audio enabled.

Lua path
app.integrations.assemblyai.get_redacted_audio
Full name
assemblyai.assemblyai_get_redacted_audio
ParameterTypeRequiredDescription
id string yes Transcript ID.
list_transcripts Read

List transcripts with pagination. Returns transcript IDs, statuses, and metadata.

Lua path
app.integrations.assemblyai.list_transcripts
Full name
assemblyai.assemblyai_list_transcripts
ParameterTypeRequiredDescription
limit integer no Maximum number of transcripts to return per page (default: 20, max: 200).
before_id string no Return transcripts created before this transcript ID (for pagination).
after_id string no Return transcripts created after this transcript ID (for pagination).
upload_file Write

Upload a local audio or video file to AssemblyAI. Returns an upload URL that can be passed to the transcribe tool as the audio_url parameter. Supports most common audio and video formats.

Lua path
app.integrations.assemblyai.upload_file
Full name
assemblyai.assemblyai_upload
ParameterTypeRequiredDescription
file_path string yes Absolute path to the local audio or video file to upload (e.g., "/tmp/recording.mp3").
create_streaming_token Read

Generate a temporary token for browser or client-side Streaming Speech-to-Text sessions.

Lua path
app.integrations.assemblyai.create_streaming_token
Full name
assemblyai.assemblyai_create_streaming_token
ParameterTypeRequiredDescription
expires_in_seconds integer yes Token lifetime from 1 to 600 seconds.
max_session_duration_seconds integer no Maximum streaming session duration from 60 to 10800 seconds.
llm_gateway_chat Read

Create a chat completion through AssemblyAI LLM Gateway using a prompt or message list.

Lua path
app.integrations.assemblyai.llm_gateway_chat
Full name
assemblyai.assemblyai_llm_gateway_chat
ParameterTypeRequiredDescription
model string yes LLM Gateway model id.
messages array no Conversation messages. Either messages or prompt is required.
prompt string no Simple single-turn prompt. Either prompt or messages is required.
max_tokens integer no Maximum output tokens. Defaults to 1000 upstream.
temperature number no Sampling temperature.
tools array no Optional tool/function definitions.
tool_choice object no Optional tool choice control.
response_format object no Optional structured output format.
fallbacks array no Optional fallback model configs.
fallback_config object no Optional fallback behavior config.