KosmoKrator

ai

Retell AI Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write Bearer token auth

Lua Namespace

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

Retell AI — Lua API Reference

list_calls

List AI voice calls with optional filtering and pagination.

Parameters

NameTypeRequiredDescription
limitintegernoMaximum number of calls to return
filter_criteriaobjectnoFilter criteria (e.g., {"agent_id": "agent_123"})
beforestringnoReturn calls created before this timestamp (cursor pagination)
afterstringnoReturn calls created after this timestamp (cursor pagination)

Examples

-- List recent calls
local result = app.integrations.retell.list_calls({
  limit = 10
})

for _, call in ipairs(result.calls or {}) do
  print(call.call_id .. ": " .. call.call_status)
end

-- Filter by agent
local result = app.integrations.retell.list_calls({
  limit = 5,
  filter_criteria = { agent_id = "agent_abcdef123456" }
})

get_call

Get detailed information about a specific call.

Parameters

NameTypeRequiredDescription
call_idstringyesThe unique call identifier

Example

local result = app.integrations.retell.get_call({
  call_id = "call_abcdef123456"
})

print("Status: " .. result.call_status)
print("Duration: " .. (result.start_timestamp and result.end_timestamp and (result.end_timestamp - result.start_timestamp) or "N/A"))

create_phone_call

Initiate a new AI-powered phone call.

Parameters

NameTypeRequiredDescription
agent_idstringyesThe agent to use for the call
metadataobjectnoCustom metadata to attach to the call
retell_llm_dynamic_variablesobjectnoDynamic variables injected into the agent’s LLM prompt

Example

local result = app.integrations.retell.create_phone_call({
  agent_id = "agent_abcdef123456",
  metadata = {
    customer_name = "Acme Corp",
    call_purpose = "follow-up"
  },
  retell_llm_dynamic_variables = {
    customer_name = "John",
    account_type = "premium"
  }
})

print("Call created: " .. result.call_id)

list_agents

List all AI voice agents.

Parameters

None.

Example

local result = app.integrations.retell.list_agents()

for _, agent in ipairs(result.agents or {}) do
  print(agent.agent_id .. ": " .. (agent.name or "Unnamed"))
end

get_agent

Get detailed information about a specific agent.

Parameters

NameTypeRequiredDescription
agent_idstringyesThe unique agent identifier

Example

local result = app.integrations.retell.get_agent({
  agent_id = "agent_abcdef123456"
})

print("Agent: " .. (result.name or "Unnamed"))
print("Model: " .. (result.model or "N/A"))
print("Voice: " .. (result.voice_id or "N/A"))

create_agent

Create a new AI voice agent.

Parameters

NameTypeRequiredDescription
modelstringnoLLM model (e.g., "gpt-4o", "gpt-4o-mini")
voice_idstringnoVoice ID for the agent
promptstringnoSystem prompt defining agent behavior
response_engineobjectnoResponse engine configuration

Example

local result = app.integrations.retell.create_agent({
  model = "gpt-4o",
  voice_id = "11labs-Adrian",
  prompt = "You are a helpful customer support agent for Acme Corp. Be friendly and concise.",
  response_engine = {
    type = "retell-llm"
  }
})

print("Agent created: " .. result.agent_id)

get_current_user

Get the currently authenticated Retell AI user.

Parameters

None.

Example

local result = app.integrations.retell.get_current_user()

print("User: " .. (result.email or result.name or "Unknown"))

Multi-Account Usage

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

-- Default account (always works)
app.integrations.retell.list_calls({})

-- Explicit default (portable across setups)
app.integrations.retell.default.list_calls({})

-- Named accounts
app.integrations.retell.production.list_calls({})
app.integrations.retell.staging.list_agents({})

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

Raw agent markdown
# Retell AI — Lua API Reference

## list_calls

List AI voice calls with optional filtering and pagination.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Maximum number of calls to return |
| `filter_criteria` | object | no | Filter criteria (e.g., `{"agent_id": "agent_123"}`) |
| `before` | string | no | Return calls created before this timestamp (cursor pagination) |
| `after` | string | no | Return calls created after this timestamp (cursor pagination) |

### Examples

```lua
-- List recent calls
local result = app.integrations.retell.list_calls({
  limit = 10
})

for _, call in ipairs(result.calls or {}) do
  print(call.call_id .. ": " .. call.call_status)
end

-- Filter by agent
local result = app.integrations.retell.list_calls({
  limit = 5,
  filter_criteria = { agent_id = "agent_abcdef123456" }
})
```

---

## get_call

Get detailed information about a specific call.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `call_id` | string | yes | The unique call identifier |

### Example

```lua
local result = app.integrations.retell.get_call({
  call_id = "call_abcdef123456"
})

print("Status: " .. result.call_status)
print("Duration: " .. (result.start_timestamp and result.end_timestamp and (result.end_timestamp - result.start_timestamp) or "N/A"))
```

---

## create_phone_call

