KosmoKrator

ai

Hugging Face Lua API for KosmoKrator Agents

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

7 functions 7 read 0 write Bearer token auth

Lua Namespace

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

Hugging Face — Lua API Reference

list_models

Search and list AI models on the Hugging Face Hub.

Parameters

NameTypeRequiredDescription
searchstringnoSearch query to filter models
authorstringnoFilter by organization or user
taskstringnoFilter by pipeline task (e.g. "text-generation", "image-classification")
tagsarraynoFilter by tags (e.g. {"pytorch", "safetensors"})
sortstringnoSort order: "downloads", "likes", "lastModified", "created"
directionstringnoSort direction: "asc" or "desc"
limitintegernoResults per page (default: 20, max: 500)
offsetintegernoOffset for pagination

Common Tasks

text-generation, text2text-generation, text-classification, token-classification, question-answering, summarization, translation, image-classification, image-generation, automatic-speech-recognition, feature-extraction, sentence-similarity

Examples

-- Top text-generation models
local result = app.integrations["huggingface"].list_models({
  task = "text-generation",
  sort = "downloads",
  limit = 10
})

for _, model in ipairs(result) do
  print(model.id .. " — " .. model.downloads .. " downloads")
end
-- Search for a specific model
local result = app.integrations["huggingface"].list_models({
  search = "bert-base",
  sort = "downloads",
  limit = 5
})

get_model

Get detailed information about a specific model.

Parameters

NameTypeRequiredDescription
model_idstringyesThe model ID (e.g. "meta-llama/Llama-3.3-70B-Instruct")

Example

local model = app.integrations["huggingface"].get_model({
  model_id = "meta-llama/Llama-3.3-70B-Instruct"
})

print(model.id)
print(model.pipeline_tag)
print(model.downloads .. " downloads")
print(model.likes .. " likes")

list_datasets

Search and list datasets on the Hugging Face Hub.

Parameters

NameTypeRequiredDescription
searchstringnoSearch query to filter datasets
authorstringnoFilter by organization or user
tagsarraynoFilter by tags
sortstringnoSort order: "downloads", "likes", "lastModified", "created"
directionstringnoSort direction: "asc" or "desc"
limitintegernoResults per page (default: 20, max: 500)
offsetintegernoOffset for pagination

Example

local datasets = app.integrations["huggingface"].list_datasets({
  search = "sentiment",
  sort = "downloads",
  limit = 10
})

for _, ds in ipairs(datasets) do
  print(ds.id .. " — " .. ds.downloads .. " downloads")
end

get_dataset

Get detailed information about a specific dataset.

Parameters

NameTypeRequiredDescription
dataset_idstringyesThe dataset ID (e.g. "mozilla-foundation/common_voice_17_0")

Example

local dataset = app.integrations["huggingface"].get_dataset({
  dataset_id = "imdb"
})

print(dataset.id)
print(dataset.downloads .. " downloads")
print(dataset.likes .. " likes")

list_spaces

Search and list Spaces on the Hugging Face Hub.

Parameters

NameTypeRequiredDescription
searchstringnoSearch query to filter Spaces
authorstringnoFilter by organization or user
tagsarraynoFilter by tags
sortstringnoSort order: "downloads", "likes", "lastModified", "created"
directionstringnoSort direction: "asc" or "desc"
limitintegernoResults per page (default: 20, max: 500)
offsetintegernoOffset for pagination

Example

local spaces = app.integrations["huggingface"].list_spaces({
  search = "chat",
  sort = "likes",
  limit = 10
})

for _, space in ipairs(spaces) do
  print(space.id .. " — " .. (space.likes or 0) .. " likes")
end

get_space

Get detailed information about a specific Space.

Parameters

NameTypeRequiredDescription
space_idstringyesThe Space ID (e.g. "stabilityai/stable-diffusion-3.5")

Example

local space = app.integrations["huggingface"].get_space({
  space_id = "stabilityai/stable-diffusion-3.5"
})

print(space.id)
print(space.sdk .. " SDK")
print(space.runtime.stage)

get_current_user

Get the authenticated user’s profile information.

Parameters

None.

Example

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

print("Name: " .. user.fullname)
print("Username: " .. user.name)
print("Type: " .. user.type)

Multi-Account Usage

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

-- Default account (always works)
app.integrations["huggingface"].list_models({})

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

