KosmoKrator

analytics

Langfuse Lua API for KosmoKrator Agents

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

Lua Namespace

Agents call this integration through app.integrations.langfuse.*. Use lua_read_doc("integrations.langfuse") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic Langfuse workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.langfuse.get_health({}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("langfuse"))' --json
kosmo integrations:lua --eval 'print(docs.read("langfuse.get_health"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local langfuse = app.integrations.langfuse
local result = langfuse.get_health({})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.langfuse, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.langfuse.default.* or app.integrations.langfuse.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Langfuse, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

Langfuse

Namespace: langfuse

Langfuse is an LLM engineering and observability platform. This integration uses the Langfuse Public API with Basic Auth:

  • username: project public key
  • password: project secret key

The configured URL can be a Langfuse host such as https://cloud.langfuse.com or a full /api/public base URL for US, EU, HIPAA, or self-hosted deployments.

Traces And Observability

Use langfuse_ingest_batch to submit tracing events. The body object is sent directly to POST /api/public/ingestion, so it must match the official Langfuse ingestion schema.

langfuse.ingest_batch({
  body = {
    batch = {
      {
        id = "event-1",
        type = "trace-create",
        timestamp = "2026-01-01T00:00:00.000Z",
        body = {
          id = "trace-1",
          name = "support-agent",
          userId = "user-123"
        }
      }
    }
  }
})

Query stored observability data with:

  • langfuse_list_traces
  • langfuse_get_trace
  • langfuse_list_observations
  • langfuse_get_observation
  • langfuse_list_sessions
  • langfuse_get_session

Delete operations such as langfuse_delete_trace are destructive.

Scores And Metrics

Use langfuse_create_score for online evals, user feedback, moderation checks, or session-level quality signals. The body is passed to the official score creation endpoint.

langfuse_list_scores and langfuse_get_score use the v2 score read endpoints. langfuse_delete_score uses the public score delete endpoint.

Use langfuse_metrics for the v2 metrics API. The body is sent directly to the official metrics schema.

Datasets And Prompt Management

Datasets:

  • langfuse_list_datasets
  • langfuse_create_dataset
  • langfuse_get_dataset
  • langfuse_create_dataset_item
  • langfuse_list_dataset_items
  • langfuse_get_dataset_item
  • langfuse_delete_dataset_item
  • langfuse_create_dataset_run_item
  • langfuse_list_dataset_run_items

Prompts:

  • langfuse_list_prompts
  • langfuse_create_prompt
  • langfuse_get_prompt
  • langfuse_delete_prompt
  • langfuse_update_prompt_version

For complex create/update operations, pass a body object matching the current Langfuse API reference. This avoids stale local field assumptions as Langfuse evolves its schemas.

Comments And Model Definitions

Comments:

  • langfuse_create_comment
  • langfuse_list_comments
  • langfuse_get_comment

Model definitions:

  • langfuse_list_models
  • langfuse_create_model
  • langfuse_get_model
  • langfuse_delete_model

Coverage Notes

This package covers the project-level surfaces agents most often need: health, ingestion, traces, observations, scores, sessions, datasets, dataset items, dataset run items, prompts, comments, metrics, and model definitions.

The Langfuse OpenAPI spec also includes organization administration, SCIM, blob storage exports, annotation queues, LLM connections, media upload URLs, OpenTelemetry export, and unstable evaluator/evaluation-rule endpoints. Those should be added as endpoint-specific tools before calling this integration complete against the full Langfuse API.

Raw agent markdown
# Langfuse

Namespace: `langfuse`

Langfuse is an LLM engineering and observability platform. This integration uses the Langfuse Public API with Basic Auth:

- username: project public key
- password: project secret key

The configured URL can be a Langfuse host such as `https://cloud.langfuse.com` or a full `/api/public` base URL for US, EU, HIPAA, or self-hosted deployments.

## Traces And Observability

Use `langfuse_ingest_batch` to submit tracing events. The `body` object is sent directly to `POST /api/public/ingestion`, so it must match the official Langfuse ingestion schema.

```lua
langfuse.ingest_batch({
  body = {
    batch = {
      {
        id = "event-1",
        type = "trace-create",
        timestamp = "2026-01-01T00:00:00.000Z",
        body = {
          id = "trace-1",
          name = "support-agent",
          userId = "user-123"
        }
      }
    }
  }
})
```

Query stored observability data with:

- `langfuse_list_traces`
- `langfuse_get_trace`
- `langfuse_list_observations`
- `langfuse_get_observation`
- `langfuse_list_sessions`
- `langfuse_get_session`

Delete operations such as `langfuse_delete_trace` are destructive.

## Scores And Metrics

Use `langfuse_create_score` for online evals, user feedback, moderation checks, or session-level quality signals. The body is passed to the official score creation endpoint.

