KosmoKrator

data

Milvus Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write API key auth

Lua Namespace

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

Milvus — Lua API Reference

list_collections

List all vector collections in Milvus.

Parameters

NameTypeRequiredDescription
limitintegernoMax collections to return (default: 100)
offsetintegernoNumber of collections to skip for pagination

Example

local result = app.integrations.milvus.list_collections({
  limit = 50
})

for _, col in ipairs(result.data) do
  print(col.collectionName)
end

get_collection

Get details of a specific collection by name.

Parameters

NameTypeRequiredDescription
collection_namestringyesThe name of the collection

Example

local result = app.integrations.milvus.get_collection({
  collection_name = "knowledge_base"
})

print("Name: " .. result.collectionName)
print("Description: " .. (result.description or "none"))

create_collection

Create a new vector collection.

Parameters

NameTypeRequiredDescription
namestringyesName of the collection
dimensionintegeryesDimension of embedding vectors
descriptionstringnoOptional description
paramsobjectnoOptional parameters (index type, metric type, etc.)

Example

local result = app.integrations.milvus.create_collection({
  name = "knowledge_base",
  dimension = 1536,
  description = "Product documentation embeddings"
})

print("Created collection: " .. result.collectionName)

Example with custom index parameters

local result = app.integrations.milvus.create_collection({
  name = "image_vectors",
  dimension = 512,
  description = "Image feature vectors",
  params = {
    indexType = "IVF_FLAT",
    metricType = "L2",
    nlist = 1024
  }
})

insert_documents

Insert documents with embedding vectors into a collection.

Parameters

NameTypeRequiredDescription
collection_namestringyesThe name of the collection
dataarrayyesArray of document objects with a vector field and optional scalar fields

Each document object should contain:

  • vector (array of floats): The embedding vector
  • id (string/integer, optional): Custom document ID
  • Additional scalar fields as defined in the collection schema

Example

local result = app.integrations.milvus.insert_documents({
  collection_name = "knowledge_base",
  data = {
    {
      id = "doc1",
      vector = { 0.1, 0.2, 0.3, 0.4 },
      text = "Milvus is a high-performance vector database.",
      source = "readme"
    },
    {
      id = "doc2",
      vector = { 0.5, 0.6, 0.7, 0.8 },
      text = "It supports billion-scale vector search.",
      source = "docs"
    }
  }
})

print("Inserted " .. tostring(result.insertCount) .. " documents")

search_documents

Search for similar documents using a query vector.

Parameters

NameTypeRequiredDescription
collection_namestringyesThe name of the collection to search
vectorarrayyesThe query embedding vector (array of floats)
limitintegernoNumber of results to return (default: 10)
output_fieldsarraynoFields to include in response, e.g. {"id", "text"}
filterstringnoFilter expression, e.g. 'source == "docs"'

Example

local result = app.integrations.milvus.search_documents({
  collection_name = "knowledge_base",
  vector = { 0.1, 0.2, 0.3, 0.4 },
  limit = 5,
  output_fields = { "id", "text", "source" }
})

for i, match in ipairs(result.data) do
  print(i .. ": " .. match.text .. " (distance: " .. tostring(match.distance) .. ")")
end

Example with filter

local result = app.integrations.milvus.search_documents({
  collection_name = "knowledge_base",
  vector = { 0.1, 0.2, 0.3, 0.4 },
  limit = 3,
  filter = 'source == "docs"',
  output_fields = { "id", "text" }
})

get_collection_stats

Get statistics for a collection including row count.

Parameters

NameTypeRequiredDescription
collection_namestringyesThe name of the collection

Example

local result = app.integrations.milvus.get_collection_stats({
  collection_name = "knowledge_base"
})

print("Row count: " .. tostring(result.rowCount))

get_health

Check the health status of the Milvus server.

Parameters

None.

Example

local result = app.integrations.milvus.get_health({})

print("Status: " .. (result.status or "unknown"))

Multi-Account Usage

If you have multiple Milvus instances configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.milvus.function_name({...})

-- Explicit default (portable across setups)
app.integrations.milvus.default.function_name({...})

-- Named accounts
app.integrations.milvus.production.function_name({...})
app.integrations.milvus.staging.function_name({...})

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

Raw agent markdown
# Milvus — Lua API Reference

## list_collections

List all vector collections in Milvus.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `limit` | integer | no | Max collections to return (default: 100) |
| `offset` | integer | no | Number of collections to skip for pagination |

### Example

```lua
local result = app.integrations.milvus.list_collections({
  limit = 50
})

for _, col in ipairs(result.data) do
  print(col.collectionName)
end
```

---

## get_collection

Get details of a specific collection by name.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection_name` | string | yes | The name of the collection |

### Example

```lua
local result = app.integrations.milvus.get_collection({
  collection_name = "knowledge_base"
})

print("Name: " .. result.collectionName)
print("Description: " .. (result.description or "none"))
```

---

## create_collection

Create a new vector collection.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Name of the collection |
| `dimension` | integer | yes | Dimension of embedding vectors |
| `description` | string | no | Optional description |
| `params` | object | no | Optional parameters (index type, metric type, etc.) |

### Example

```lua
local result = app.integrations.milvus.create_collection({
  name = "knowledge_base",
  dimension = 1536,
  description = "Product documentation embeddings"
})