-- Named accounts
app.integrations["huggingface"].work.list_models({})
app.integrations["huggingface"].research.list_models({})

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

Raw agent markdown
# Hugging Face — Lua API Reference

## list_models

Search and list AI models on the Hugging Face Hub.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `search` | string | no | Search query to filter models |
| `author` | string | no | Filter by organization or user |
| `task` | string | no | Filter by pipeline task (e.g. `"text-generation"`, `"image-classification"`) |
| `tags` | array | no | Filter by tags (e.g. `{"pytorch", "safetensors"}`) |
| `sort` | string | no | Sort order: `"downloads"`, `"likes"`, `"lastModified"`, `"created"` |
| `direction` | string | no | Sort direction: `"asc"` or `"desc"` |
| `limit` | integer | no | Results per page (default: 20, max: 500) |
| `offset` | integer | no | Offset for pagination |

### Common Tasks

`text-generation`, `text2text-generation`, `text-classification`, `token-classification`, `question-answering`, `summarization`, `translation`, `image-classification`, `image-generation`, `automatic-speech-recognition`, `feature-extraction`, `sentence-similarity`

### Examples

```lua
-- Top text-generation models
local result = app.integrations["huggingface"].list_models({
  task = "text-generation",
  sort = "downloads",
  limit = 10
})

for _, model in ipairs(result) do
  print(model.id .. " — " .. model.downloads .. " downloads")
end
```

```lua
-- Search for a specific model
local result = app.integrations["huggingface"].list_models({
  search = "bert-base",
  sort = "downloads",
  limit = 5
})
```

---

## get_model

Get detailed information about a specific model.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model_id` | string | yes | The model ID (e.g. `"meta-llama/Llama-3.3-70B-Instruct"`) |

### Example

```lua
local model = app.integrations["huggingface"].get_model({
  model_id = "meta-llama/Llama-3.3-70B-Instruct"
})

print(model.id)
print(model.pipeline_tag)
print(model.downloads .. " downloads")
print(model.likes .. " likes")
```

---

## list_datasets

Search and list datasets on the Hugging Face Hub.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `search` | string | no | Search query to filter datasets |
| `author` | string | no | Filter by organization or user |
| `tags` | array | no | Filter by tags |
| `sort` | string | no | Sort order: `"downloads"`, `"likes"`, `"lastModified"`, `"created"` |
| `direction` | string | no | Sort direction: `"asc"` or `"desc"` |
| `limit` | integer | no | Results per page (default: 20, max: 500) |
| `offset` | integer | no | Offset for pagination |

### Example

```lua
local datasets = app.integrations["huggingface"].list_datasets({
  search = "sentiment",
  sort = "downloads",
  limit = 10
})

for _, ds in ipairs(datasets) do
  print(ds.id .. " — " .. ds.downloads .. " downloads")
end
```

---

## get_dataset

Get detailed information about a specific dataset.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `dataset_id` | string | yes | The dataset ID (e.g. `"mozilla-foundation/common_voice_17_0"`) |

### Example

```lua
local dataset = app.integrations["huggingface"].get_dataset({
  dataset_id = "imdb"
})

print(dataset.id)
print(dataset.downloads .. " downloads")
print(dataset.likes .. " likes")
```

---

## list_spaces

Search and list Spaces on the Hugging Face Hub.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `search` | string | no | Search query to filter Spaces |
| `author` | string | no | Filter by organization or user |
| `tags` | array | no | Filter by tags |
| `sort` | string | no | Sort order: `"downloads"`, `"likes"`, `"lastModified"`, `"created"` |
| `direction` | string | no | Sort direction: `"asc"` or `"desc"` |
| `limit` | integer | no | Results per page (default: 20, max: 500) |
| `offset` | integer | no | Offset for pagination |

### Example

```lua
local spaces = app.integrations["huggingface"].list_spaces({
  search = "chat",
  sort = "likes",
  limit = 10
})

for _, space in ipairs(spaces) do
  print(space.id .. " — " .. (space.likes or 0) .. " likes")
end
```

---

## get_space

Get detailed information about a specific Space.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `space_id` | string | yes | The Space ID (e.g. `"stabilityai/stable-diffusion-3.5"`) |

### Example

```lua
local space = app.integrations["huggingface"].get_space({
  space_id = "stabilityai/stable-diffusion-3.5"
})