`langfuse_list_scores` and `langfuse_get_score` use the v2 score read endpoints. `langfuse_delete_score` uses the public score delete endpoint.

Use `langfuse_metrics` for the v2 metrics API. The body is sent directly to the official metrics schema.

## Datasets And Prompt Management

Datasets:

- `langfuse_list_datasets`
- `langfuse_create_dataset`
- `langfuse_get_dataset`
- `langfuse_create_dataset_item`
- `langfuse_list_dataset_items`
- `langfuse_get_dataset_item`
- `langfuse_delete_dataset_item`
- `langfuse_create_dataset_run_item`
- `langfuse_list_dataset_run_items`

Prompts:

- `langfuse_list_prompts`
- `langfuse_create_prompt`
- `langfuse_get_prompt`
- `langfuse_delete_prompt`
- `langfuse_update_prompt_version`

For complex create/update operations, pass a `body` object matching the current Langfuse API reference. This avoids stale local field assumptions as Langfuse evolves its schemas.

## Comments And Model Definitions

Comments:

- `langfuse_create_comment`
- `langfuse_list_comments`
- `langfuse_get_comment`

Model definitions:

- `langfuse_list_models`
- `langfuse_create_model`
- `langfuse_get_model`
- `langfuse_delete_model`

## Coverage Notes

This package covers the project-level surfaces agents most often need: health, ingestion, traces, observations, scores, sessions, datasets, dataset items, dataset run items, prompts, comments, metrics, and model definitions.

The Langfuse OpenAPI spec also includes organization administration, SCIM, blob storage exports, annotation queues, LLM connections, media upload URLs, OpenTelemetry export, and unstable evaluator/evaluation-rule endpoints. Those should be added as endpoint-specific tools before calling this integration complete against the full Langfuse API.
Metadata-derived Lua example
local result = app.integrations.langfuse.get_health({})
print(result)

Functions

get_health Read

Check Langfuse Public API health.

Lua path
app.integrations.langfuse.get_health
Full name
langfuse.langfuse_get_health
ParameterTypeRequiredDescription
No parameters.
ingest_batch Write

Submit Langfuse ingestion batch events.

Lua path
app.integrations.langfuse.ingest_batch
Full name
langfuse.langfuse_ingest_batch
ParameterTypeRequiredDescription
No parameters.
list_traces Read

List Langfuse traces with filters and pagination.

Lua path
app.integrations.langfuse.list_traces
Full name
langfuse.langfuse_list_traces
ParameterTypeRequiredDescription
No parameters.
get_trace Read

Retrieve a Langfuse trace by ID.

Lua path
app.integrations.langfuse.get_trace
Full name
langfuse.langfuse_get_trace
ParameterTypeRequiredDescription
No parameters.
delete_trace Write

Delete a Langfuse trace by ID.

Lua path
app.integrations.langfuse.delete_trace
Full name
langfuse.langfuse_delete_trace
ParameterTypeRequiredDescription
No parameters.
list_observations Read

List Langfuse observations with v2 filters.

Lua path
app.integrations.langfuse.list_observations
Full name
langfuse.langfuse_list_observations
ParameterTypeRequiredDescription
No parameters.
get_observation Read

Retrieve a Langfuse observation by ID.

Lua path
app.integrations.langfuse.get_observation
Full name
langfuse.langfuse_get_observation
ParameterTypeRequiredDescription
No parameters.
create_score Write

Create a trace, observation, session, or dataset score.

Lua path
app.integrations.langfuse.create_score
Full name
langfuse.langfuse_create_score
ParameterTypeRequiredDescription
No parameters.
list_scores Read

List Langfuse v2 scores with filters.

Lua path
app.integrations.langfuse.list_scores
Full name
langfuse.langfuse_list_scores
ParameterTypeRequiredDescription
No parameters.
get_score Read

Retrieve a Langfuse score by ID.

Lua path
app.integrations.langfuse.get_score
Full name
langfuse.langfuse_get_score
ParameterTypeRequiredDescription
No parameters.
delete_score Write

Delete a Langfuse score by ID.

Lua path
app.integrations.langfuse.delete_score
Full name
langfuse.langfuse_delete_score
ParameterTypeRequiredDescription
No parameters.
list_sessions Read

List Langfuse sessions.

Lua path
app.integrations.langfuse.list_sessions
Full name
langfuse.langfuse_list_sessions
ParameterTypeRequiredDescription
No parameters.
get_session Read

Retrieve a Langfuse session by ID.

Lua path
app.integrations.langfuse.get_session
Full name
langfuse.langfuse_get_session
ParameterTypeRequiredDescription
No parameters.
list_datasets Read

List Langfuse v2 datasets.

