data
Milvus Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Milvus KosmoKrator integration.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.
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
Milvus workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.milvus.list_collections({limit = 1, offset = 1}))' --json kosmo integrations:lua --eval 'print(docs.read("milvus"))' --json
kosmo integrations:lua --eval 'print(docs.read("milvus.list_collections"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local milvus = app.integrations.milvus
local result = milvus.list_collections({limit = 1, offset = 1})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.milvus, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.milvus.default.* or app.integrations.milvus.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Milvus, use the narrower 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.
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
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
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
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
| 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 vectorid(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
| 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
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
| Name | Type | Required | Description |
|---|---|---|---|
collection_name | string | yes | The 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. local result = app.integrations.milvus.list_collections({limit = 1, offset = 1})
print(result) Functions
list_collections Read
List all vector collections in Milvus. Returns collection names and details that can be used for further operations.
- Lua path
app.integrations.milvus.list_collections- Full name
milvus.milvus_list_collections
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of collections to return (default: 100). |
offset | integer | no | Number of collections to skip for pagination. |
get_collection Read
Get details of a specific Milvus collection by its name, including schema and description.
- Lua path
app.integrations.milvus.get_collection- Full name
milvus.milvus_get_collection
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_name | string | yes | The name of the collection. |
create_collection Write
Create a new vector collection in Milvus. A collection requires a name and the embedding dimension size.
- Lua path
app.integrations.milvus.create_collection- Full name
milvus.milvus_create_collection
| Parameter | Type | Required | Description |
|---|---|---|---|
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). |
insert_documents Write
Insert documents with embedding vectors into a Milvus collection. Each document requires a vector and an optional ID.
- Lua path
app.integrations.milvus.insert_documents- Full name
milvus.milvus_insert_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
search_documents Read
Search for similar documents in a Milvus collection using a query vector. Returns the most similar documents ranked by distance or similarity.
- Lua path
app.integrations.milvus.search_documents- Full name
milvus.milvus_search_documents
| Parameter | 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 | 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"'. |
get_collection_stats Read
Get statistics for a Milvus collection, including row count and index information.
- Lua path
app.integrations.milvus.get_collection_stats- Full name
milvus.milvus_get_collection_stats
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_name | string | yes | The name of the collection. |
get_health Read
Check the health status of the Milvus vector database server. Returns health and version information.
- Lua path
app.integrations.milvus.get_health- Full name
milvus.milvus_get_health
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||