KosmoKrator

ai

Hugging Face CLI for AI Agents

Use the Hugging Face CLI from KosmoKrator to call Hugging Face tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

6 functions 5 read 1 write Bearer token auth

Hugging Face CLI Setup

Hugging Face can be configured headlessly with `kosmokrator integrations:configure hugging-face`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure hugging-face --set access_token="$HUGGING_FACE_ACCESS_TOKEN" --enable --read allow --write ask --json
kosmokrator integrations:doctor hugging-face --json
kosmokrator integrations:status --json

Credentials

Authentication type: Bearer token bearer_token. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
access_token HUGGING_FACE_ACCESS_TOKEN Secret secret yes Access Token
url HUGGING_FACE_URL URL url no API Base URL

Call Hugging Face Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

kosmo integrations:call hugging-face.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
}' --json

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations:hugging-face 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
}' --json

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities before choosing a function.

kosmo integrations:docs hugging-face --json
kosmo integrations:docs hugging-face.huggingface_list_models --json
kosmo integrations:schema hugging-face.huggingface_list_models --json
kosmo integrations:search "Hugging Face" --json
kosmo integrations:list --json

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to Hugging Face.

hugging-face.huggingface_list_models

Read read

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.

Parameters
search, author, task, tags, sort, direction, limit, offset

Generic CLI call

kosmo integrations:call hugging-face.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}' --json

Provider shortcut

kosmo integrations:hugging-face 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}' --json

hugging-face.huggingface_get_model

Read read

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

Parameters
model_id

Generic CLI call

kosmo integrations:call hugging-face.huggingface_get_model '{"model_id":"example_model_id"}' --json

Provider shortcut

kosmo integrations:hugging-face huggingface_get_model '{"model_id":"example_model_id"}' --json

hugging-face.huggingface_list_datasets

Read read

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

Parameters
search, author, tags, sort, direction, limit, offset

Generic CLI call

kosmo integrations:call hugging-face.huggingface_list_datasets '{"search":"example_search","author":"example_author","tags":"example_tags","sort":"example_sort","direction":"example_direction","limit":1,"offset":1}' --json

Provider shortcut

kosmo integrations:hugging-face huggingface_list_datasets '{"search":"example_search","author":"example_author","tags":"example_tags","sort":"example_sort","direction":"example_direction","limit":1,"offset":1}' --json

hugging-face.huggingface_inference

Write write

Run inference on a Hugging Face model via the serverless Inference API. Supports text generation, summarization, translation, classification, image analysis, and more. The payload structure depends on the model's task — refer to the Hugging Face Inference API docs for model-specific formats.

Parameters
model_id, inputs, parameters, data

Generic CLI call

kosmo integrations:call hugging-face.huggingface_inference '{"model_id":"example_model_id","inputs":"example_inputs","parameters":"example_parameters","data":"example_data"}' --json

Provider shortcut

kosmo integrations:hugging-face huggingface_inference '{"model_id":"example_model_id","inputs":"example_inputs","parameters":"example_parameters","data":"example_data"}' --json

hugging-face.huggingface_list_spaces

Read read

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

Parameters
search, author, tags, sort, direction, limit, offset

Generic CLI call

kosmo integrations:call hugging-face.huggingface_list_spaces '{"search":"example_search","author":"example_author","tags":"example_tags","sort":"example_sort","direction":"example_direction","limit":1,"offset":1}' --json

Provider shortcut

kosmo integrations:hugging-face huggingface_list_spaces '{"search":"example_search","author":"example_author","tags":"example_tags","sort":"example_sort","direction":"example_direction","limit":1,"offset":1}' --json

hugging-face.huggingface_get_current_user

Read read

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

Parameters
none

Generic CLI call

kosmo integrations:call hugging-face.huggingface_get_current_user '{}' --json

Provider shortcut

kosmo integrations:hugging-face huggingface_get_current_user '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

hugging-face.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
Schema command
kosmo integrations:schema hugging-face.huggingface_list_models --json
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.

hugging-face.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
Schema command
kosmo integrations:schema hugging-face.huggingface_get_model --json
ParameterTypeRequiredDescription
model_id string yes The model ID (e.g. "meta-llama/Llama-3.3-70B-Instruct", "bert-base-uncased").

hugging-face.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
Schema command
kosmo integrations:schema hugging-face.huggingface_list_datasets --json
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.

hugging-face.huggingface_inference

Run inference on a Hugging Face model via the serverless Inference API. Supports text generation, summarization, translation, classification, image analysis, and more. The payload structure depends on the model's task — refer to the Hugging Face Inference API docs for model-specific formats.

Operation
Write write
Schema command
kosmo integrations:schema hugging-face.huggingface_inference --json
ParameterTypeRequiredDescription
model_id string yes The model ID to run inference on (e.g. "meta-llama/Llama-3.3-70B-Instruct", "facebook/bart-large-cnn").
inputs string no The input text or data for the model. For text tasks, this is the prompt or text to process.
parameters object no Model-specific parameters (e.g. {"max_new_tokens": 256, "temperature": 0.7, "top_p": 0.95} for text generation).
data string no Base64-encoded data for image/audio tasks. Use this instead of "inputs" for non-text models.

hugging-face.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
Schema command
kosmo integrations:schema hugging-face.huggingface_list_spaces --json
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.

hugging-face.huggingface_get_current_user

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

Operation
Read read
Schema command
kosmo integrations:schema hugging-face.huggingface_get_current_user --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.