print("Created collection: " .. result.collectionName)
```

### Example with custom index parameters

```lua
local result = app.integrations.milvus.create_collection({
  name = "image_vectors",
  dimension = 512,
  description = "Image feature vectors",
  params = {
    indexType = "IVF_FLAT",
    metricType = "L2",
    nlist = 1024
  }
})
```

---

## insert_documents

Insert documents with embedding vectors into a collection.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection_name` | string | yes | The name of the collection |
| `data` | array | yes | Array of document objects with a `vector` field and optional scalar fields |

Each document object should contain:
- `vector` (array of floats): The embedding vector
- `id` (string/integer, optional): Custom document ID
- Additional scalar fields as defined in the collection schema

### Example

```lua
local result = app.integrations.milvus.insert_documents({
  collection_name = "knowledge_base",
  data = {
    {
      id = "doc1",
      vector = { 0.1, 0.2, 0.3, 0.4 },
      text = "Milvus is a high-performance vector database.",
      source = "readme"
    },
    {
      id = "doc2",
      vector = { 0.5, 0.6, 0.7, 0.8 },
      text = "It supports billion-scale vector search.",
      source = "docs"
    }
  }
})

print("Inserted " .. tostring(result.insertCount) .. " documents")
```

---

## search_documents

Search for similar documents using a query vector.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection_name` | string | yes | The name of the collection to search |
| `vector` | array | yes | The query embedding vector (array of floats) |
| `limit` | integer | no | Number of results to return (default: 10) |
| `output_fields` | array | no | Fields to include in response, e.g. `{"id", "text"}` |
| `filter` | string | no | Filter expression, e.g. `'source == "docs"'` |

### Example

```lua
local result = app.integrations.milvus.search_documents({
  collection_name = "knowledge_base",
  vector = { 0.1, 0.2, 0.3, 0.4 },
  limit = 5,
  output_fields = { "id", "text", "source" }
})

for i, match in ipairs(result.data) do
  print(i .. ": " .. match.text .. " (distance: " .. tostring(match.distance) .. ")")
end
```

### Example with filter

```lua
local result = app.integrations.milvus.search_documents({
  collection_name = "knowledge_base",
  vector = { 0.1, 0.2, 0.3, 0.4 },
  limit = 3,
  filter = 'source == "docs"',
  output_fields = { "id", "text" }
})
```

---

## get_collection_stats

Get statistics for a collection including row count.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection_name` | string | yes | The name of the collection |

### Example

```lua
local result = app.integrations.milvus.get_collection_stats({
  collection_name = "knowledge_base"
})

print("Row count: " .. tostring(result.rowCount))
```

---

## get_health

Check the health status of the Milvus server.

### Parameters

None.

### Example

```lua
local result = app.integrations.milvus.get_health({})

print("Status: " .. (result.status or "unknown"))
```

---

## Multi-Account Usage

If you have multiple Milvus instances configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.milvus.function_name({...})

-- Explicit default (portable across setups)
app.integrations.milvus.default.function_name({...})

-- Named accounts
app.integrations.milvus.production.function_name({...})
app.integrations.milvus.staging.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.milvus.milvus_list_collections({
  limit = 1,
  offset = 1
})
print(result)

Functions

milvus_list_collections

List all vector collections in Milvus. Returns collection names and details that can be used for further operations.

Operation
Read read
Full name
milvus.milvus_list_collections
ParameterTypeRequiredDescription
limit integer no Maximum number of collections to return (default: 100).
offset integer no Number of collections to skip for pagination.

milvus_get_collection

Get details of a specific Milvus collection by its name, including schema and description.

Operation
Read read
Full name
milvus.milvus_get_collection
ParameterTypeRequiredDescription
collection_name string yes The name of the collection.

milvus_create_collection

Create a new vector collection in Milvus. A collection requires a name and the embedding dimension size.

Operation
Write write
Full name
milvus.milvus_create_collection
ParameterTypeRequiredDescription
name string yes The name of the collection to create.
dimension integer yes The dimension of the embedding vectors to be stored in this collection.
description string no An optional description of the collection.
params object no Optional collection parameters such as index type and metric type (JSON object).

milvus_insert_documents

Insert documents with embedding vectors into a Milvus collection. Each document requires a vector and an optional ID.

Operation
Write write
Full name
milvus.milvus_insert_documents
ParameterTypeRequiredDescription
collection_name string yes The name of the collection to insert into.
data array yes Array of document objects. Each object should contain a "vector" field (array of floats) and optional "id", "color", or other scalar fields.

milvus_search_documents

Search for similar documents in a Milvus collection using a query vector. Returns the most similar documents ranked by distance or similarity.

Operation
Read read
Full name
milvus.milvus_search_documents
ParameterTypeRequiredDescription
collection_name string yes The name of the collection to search.
vector array yes The query embedding vector (array of floats).
limit integer no Maximum number of results to return (default: 10).
output_fields array no Fields to include in the response, e.g. ["id", "color", "text"].
filter string no Filter expression for scalar fields, e.g. 'color == "red"'.

milvus_get_collection_stats

Get statistics for a Milvus collection, including row count and index information.

Operation
Read read
Full name
milvus.milvus_get_collection_stats
ParameterTypeRequiredDescription
collection_name string yes The name of the collection.

milvus_get_health

Check the health status of the Milvus vector database server. Returns health and version information.

Operation
Read read
Full name
milvus.milvus_get_health
ParameterTypeRequiredDescription
No parameters.