data
Chroma Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Chroma KosmoKrator integration.Lua Namespace
Agents call this integration through app.integrations.chroma.*.
Use lua_read_doc("integrations.chroma") 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
Chroma workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.chroma.get_health({}))' --json kosmo integrations:lua --eval 'print(docs.read("chroma"))' --json
kosmo integrations:lua --eval 'print(docs.read("chroma.get_health"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local chroma = app.integrations.chroma
local result = chroma.get_health({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.chroma, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.chroma.default.* or app.integrations.chroma.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Chroma, 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.
Chroma Lua API Reference
Namespace: app.integrations.chroma
This package targets the official Chroma REST API v2. Configure the Chroma server origin, tenant, database, and API token. The service sends the token as x-chroma-token and builds paths as:
/api/v2/tenants/{tenant}/databases/{database}/...
System
local health = app.integrations.chroma.get_health({})
print(health["nanosecond heartbeat"])
Collections
local collections = app.integrations.chroma.list_collections({
limit = 50,
offset = 0
})
local count = app.integrations.chroma.count_collections({})
Collection tools:
list_collections({ limit, offset })count_collections({})get_collection({ collection_id })create_collection({ name, metadata, configuration })update_collection({ collection_id, new_name, metadata, configuration })delete_collection({ collection_id })
collection_id may be a collection UUID or name when the configured Chroma deployment accepts names in that path.
Add And Upsert Records
Chroma record payloads are column-oriented. Matching array positions belong to the same record.
local added = app.integrations.chroma.add_documents({
collection_id = "knowledge_base",
ids = { "doc1", "doc2" },
documents = {
"Chroma stores embeddings.",
"Chroma supports metadata filters."
},
metadatas = {
{ source = "docs" },
{ source = "docs" }
}
})
Use upsert_documents to create missing records or update existing ones:
local upserted = app.integrations.chroma.upsert_documents({
collection_id = "knowledge_base",
ids = { "vec1" },
embeddings = {
{ 0.1, 0.2, 0.3 }
},
documents = { "A record with a provided embedding" }
})
Query And Get
Use query_documents for nearest-neighbor search and get_document for non-ranked retrieval by IDs or filters.
local result = app.integrations.chroma.query_documents({
collection_id = "knowledge_base",
query_embeddings = {
{ 0.1, 0.2, 0.3 }
},
n_results = 5,
include = { "documents", "metadatas", "distances" }
})
local records = app.integrations.chroma.get_document({
collection_id = "knowledge_base",
ids = { "doc1", "doc2" },
include = { "documents", "metadatas" }
})
Filter fields such as where and where_document are passed to Chroma as JSON objects.
Update, Delete, And Count Records
local updated = app.integrations.chroma.update_documents({
collection_id = "knowledge_base",
ids = { "doc1" },
documents = { "Updated text" },
metadatas = { { source = "manual" } }
})
local deleted = app.integrations.chroma.delete_documents({
collection_id = "knowledge_base",
ids = { "doc2" }
})
local total = app.integrations.chroma.count_documents({
collection_id = "knowledge_base"
})
Record tools:
add_documentsupdate_documentsupsert_documentsdelete_documentscount_documentsquery_documentsget_document
Responses are Chroma JSON responses with no additional reshaping except count endpoints, which return { count = number }.
Raw agent markdown
# Chroma Lua API Reference
Namespace: `app.integrations.chroma`
This package targets the official Chroma REST API v2. Configure the Chroma server origin, tenant, database, and API token. The service sends the token as `x-chroma-token` and builds paths as:
```text
/api/v2/tenants/{tenant}/databases/{database}/...
```
## System
```lua
local health = app.integrations.chroma.get_health({})
print(health["nanosecond heartbeat"])
```
## Collections
```lua
local collections = app.integrations.chroma.list_collections({
limit = 50,
offset = 0
})
local count = app.integrations.chroma.count_collections({})
```
Collection tools:
- `list_collections({ limit, offset })`
- `count_collections({})`
- `get_collection({ collection_id })`
- `create_collection({ name, metadata, configuration })`
- `update_collection({ collection_id, new_name, metadata, configuration })`
- `delete_collection({ collection_id })`
`collection_id` may be a collection UUID or name when the configured Chroma deployment accepts names in that path.
## Add And Upsert Records
Chroma record payloads are column-oriented. Matching array positions belong to the same record.
```lua
local added = app.integrations.chroma.add_documents({
collection_id = "knowledge_base",
ids = { "doc1", "doc2" },
documents = {
"Chroma stores embeddings.",
"Chroma supports metadata filters."
},
metadatas = {
{ source = "docs" },
{ source = "docs" }
}
})
```
Use `upsert_documents` to create missing records or update existing ones:
```lua
local upserted = app.integrations.chroma.upsert_documents({
collection_id = "knowledge_base",
ids = { "vec1" },
embeddings = {
{ 0.1, 0.2, 0.3 }
},
documents = { "A record with a provided embedding" }
})
```
## Query And Get
Use `query_documents` for nearest-neighbor search and `get_document` for non-ranked retrieval by IDs or filters.
```lua
local result = app.integrations.chroma.query_documents({
collection_id = "knowledge_base",
query_embeddings = {
{ 0.1, 0.2, 0.3 }
},
n_results = 5,
include = { "documents", "metadatas", "distances" }
})
```
```lua
local records = app.integrations.chroma.get_document({
collection_id = "knowledge_base",
ids = { "doc1", "doc2" },
include = { "documents", "metadatas" }
})
```
Filter fields such as `where` and `where_document` are passed to Chroma as JSON objects.
## Update, Delete, And Count Records
```lua
local updated = app.integrations.chroma.update_documents({
collection_id = "knowledge_base",
ids = { "doc1" },
documents = { "Updated text" },
metadatas = { { source = "manual" } }
})
local deleted = app.integrations.chroma.delete_documents({
collection_id = "knowledge_base",
ids = { "doc2" }
})
local total = app.integrations.chroma.count_documents({
collection_id = "knowledge_base"
})
```
Record tools:
- `add_documents`
- `update_documents`
- `upsert_documents`
- `delete_documents`
- `count_documents`
- `query_documents`
- `get_document`
Responses are Chroma JSON responses with no additional reshaping except count endpoints, which return `{ count = number }`. local result = app.integrations.chroma.get_health({})
print(result) Functions
get_health Read
Check the health status of the Chroma vector database server. Returns heartbeat and version information.
- Lua path
app.integrations.chroma.get_health- Full name
chroma.chroma_get_health
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_collections Read
List all vector collections in Chroma. Returns collection names and IDs that can be used for further operations.
- Lua path
app.integrations.chroma.list_collections- Full name
chroma.chroma_list_collections
| Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Maximum number of collections to return (default: 100). |
offset | integer | no | Offset for pagination. |
count_collections Read
Count vector collections in the configured Chroma tenant/database.
- Lua path
app.integrations.chroma.count_collections- Full name
chroma.chroma_count_collections
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_collection Read
Get details of a specific Chroma collection by its name or UUID, including metadata and document count.
- Lua path
app.integrations.chroma.get_collection- Full name
chroma.chroma_get_collection
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | The collection name or UUID. |
create_collection Write
Create a new vector collection in Chroma. Collections are used to store and query document embeddings.
- Lua path
app.integrations.chroma.create_collection- Full name
chroma.chroma_create_collection
| Parameter | Type | Required | Description |
|---|---|---|---|
name | string | yes | The name of the collection to create. |
metadata | object | no | Optional metadata to attach to the collection (JSON object with string values). |
configuration | object | no | Optional Chroma index configuration. |
update_collection Write
Update collection name, metadata, or configuration.
- Lua path
app.integrations.chroma.update_collection- Full name
chroma.chroma_update_collection
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | Collection UUID or name. |
new_name | string | no | Optional new collection name. |
metadata | object | no | Optional replacement metadata. |
configuration | object | no | Optional replacement index configuration. |
delete_collection Write
Delete a collection and all records in it.
- Lua path
app.integrations.chroma.delete_collection- Full name
chroma.chroma_delete_collection
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | Collection UUID or name. |
add_documents Write
Add documents with embeddings to a Chroma collection. Each document requires an ID and either embeddings or text content.
- Lua path
app.integrations.chroma.add_documents- Full name
chroma.chroma_add_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | The collection name or UUID to add documents to. |
ids | array | yes | Array of unique document IDs (strings). |
embeddings | array | no | Array of embedding vectors. Each embedding is an array of floats. Required if no documents text provided. |
documents | array | no | Array of text documents. Chroma will generate embeddings if no embeddings are provided. |
metadatas | array | no | Array of metadata objects (one per document) with string values. |
uris | array | no | Optional URI strings associated with each record. |
update_documents Write
Update existing records in a Chroma collection.
- Lua path
app.integrations.chroma.update_documents- Full name
chroma.chroma_update_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | Collection UUID or name. |
ids | array | yes | Record IDs to update. |
embeddings | array | no | Updated embedding vectors. |
documents | array | no | Updated document strings. |
metadatas | array | no | Updated metadata objects. |
uris | array | no | Updated URI strings. |
upsert_documents Write
Upsert records in a Chroma collection.
- Lua path
app.integrations.chroma.upsert_documents- Full name
chroma.chroma_upsert_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | Collection UUID or name. |
ids | array | yes | Record IDs to upsert. |
embeddings | array | yes | Embedding vectors for each record. |
documents | array | no | Optional document strings. |
metadatas | array | no | Optional metadata objects. |
uris | array | no | Optional URI strings. |
delete_documents Write
Delete records from a collection by IDs or metadata filters.
- Lua path
app.integrations.chroma.delete_documents- Full name
chroma.chroma_delete_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | Collection UUID or name. |
ids | array | no | Record IDs to delete. |
where | object | no | Metadata filter. |
where_document | object | no | Document content filter. |
limit | integer | no | Optional maximum records to delete. |
count_documents Read
Count records in a Chroma collection.
- Lua path
app.integrations.chroma.count_documents- Full name
chroma.chroma_count_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | Collection UUID or name. |
query_documents Read
Search for similar documents in a Chroma collection using query embeddings or text. Returns the most similar documents ranked by distance.
- Lua path
app.integrations.chroma.query_documents- Full name
chroma.chroma_query_documents
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | The collection name or UUID to query. |
query_embeddings | array | no | Array of query embedding vectors. Each embedding is an array of floats. |
query_texts | array | no | Array of query text strings. Chroma will generate embeddings automatically. |
query_uris | array | no | Array of query URI strings. |
ids | array | no | Optional record IDs to constrain the search to. |
n_results | integer | no | Number of results to return per query (default: 10). |
where | string | no | JSON-encoded filter expression for metadata filtering, e.g. {"category": "tech"}. |
where_document | string | no | JSON-encoded filter on document content, e.g. {"$contains": "search term"}. |
include | array | no | Fields to include in response: documents, embeddings, metadatas, distances. Default: ["documents", "metadatas", "distances"]. |
get_document Read
Retrieve specific documents from a Chroma collection by their IDs. Returns the full documents including text, embeddings, and metadata.
- Lua path
app.integrations.chroma.get_document- Full name
chroma.chroma_get_document
| Parameter | Type | Required | Description |
|---|---|---|---|
collection_id | string | yes | The collection name or UUID. |
ids | array | no | Array of document IDs to retrieve. |
where | string | no | JSON-encoded metadata filter, e.g. {"category": "tech"}. |
where_document | string | no | JSON-encoded document content filter, e.g. {"$contains": "search term"}. |
include | array | no | Fields to include: documents, embeddings, metadatas. Default: ["documents", "metadatas"]. |
limit | integer | no | Maximum number of documents to return (default: 100). |
offset | integer | no | Number of documents to skip for pagination. |