KosmoKrator

other

Cloudinary Lua API for KosmoKrator Agents

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

6 functions 4 read 2 write Manual OAuth token auth

Lua Namespace

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

Cloudinary — Lua API Reference

upload

Upload an image to Cloudinary.

Parameters

NameTypeRequiredDescription
filestringyesFile to upload — a remote URL or base64 data URI
public_idstringnoPublic ID to assign (auto-generated if omitted)
folderstringnoFolder path (e.g. "blog/images")

Example

local result = app.integrations.cloudinary.upload({
  file = "https://example.com/photo.jpg",
  public_id = "blog/hero",
  folder = "blog"
})

print("Uploaded: " .. result.secure_url)
print("Dimensions: " .. result.width .. "x" .. result.height)

list_resources

List media resources in your Cloudinary cloud.

Parameters

NameTypeRequiredDescription
typestringnoResource type: "image", "video", or "raw" (default: "image")
max_resultsintegernoMax resources to return (max 500)
next_cursorstringnoPagination cursor from a previous response
prefixstringnoOnly resources whose public ID starts with this prefix

Example

local result = app.integrations.cloudinary.list_resources({
  type = "image",
  prefix = "blog/",
  max_results = 20
})

for _, resource in ipairs(result.resources) do
  print(resource.public_id .. " (" .. resource.format .. ")")
end

get_resource

Get details of a specific Cloudinary resource.

Parameters

NameTypeRequiredDescription
typestringyesResource type: "image", "video", or "raw"
public_idstringyesPublic ID of the resource

Example

local result = app.integrations.cloudinary.get_resource({
  type = "image",
  public_id = "blog/hero"
})

print(result.secure_url)
print("Size: " .. result.bytes .. " bytes")

delete_resource

Delete a media resource from Cloudinary. This action is irreversible.

Parameters

NameTypeRequiredDescription
typestringyesResource type: "image", "video", or "raw"
public_idstringyesPublic ID of the resource to delete

Example

local result = app.integrations.cloudinary.delete_resource({
  type = "image",
  public_id = "blog/old-photo"
})

print(result.message)

list_folders

List all folders in your Cloudinary cloud.

Parameters

NameTypeRequiredDescription
max_resultsintegernoMax folders to return
next_cursorstringnoPagination cursor from a previous response

Example

local result = app.integrations.cloudinary.list_folders({})

for _, folder in ipairs(result.folders) do
  print(folder.name .. " (" .. folder.path .. ")")
end

get_current_user

Get the currently authenticated Cloudinary user profile.

Parameters

None.

Example

local result = app.integrations.cloudinary.get_current_user({})
print("Connected as: " .. result.name .. " (" .. result.email .. ")")

Multi-Account Usage

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

-- Default account (always works)
app.integrations.cloudinary.upload({...})

-- Explicit default (portable across setups)
app.integrations.cloudinary.default.upload({...})

-- Named accounts
app.integrations.cloudinary.production.upload({...})
app.integrations.cloudinary.staging.upload({...})

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

Raw agent markdown
# Cloudinary — Lua API Reference

## upload

Upload an image to Cloudinary.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file` | string | yes | File to upload — a remote URL or base64 data URI |
| `public_id` | string | no | Public ID to assign (auto-generated if omitted) |
| `folder` | string | no | Folder path (e.g. `"blog/images"`) |

### Example

```lua
local result = app.integrations.cloudinary.upload({
  file = "https://example.com/photo.jpg",
  public_id = "blog/hero",
  folder = "blog"
})

print("Uploaded: " .. result.secure_url)
print("Dimensions: " .. result.width .. "x" .. result.height)
```

---

## list_resources

List media resources in your Cloudinary cloud.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | no | Resource type: `"image"`, `"video"`, or `"raw"` (default: `"image"`) |
| `max_results` | integer | no | Max resources to return (max 500) |
| `next_cursor` | string | no | Pagination cursor from a previous response |
| `prefix` | string | no | Only resources whose public ID starts with this prefix |

### Example

```lua
local result = app.integrations.cloudinary.list_resources({
  type = "image",
  prefix = "blog/",
  max_results = 20
})

for _, resource in ipairs(result.resources) do
  print(resource.public_id .. " (" .. resource.format .. ")")