Lua path
app.integrations.langfuse.list_datasets
Full name
langfuse.langfuse_list_datasets
ParameterTypeRequiredDescription
No parameters.
create_dataset Write

Create a Langfuse v2 dataset.

Lua path
app.integrations.langfuse.create_dataset
Full name
langfuse.langfuse_create_dataset
ParameterTypeRequiredDescription
No parameters.
get_dataset Read

Retrieve a Langfuse dataset by name.

Lua path
app.integrations.langfuse.get_dataset
Full name
langfuse.langfuse_get_dataset
ParameterTypeRequiredDescription
No parameters.
create_dataset_item Write

Create a Langfuse dataset item.

Lua path
app.integrations.langfuse.create_dataset_item
Full name
langfuse.langfuse_create_dataset_item
ParameterTypeRequiredDescription
No parameters.
list_dataset_items Read

List Langfuse dataset items.

Lua path
app.integrations.langfuse.list_dataset_items
Full name
langfuse.langfuse_list_dataset_items
ParameterTypeRequiredDescription
No parameters.
get_dataset_item Read

Retrieve a Langfuse dataset item by ID.

Lua path
app.integrations.langfuse.get_dataset_item
Full name
langfuse.langfuse_get_dataset_item
ParameterTypeRequiredDescription
No parameters.
delete_dataset_item Write

Delete a Langfuse dataset item by ID.

Lua path
app.integrations.langfuse.delete_dataset_item
Full name
langfuse.langfuse_delete_dataset_item
ParameterTypeRequiredDescription
No parameters.
create_dataset_run_item Write

Create a Langfuse dataset run item.

Lua path
app.integrations.langfuse.create_dataset_run_item
Full name
langfuse.langfuse_create_dataset_run_item
ParameterTypeRequiredDescription
No parameters.
list_dataset_run_items Read

List Langfuse dataset run items.

Lua path
app.integrations.langfuse.list_dataset_run_items
Full name
langfuse.langfuse_list_dataset_run_items
ParameterTypeRequiredDescription
No parameters.
list_prompts Read

List Langfuse v2 prompts.

Lua path
app.integrations.langfuse.list_prompts
Full name
langfuse.langfuse_list_prompts
ParameterTypeRequiredDescription
No parameters.
create_prompt Write

Create a Langfuse prompt version.

Lua path
app.integrations.langfuse.create_prompt
Full name
langfuse.langfuse_create_prompt
ParameterTypeRequiredDescription
No parameters.
get_prompt Read

Retrieve a Langfuse prompt by name.

Lua path
app.integrations.langfuse.get_prompt
Full name
langfuse.langfuse_get_prompt
ParameterTypeRequiredDescription
No parameters.
delete_prompt Write

Delete a Langfuse prompt by name.

Lua path
app.integrations.langfuse.delete_prompt
Full name
langfuse.langfuse_delete_prompt
ParameterTypeRequiredDescription
No parameters.
update_prompt_version Write

Update labels or config for a prompt version.

Lua path
app.integrations.langfuse.update_prompt_version
Full name
langfuse.langfuse_update_prompt_version
ParameterTypeRequiredDescription
No parameters.
create_comment Write

Create a Langfuse comment.

Lua path
app.integrations.langfuse.create_comment
Full name
langfuse.langfuse_create_comment
ParameterTypeRequiredDescription
No parameters.
list_comments Read

List Langfuse comments.

Lua path
app.integrations.langfuse.list_comments
Full name
langfuse.langfuse_list_comments
ParameterTypeRequiredDescription
No parameters.
get_comment Read

Retrieve a Langfuse comment by ID.

Lua path
app.integrations.langfuse.get_comment
Full name
langfuse.langfuse_get_comment
ParameterTypeRequiredDescription
No parameters.
metrics Read

Query Langfuse v2 metrics.

Lua path
app.integrations.langfuse.metrics
Full name
langfuse.langfuse_metrics
ParameterTypeRequiredDescription
No parameters.
list_models Read

List Langfuse model definitions.

Lua path
app.integrations.langfuse.list_models
Full name
langfuse.langfuse_list_models
ParameterTypeRequiredDescription
No parameters.
create_model Write

Create a Langfuse model definition.

Lua path
app.integrations.langfuse.create_model
Full name
langfuse.langfuse_create_model
ParameterTypeRequiredDescription
No parameters.
get_model Read

Retrieve a Langfuse model definition by ID.

Lua path
app.integrations.langfuse.get_model
Full name
langfuse.langfuse_get_model
ParameterTypeRequiredDescription
No parameters.
delete_model Write

Delete a Langfuse model definition by ID.

Lua path
app.integrations.langfuse.delete_model
Full name
langfuse.langfuse_delete_model
ParameterTypeRequiredDescription
No parameters.