KosmoKrator

database

Qdrant Lua API for KosmoKrator Agents

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

6 functions 4 read 2 write API key auth

Lua Namespace

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

Qdrant — Lua API Reference

list_collections

List all vector collections in the Qdrant cluster.

Parameters

None.

Example

local result = app.integrations.qdrant.list_collections({})

for _, col in ipairs(result.result.collections) do
  print(col.name)
end

get_collection

Get detailed information about a specific collection.

Parameters

NameTypeRequiredDescription
namestringyesCollection name

Example

local result = app.integrations.qdrant.get_collection({
  name = "documents"
})

print("Points count: " .. result.result.points_count)
print("Vectors count: " .. result.result.vectors_count)

create_collection

Create a new vector collection.

Parameters

NameTypeRequiredDescription
namestringyesName for the new collection
vectorsobjectyesVector configuration, e.g. {size = 1536, distance = "Cosine"}
hnsw_configobjectnoHNSW index settings (e.g. {m = 16, ef_construct = 100})
optimizers_configobjectnoOptimizer settings
quantization_configobjectnoQuantization for memory savings
replication_factorintegernoNumber of replicas per shard
shard_numberintegernoNumber of shards

Distance Options

Cosine, Euclid, Dot

Example

local result = app.integrations.qdrant.create_collection({
  name = "documents",
  vectors = {
    size = 1536,
    distance = "Cosine"
  },
  hnsw_config = {
    m = 16,
    ef_construct = 100
  }
})

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

Search for similar vectors in a collection.

Parameters

NameTypeRequiredDescription
collectionstringyesCollection to search in
vectorarrayyesQuery vector (array of floats)
vector_namestringnoNamed vector to search (multi-vector collections)
filterobjectnoFilter conditions with must, should, must_not clauses
limitintegernoMax results (default: 10)
offsetintegernoPagination offset
with_payloadbooleannoInclude payloads (default: true)
with_vectorsbooleannoInclude vectors (default: false)
score_thresholdnumbernoMinimum similarity score

Filter Syntax

Filters use conditions within must (AND), should (OR), and must_not (NOT) clauses:

{
  "must": [
    {"key": "category", "match": {"value": "technology"}}
  ],
  "must_not": [
    {"key": "status", "match": {"value": "archived"}}
  ]
}

Example

local result = app.integrations.qdrant.search({
  collection = "documents",
  vector = {0.1, 0.2, 0.3, /* ... */},
  limit = 5,
  with_payload = true,
  filter = {
    must = {
      { key = "category", match = { value = "technology" } }
    }
  }
})

for _, point in ipairs(result.result) do
  print("ID: " .. tostring(point.id) .. ", Score: " .. point.score)
  if point.payload then
    print("  Title: " .. (point.payload.title or "N/A"))
  end
end

upsert_points

Insert or update points in a collection.

Parameters

NameTypeRequiredDescription
collectionstringyesTarget collection
pointsarrayyesArray of point objects (see below)
waitbooleannoWait for completion (default: true)
orderingstringnoWrite ordering: "weak" or "strong"

Point Object

Each point requires:

FieldTypeDescription
idinteger or stringUnique point identifier (integer or UUID)
vectorarrayVector data (array of floats)
payloadobjectOptional metadata key-value pairs

Example

local result = app.integrations.qdrant.upsert_points({
  collection = "documents",
  points = {
    {
      id = 1,
      vector = {0.1, 0.2, 0.3, /* ... */},
      payload = {
        title = "Introduction to Vectors",
        category = "technology",
        source = "docs"
      }
    },
    {
      id = 2,
      vector = {0.4, 0.5, 0.6, /* ... */},
      payload = {
        title = "Vector Databases Explained",
        category = "technology",
        source = "blog"
      }
    }
  }
})

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

get_current_user

Get information about the Qdrant cluster and authenticated context.

Parameters

None.

Example

local result = app.integrations.qdrant.get_current_user({})

