KosmoKrator

ai

Replicate Lua API for KosmoKrator Agents

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

7 functions 6 read 1 write API key auth

Lua Namespace

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

Replicate — Lua API Reference

list_predictions

List recent Replicate predictions.

Parameters

None.

Example

local result = app.integrations["replicate"].list_predictions({})

for _, prediction in ipairs(result.results) do
  print(prediction.id .. " - " .. prediction.status)
end

get_prediction

Get detailed information about a specific prediction.

Parameters

NameTypeRequiredDescription
prediction_idstringyesThe unique prediction identifier

Example

local prediction = app.integrations["replicate"].get_prediction({
  prediction_id = "abc123def456"
})

print("Status: " .. prediction.status)
print("Model: " .. prediction.version)
if prediction.output then
  print("Output: " .. vim.inspect(prediction.output))
end

create_prediction

Create a new prediction using a model version.

Parameters

NameTypeRequiredDescription
versionstringyesThe model version ID (hex string)
inputobjectyesModel input values (varies by model)
webhookstringnoURL to receive POST notifications on completion
webhook_eventsarraynoList of webhook events (e.g., {"output", "completed"})

Example

local prediction = app.integrations["replicate"].create_prediction({
  version = "5c7d5dc6dd8bf75c1acaa8565735e7986bc5fc6681734b58f0b7ef5f02a3ca2e",
  input = {
    prompt = "A beautiful sunset over the ocean",
    num_outputs = 1
  },
  webhook = "https://example.com/webhook",
  webhook_events = { "completed" }
})

print("Prediction ID: " .. prediction.id)
print("Status: " .. prediction.status)

list_models

List available Replicate models.

Parameters

None.

Example

local result = app.integrations["replicate"].list_models({})

for _, model in ipairs(result.results) do
  print(model.owner .. "/" .. model.name .. ": " .. model.description)
end

get_model

Get detailed information about a specific model.

Parameters

NameTypeRequiredDescription
model_ownerstringyesThe model owner (user or organization)
model_namestringyesThe model name

Example

local model = app.integrations["replicate"].get_model({
  model_owner = "stability-ai",
  model_name = "stable-diffusion"
})

print("Owner: " .. model.owner)
print("Name: " .. model.name)
print("Description: " .. model.description)
if model.latest_version then
  print("Latest version: " .. model.latest_version.id)
end

list_collections

List curated model collections on Replicate.

Parameters

None.

Example

local result = app.integrations["replicate"].list_collections({})

for _, collection in ipairs(result.results) do
  print(collection.slug .. ": " .. collection.description)
end

get_current_user

Get the current user’s profile and billing information.

Parameters

None.

Example

local user = app.integrations["replicate"].get_current_user({})

print("Name: " .. user.name)
print("Username: " .. user.username)

Multi-Account Usage

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