print(space.id)
print(space.sdk .. " SDK")
print(space.runtime.stage)
```

---

## get_current_user

Get the authenticated user's profile information.

### Parameters

None.

### Example

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

print("Name: " .. user.fullname)
print("Username: " .. user.name)
print("Type: " .. user.type)
```

---

## Multi-Account Usage

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

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

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

-- Named accounts
app.integrations["huggingface"].work.list_models({})
app.integrations["huggingface"].research.list_models({})
```

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

Metadata-Derived Lua Example

local result = app.integrations.huggingface.huggingface_list_models({
  search = "example_search",
  author = "example_author",
  task = "example_task",
  tags = "example_tags",
  sort = "example_sort",
  direction = "example_direction",
  limit = 1,
  offset = 1
})
print(result)

Functions

huggingface_list_models

Search and list AI models on the Hugging Face Hub. Filter by text search, author, task (e.g. "text-generation", "image-classification"), tags, and sort by downloads, likes, or recent activity.

Operation
Read read
Full name
huggingface.huggingface_list_models
ParameterTypeRequiredDescription
search string no Search query to filter models by name or description.
author string no Filter by organization or user (e.g. "meta-llama", "openai").
task string no Filter by pipeline task (e.g. "text-generation", "text-classification", "image-classification", "automatic-speech-recognition").
tags array no Filter by tags (e.g. ["pytorch", "safetensors"]).
sort string no Sort order: "downloads", "likes", "lastModified", "created". Defaults to "downloads".
direction string no Sort direction: "asc" or "desc". Defaults to "desc".
limit integer no Number of results per page (default: 20, max: 500).
offset integer no Offset for pagination.

huggingface_get_model

Get detailed information about a specific Hugging Face model, including its card, tags, pipeline tag, library, downloads, likes, and file listing.

Operation
Read read
Full name
huggingface.huggingface_get_model
ParameterTypeRequiredDescription
model_id string yes The model ID (e.g. "meta-llama/Llama-3.3-70B-Instruct", "bert-base-uncased").

huggingface_list_datasets

Search and list datasets on the Hugging Face Hub. Filter by text search, author, tags, and sort by downloads, likes, or recent activity.

Operation
Read read
Full name
huggingface.huggingface_list_datasets
ParameterTypeRequiredDescription
search string no Search query to filter datasets by name or description.
author string no Filter by organization or user (e.g. "HuggingFaceFW", "mozilla-foundation").
tags array no Filter by tags (e.g. ["text-classification", "english"]).
sort string no Sort order: "downloads", "likes", "lastModified", "created". Defaults to "downloads".
direction string no Sort direction: "asc" or "desc". Defaults to "desc".
limit integer no Number of results per page (default: 20, max: 500).
offset integer no Offset for pagination.

huggingface_get_dataset

Get detailed information about a specific Hugging Face dataset, including its card, tags, downloads, likes, and file listing.

Operation
Read read
Full name
huggingface.huggingface_get_dataset
ParameterTypeRequiredDescription
dataset_id string yes The dataset ID (e.g. "mozilla-foundation/common_voice_17_0", "imdb").

huggingface_list_spaces

Search and list Spaces on the Hugging Face Hub. Filter by text search, author, tags, SDK, and sort by downloads, likes, or recent activity.

Operation
Read read
Full name
huggingface.huggingface_list_spaces
ParameterTypeRequiredDescription
search string no Search query to filter Spaces by name or description.
author string no Filter by organization or user (e.g. "gradio", "stabilityai").
tags array no Filter by tags (e.g. ["gradio", "text-generation"]).
sort string no Sort order: "downloads", "likes", "lastModified", "created". Defaults to "downloads".
direction string no Sort direction: "asc" or "desc". Defaults to "desc".
limit integer no Number of results per page (default: 20, max: 500).
offset integer no Offset for pagination.

huggingface_get_space

Get detailed information about a specific Hugging Face Space, including its SDK, hardware, runtime status, and settings.

Operation
Read read
Full name
huggingface.huggingface_get_space
ParameterTypeRequiredDescription
space_id string yes The Space ID (e.g. "stabilityai/stable-diffusion-3.5", "gradio/chatbot").

huggingface_get_current_user

Get the authenticated Hugging Face user's profile information, including name, username, type (user/org), and avatar.

Operation
Read read
Full name
huggingface.huggingface_get_current_user
ParameterTypeRequiredDescription
No parameters.