end
```

---

## get_resource

Get details of a specific Cloudinary resource.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | yes | Resource type: `"image"`, `"video"`, or `"raw"` |
| `public_id` | string | yes | Public ID of the resource |

### Example

```lua
local result = app.integrations.cloudinary.get_resource({
  type = "image",
  public_id = "blog/hero"
})

print(result.secure_url)
print("Size: " .. result.bytes .. " bytes")
```

---

## delete_resource

Delete a media resource from Cloudinary. **This action is irreversible.**

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `type` | string | yes | Resource type: `"image"`, `"video"`, or `"raw"` |
| `public_id` | string | yes | Public ID of the resource to delete |

### Example

```lua
local result = app.integrations.cloudinary.delete_resource({
  type = "image",
  public_id = "blog/old-photo"
})

print(result.message)
```

---

## list_folders

List all folders in your Cloudinary cloud.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `max_results` | integer | no | Max folders to return |
| `next_cursor` | string | no | Pagination cursor from a previous response |

### Example

```lua
local result = app.integrations.cloudinary.list_folders({})

for _, folder in ipairs(result.folders) do
  print(folder.name .. " (" .. folder.path .. ")")
end
```

---

## get_current_user

Get the currently authenticated Cloudinary user profile.

### Parameters

None.

### Example

```lua
local result = app.integrations.cloudinary.get_current_user({})
print("Connected as: " .. result.name .. " (" .. result.email .. ")")
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations.cloudinary.upload({...})

-- Explicit default (portable across setups)
app.integrations.cloudinary.default.upload({...})

-- Named accounts
app.integrations.cloudinary.production.upload({...})
app.integrations.cloudinary.staging.upload({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.cloudinary.cloudinary_upload({
  file = "example_file",
  public_id = "example_public_id",
  folder = "example_folder"
})
print(result)

Functions

cloudinary_upload

Upload an image to Cloudinary. Provide a file URL or base64 data URI, an optional public ID, and an optional folder path. Returns the uploaded asset details.

Operation
Write write
Full name
cloudinary.cloudinary_upload
ParameterTypeRequiredDescription
file string yes The file to upload — a remote URL (e.g. "https://example.com/photo.jpg") or a base64 data URI (e.g. "data:image/png;base64,...").
public_id string no The public ID to assign to the uploaded asset. If omitted, Cloudinary generates a random ID.
folder string no The folder to store the asset in (e.g. "blog/images").

cloudinary_list_resources

List media resources in your Cloudinary cloud. Filter by resource type (image, video, raw) and prefix. Supports pagination with max_results and next_cursor.

Operation
Read read
Full name
cloudinary.cloudinary_list_resources
ParameterTypeRequiredDescription
type string no Resource type to list: "image", "video", or "raw". Defaults to "image".
max_results integer no Maximum number of resources to return (max 500, default 10).
next_cursor string no Pagination cursor from a previous response to get the next page.
prefix string no Only include resources whose public ID starts with this prefix (e.g. "blog/").

cloudinary_get_resource

Get details of a specific Cloudinary resource by its type and public ID. Returns full asset metadata including dimensions, format, URL, tags, and derived resources.

Operation
Read read
Full name
cloudinary.cloudinary_get_resource
ParameterTypeRequiredDescription
type string yes Resource type: "image", "video", or "raw".
public_id string yes The public ID of the resource (e.g. "blog/hero-image").

cloudinary_delete_resource

Delete a media resource from Cloudinary by its type and public ID. This permanently removes the asset and all its derived resources.

Operation
Write write
Full name
cloudinary.cloudinary_delete_resource
ParameterTypeRequiredDescription
type string yes Resource type: "image", "video", or "raw".
public_id string yes The public ID of the resource to delete (e.g. "blog/old-photo").

cloudinary_list_folders

List all folders in your Cloudinary cloud. Returns folder names and paths with pagination support.

Operation
Read read
Full name
cloudinary.cloudinary_list_folders
ParameterTypeRequiredDescription
max_results integer no Maximum number of folders to return (default 10).
next_cursor string no Pagination cursor from a previous response to get the next page.

cloudinary_get_current_user

Get the currently authenticated Cloudinary user profile. Returns user name, email, and account details. Use this to verify that credentials are working.

Operation
Read read
Full name
cloudinary.cloudinary_get_current_user
ParameterTypeRequiredDescription
No parameters.