Initiate a new AI-powered phone call.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_id` | string | yes | The agent to use for the call |
| `metadata` | object | no | Custom metadata to attach to the call |
| `retell_llm_dynamic_variables` | object | no | Dynamic variables injected into the agent's LLM prompt |

### Example

```lua
local result = app.integrations.retell.create_phone_call({
  agent_id = "agent_abcdef123456",
  metadata = {
    customer_name = "Acme Corp",
    call_purpose = "follow-up"
  },
  retell_llm_dynamic_variables = {
    customer_name = "John",
    account_type = "premium"
  }
})

print("Call created: " .. result.call_id)
```

---

## list_agents

List all AI voice agents.

### Parameters

None.

### Example

```lua
local result = app.integrations.retell.list_agents()

for _, agent in ipairs(result.agents or {}) do
  print(agent.agent_id .. ": " .. (agent.name or "Unnamed"))
end
```

---

## get_agent

Get detailed information about a specific agent.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `agent_id` | string | yes | The unique agent identifier |

### Example

```lua
local result = app.integrations.retell.get_agent({
  agent_id = "agent_abcdef123456"
})

print("Agent: " .. (result.name or "Unnamed"))
print("Model: " .. (result.model or "N/A"))
print("Voice: " .. (result.voice_id or "N/A"))
```

---

## create_agent

Create a new AI voice agent.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model` | string | no | LLM model (e.g., `"gpt-4o"`, `"gpt-4o-mini"`) |
| `voice_id` | string | no | Voice ID for the agent |
| `prompt` | string | no | System prompt defining agent behavior |
| `response_engine` | object | no | Response engine configuration |

### Example

```lua
local result = app.integrations.retell.create_agent({
  model = "gpt-4o",
  voice_id = "11labs-Adrian",
  prompt = "You are a helpful customer support agent for Acme Corp. Be friendly and concise.",
  response_engine = {
    type = "retell-llm"
  }
})

print("Agent created: " .. result.agent_id)
```

---

## get_current_user

Get the currently authenticated Retell AI user.

### Parameters

None.

### Example

```lua
local result = app.integrations.retell.get_current_user()

print("User: " .. (result.email or result.name or "Unknown"))
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.retell.list_calls({})

-- Explicit default (portable across setups)
app.integrations.retell.default.list_calls({})

-- Named accounts
app.integrations.retell.production.list_calls({})
app.integrations.retell.staging.list_agents({})
```

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

Metadata-Derived Lua Example

local result = app.integrations.retell.retell_list_calls({
  limit = 1,
  filter_criteria = "example_filter_criteria",
  before = "example_before",
  after = "example_after"
})
print(result)

Functions

retell_list_calls

List AI voice calls from Retell. Supports filtering by criteria and cursor-based pagination using before/after timestamps.

Operation
Read read
Full name
retell.retell_list_calls
ParameterTypeRequiredDescription
limit integer no Maximum number of calls to return.
filter_criteria object no Filter criteria for calls. Supports filtering by agent_id, call_status, etc. Pass as a JSON object.
before string no Return calls created before this timestamp (ISO 8601 or Unix timestamp). Used for cursor-based pagination.
after string no Return calls created after this timestamp (ISO 8601 or Unix timestamp). Used for cursor-based pagination.

retell_get_call

Get detailed information about a specific AI voice call, including transcript, duration, and status.

Operation
Read read
Full name
retell.retell_get_call
ParameterTypeRequiredDescription
call_id string yes The unique identifier of the call (e.g., "call_abcdef123456").

retell_create_phone_call

Create a new AI-powered phone call using a Retell AI agent. The agent will handle the conversation automatically.

Operation
Write write
Full name
retell.retell_create_phone_call
ParameterTypeRequiredDescription
agent_id string yes The ID of the Retell AI agent to use for the call.
metadata object no Optional metadata to attach to the call (e.g., customer info, call purpose). Pass as a JSON object.
retell_llm_dynamic_variables object no Optional dynamic variables to inject into the agent's LLM prompt at runtime. Pass as a JSON object with string key-value pairs.

retell_list_agents

List all AI voice agents configured in Retell AI. Returns agent IDs, names, and configuration details.

Operation
Read read
Full name
retell.retell_list_agents
ParameterTypeRequiredDescription
No parameters.

retell_get_agent

Get detailed information about a specific AI voice agent, including its model, voice, prompt, and configuration.

Operation
Read read
Full name
retell.retell_get_agent
ParameterTypeRequiredDescription
agent_id string yes The unique identifier of the agent (e.g., "agent_abcdef123456").

retell_create_agent

Create a new AI voice agent in Retell AI. Configure the model, voice, system prompt, and response engine.

Operation
Write write
Full name
retell.retell_create_agent
ParameterTypeRequiredDescription
model string no The LLM model to use (e.g., "gpt-4o", "gpt-4o-mini", "claude-3.5-sonnet").
voice_id string no The voice ID to use for the agent. Browse available voices in the Retell AI dashboard.
prompt string no The system prompt that defines the agent's behavior and personality.
response_engine object no Response engine configuration. Pass as a JSON object (e.g., {"type": "retell-llm", "llm_url": "..."}).

retell_get_current_user

Get information about the currently authenticated Retell AI user. Useful for verifying credentials and account details.

Operation
Read read
Full name
retell.retell_get_current_user
ParameterTypeRequiredDescription
No parameters.