-- Default account (always works)
app.integrations["replicate"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["replicate"].default.function_name({...})

-- Named accounts
app.integrations["replicate"].production.function_name({...})
app.integrations["replicate"].staging.function_name({...})

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

Raw agent markdown
# Replicate — Lua API Reference

## list_predictions

List recent Replicate predictions.

### Parameters

None.

### Example

```lua
local result = app.integrations["replicate"].list_predictions({})

for _, prediction in ipairs(result.results) do
  print(prediction.id .. " - " .. prediction.status)
end
```

---

## get_prediction

Get detailed information about a specific prediction.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `prediction_id` | string | yes | The unique prediction identifier |

### Example

```lua
local prediction = app.integrations["replicate"].get_prediction({
  prediction_id = "abc123def456"
})

print("Status: " .. prediction.status)
print("Model: " .. prediction.version)
if prediction.output then
  print("Output: " .. vim.inspect(prediction.output))
end
```

---

## create_prediction

Create a new prediction using a model version.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `version` | string | yes | The model version ID (hex string) |
| `input` | object | yes | Model input values (varies by model) |
| `webhook` | string | no | URL to receive POST notifications on completion |
| `webhook_events` | array | no | List of webhook events (e.g., `{"output", "completed"}`) |

### Example

```lua
local prediction = app.integrations["replicate"].create_prediction({
  version = "5c7d5dc6dd8bf75c1acaa8565735e7986bc5fc6681734b58f0b7ef5f02a3ca2e",
  input = {
    prompt = "A beautiful sunset over the ocean",
    num_outputs = 1
  },
  webhook = "https://example.com/webhook",
  webhook_events = { "completed" }
})

print("Prediction ID: " .. prediction.id)
print("Status: " .. prediction.status)
```

---

## list_models

List available Replicate models.

### Parameters

None.

### Example

```lua
local result = app.integrations["replicate"].list_models({})

for _, model in ipairs(result.results) do
  print(model.owner .. "/" .. model.name .. ": " .. model.description)
end
```

---

## get_model

Get detailed information about a specific model.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model_owner` | string | yes | The model owner (user or organization) |
| `model_name` | string | yes | The model name |

### Example

```lua
local model = app.integrations["replicate"].get_model({
  model_owner = "stability-ai",
  model_name = "stable-diffusion"
})

print("Owner: " .. model.owner)
print("Name: " .. model.name)
print("Description: " .. model.description)
if model.latest_version then
  print("Latest version: " .. model.latest_version.id)
end
```

---

## list_collections

List curated model collections on Replicate.

### Parameters

None.

### Example

```lua
local result = app.integrations["replicate"].list_collections({})

for _, collection in ipairs(result.results) do
  print(collection.slug .. ": " .. collection.description)
end
```

---

## get_current_user

Get the current user's profile and billing information.

### Parameters

None.

### Example

```lua
local user = app.integrations["replicate"].get_current_user({})

print("Name: " .. user.name)
print("Username: " .. user.username)
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations["replicate"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["replicate"].default.function_name({...})

-- Named accounts
app.integrations["replicate"].production.function_name({...})
app.integrations["replicate"].staging.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.replicate.replicate_list_predictions({})
print(result)

Functions

replicate_list_predictions

List recent Replicate predictions. Returns prediction IDs, statuses, model versions, and outputs.

Operation
Read read
Full name
replicate.replicate_list_predictions
ParameterTypeRequiredDescription
No parameters.

replicate_get_prediction

Get detailed information about a specific Replicate prediction by its ID, including status, output, logs, and error details.

Operation
Read read
Full name
replicate.replicate_get_prediction
ParameterTypeRequiredDescription
prediction_id string yes The unique prediction identifier.

replicate_create_prediction

Create a new prediction on Replicate by providing a model version and input. Returns the prediction object with status. Poll get_prediction for results.

Operation
Write write
Full name
replicate.replicate_create_prediction
ParameterTypeRequiredDescription
version string yes The model version ID (a hex string).
input object yes An object of model input values (varies by model).
webhook string no A URL to receive POST notifications when the prediction completes.
webhook_events array no List of webhook events to subscribe to (e.g., ["output", "completed"]).

replicate_list_models

List available Replicate models. Returns model names, owners, descriptions, and latest version IDs.

Operation
Read read
Full name
replicate.replicate_list_models
ParameterTypeRequiredDescription
No parameters.

replicate_get_model

Get detailed information about a specific Replicate model by owner and name, including description, versions, and input schema.

Operation
Read read
Full name
replicate.replicate_get_model
ParameterTypeRequiredDescription
model_owner string yes The model owner (user or organization name).
model_name string yes The model name.

replicate_list_collections

List curated model collections on Replicate. Returns collection names, descriptions, and model slugs.

Operation
Read read
Full name
replicate.replicate_list_collections
ParameterTypeRequiredDescription
No parameters.

replicate_get_current_user

Get the current Replicate user profile and billing information.

Operation
Read read
Full name
replicate.replicate_get_current_user
ParameterTypeRequiredDescription
No parameters.