if result.result then
  print("Cluster status: " .. (result.result.status or "unknown"))
  print("Nodes: " .. #result.result.peer_state)
end

Multi-Account Usage

If you have multiple Qdrant clusters configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.qdrant.list_collections({})

-- Explicit default (portable across setups)
app.integrations.qdrant.default.list_collections({})

-- Named accounts
app.integrations.qdrant.production.list_collections({})
app.integrations.qdrant.staging.list_collections({})

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

Raw agent markdown
# Qdrant — Lua API Reference

## list_collections

List all vector collections in the Qdrant cluster.

### Parameters

None.

### Example

```lua
local result = app.integrations.qdrant.list_collections({})

for _, col in ipairs(result.result.collections) do
  print(col.name)
end
```

---

## get_collection

Get detailed information about a specific collection.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Collection name |

### Example

```lua
local result = app.integrations.qdrant.get_collection({
  name = "documents"
})

print("Points count: " .. result.result.points_count)
print("Vectors count: " .. result.result.vectors_count)
```

---

## create_collection

Create a new vector collection.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Name for the new collection |
| `vectors` | object | yes | Vector configuration, e.g. `{size = 1536, distance = "Cosine"}` |
| `hnsw_config` | object | no | HNSW index settings (e.g. `{m = 16, ef_construct = 100}`) |
| `optimizers_config` | object | no | Optimizer settings |
| `quantization_config` | object | no | Quantization for memory savings |
| `replication_factor` | integer | no | Number of replicas per shard |
| `shard_number` | integer | no | Number of shards |

### Distance Options

`Cosine`, `Euclid`, `Dot`

### Example

```lua
local result = app.integrations.qdrant.create_collection({
  name = "documents",
  vectors = {
    size = 1536,
    distance = "Cosine"
  },
  hnsw_config = {
    m = 16,
    ef_construct = 100
  }
})

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

---

## search

Search for similar vectors in a collection.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection` | string | yes | Collection to search in |
| `vector` | array | yes | Query vector (array of floats) |
| `vector_name` | string | no | Named vector to search (multi-vector collections) |
| `filter` | object | no | Filter conditions with `must`, `should`, `must_not` clauses |
| `limit` | integer | no | Max results (default: 10) |
| `offset` | integer | no | Pagination offset |
| `with_payload` | boolean | no | Include payloads (default: true) |
| `with_vectors` | boolean | no | Include vectors (default: false) |
| `score_threshold` | number | no | Minimum similarity score |

### Filter Syntax

Filters use conditions within `must` (AND), `should` (OR), and `must_not` (NOT) clauses:

```json
{
  "must": [
    {"key": "category", "match": {"value": "technology"}}
  ],
  "must_not": [
    {"key": "status", "match": {"value": "archived"}}
  ]
}
```

### Example

```lua
local result = app.integrations.qdrant.search({
  collection = "documents",
  vector = {0.1, 0.2, 0.3, /* ... */},
  limit = 5,
  with_payload = true,
  filter = {
    must = {
      { key = "category", match = { value = "technology" } }
    }
  }
})

for _, point in ipairs(result.result) do
  print("ID: " .. tostring(point.id) .. ", Score: " .. point.score)
  if point.payload then
    print("  Title: " .. (point.payload.title or "N/A"))
  end
end
```

---

## upsert_points

Insert or update points in a collection.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `collection` | string | yes | Target collection |
| `points` | array | yes | Array of point objects (see below) |
| `wait` | boolean | no | Wait for completion (default: true) |
| `ordering` | string | no | Write ordering: `"weak"` or `"strong"` |

### Point Object

Each point requires:

| Field | Type | Description |
|-------|------|-------------|
| `id` | integer or string | Unique point identifier (integer or UUID) |
| `vector` | array | Vector data (array of floats) |
| `payload` | object | Optional metadata key-value pairs |

### Example

```lua
local result = app.integrations.qdrant.upsert_points({
  collection = "documents",
  points = {
    {
      id = 1,
      vector = {0.1, 0.2, 0.3, /* ... */},
      payload = {
        title = "Introduction to Vectors",
        category = "technology",
        source = "docs"
      }
    },
    {
      id = 2,
      vector = {0.4, 0.5, 0.6, /* ... */},
      payload = {
        title = "Vector Databases Explained",
        category = "technology",
        source = "blog"
      }
    }
  }
})

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

---

## get_current_user

Get information about the Qdrant cluster and authenticated context.

### Parameters

None.

### Example

```lua
local result = app.integrations.qdrant.get_current_user({})

if result.result then
  print("Cluster status: " .. (result.result.status or "unknown"))
  print("Nodes: " .. #result.result.peer_state)
end
```

---

## Multi-Account Usage

If you have multiple Qdrant clusters configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.qdrant.list_collections({})

-- Explicit default (portable across setups)
app.integrations.qdrant.default.list_collections({})

-- Named accounts
app.integrations.qdrant.production.list_collections({})
app.integrations.qdrant.staging.list_collections({})
```

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

Metadata-Derived Lua Example

local result = app.integrations.qdrant.qdrant_list_collections({})
print(result)

Functions

qdrant_list_collections

List all vector collections in the Qdrant cluster. Returns collection names and basic metadata.

Operation
Read read
Full name
qdrant.qdrant_list_collections
ParameterTypeRequiredDescription
No parameters.

qdrant_get_collection

Get detailed information about a specific Qdrant collection, including vector configuration, index status, and point count.

Operation
Read read
Full name
qdrant.qdrant_get_collection
ParameterTypeRequiredDescription
name string yes The name of the collection to retrieve.

qdrant_create_collection

Create a new vector collection in Qdrant. You must specify the vector configuration (size, distance metric). Optionally provide HNSW, quantization, and optimization settings.

Operation
Write write
Full name
qdrant.qdrant_create_collection
ParameterTypeRequiredDescription
name string yes Name for the new collection.
vectors object yes Vector configuration. Example: {"size": 1536, "distance": "Cosine"}. Distance options: Cosine, Euclid, Dot.
hnsw_config object no HNSW index configuration (e.g., {"m": 16, "ef_construct": 100}).
optimizers_config object no Optimizer configuration (e.g., {"indexing_threshold": 20000}).
quantization_config object no Quantization configuration for memory savings (scalar or product).
replication_factor integer no Number of replicas for each shard (default: 1).
shard_number integer no Number of shards for the collection (default: 1 for single-node).

qdrant_upsert_points

Insert or update points (vectors with optional payloads) in a Qdrant collection. Each point requires an ID and a vector. Payloads are optional metadata.

Operation
Write write
Full name
qdrant.qdrant_upsert_points
ParameterTypeRequiredDescription
collection string yes The collection name to upsert points into.
points array yes Array of point objects. Each point must have "id" (integer or UUID string), "vector" (array of floats), and optionally "payload" (object with metadata).
wait boolean no Whether to wait for the operation to complete (default: true).
ordering string no Write ordering guarantee: "weak" or "strong" (default: "weak").

qdrant_get_current_user

Get information about the Qdrant cluster, including cluster status, node information, and the authenticated user context.

Operation
Read read
Full name
qdrant.qdrant_get_current_user
ParameterTypeRequiredDescription
No parameters.