KosmoKrator

database

Pinecone Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write Bearer token auth

Lua Namespace

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

Pinecone — Lua API Reference

list_indexes

List all vector indexes in your Pinecone project.

Parameters

None.

Example

local result = app.integrations.pinecone.list_indexes({})

for _, index in ipairs(result.indexes or {}) do
  print(index.name .. " (" .. index.dimension .. "d, " .. index.metric .. ")")
end

get_index

Get detailed information about a specific vector index.

Parameters

NameTypeRequiredDescription
namestringyesThe index name

Example

local result = app.integrations.pinecone.get_index({
  name = "my-index"
})

print("Host: " .. result.host)
print("Dimension: " .. result.dimension)
print("Status: " .. (result.status and result.status.ready and "ready" or "not ready"))

create_index

Create a new serverless vector index in Pinecone.

Parameters

NameTypeRequiredDescription
namestringyesUnique index name
dimensionintegeryesVector dimension (e.g., 1536 for OpenAI ada-002)
metricstringnoSimilarity metric: "cosine" (default), "euclidean", or "dotproduct"

Example

local result = app.integrations.pinecone.create_index({
  name = "documents",
  dimension = 1536,
  metric = "cosine"
})

print("Created index: " .. result.name)

upsert_vectors

Insert or update vectors in an index.

Parameters

NameTypeRequiredDescription
index_hoststringyesThe index host URL (from get_index response)
vectorsarrayyesArray of vector objects

Vector Object

FieldTypeRequiredDescription
idstringyesUnique vector identifier
valuesarrayyesArray of floats (must match index dimension)
metadataobjectnoKey-value metadata for filtering

Example

local result = app.integrations.pinecone.upsert_vectors({
  index_host = "idx-abc123.svc.us-east-1.pinecone.io",
  vectors = {
    {
      id = "doc1",
      values = {0.1, 0.2, 0.3, 0.4},
      metadata = { title = "Introduction", category = "docs" }
    },
    {
      id = "doc2",
      values = {0.5, 0.6, 0.7, 0.8},
      metadata = { title = "Getting Started", category = "docs" }
    }
  }
})

print("Upserted " .. (result.upserted_count or 0) .. " vectors")

query_vectors

Search for similar vectors in an index.

Parameters

NameTypeRequiredDescription
index_hoststringyesThe index host URL (from get_index response)
vectorarrayyesQuery vector embedding (must match index dimension)
top_kintegernoNumber of results to return (default: 10)
filterobjectnoMetadata filter expression
include_metadatabooleannoInclude metadata in results (default: true)

Filter Syntax

Metadata filters use Pinecone’s filter expressions:

filter = {
  category = { ["$eq"] = "docs" }
}

-- Multiple conditions
filter = {
  category = { ["$in"] = { "docs", "blog" } },
  year = { ["$gte"] = 2024 }
}

Operators: $eq, $ne, $gt, $gte, $lt, $lte, $in, $nin

Example

local result = app.integrations.pinecone.query_vectors({
  index_host = "idx-abc123.svc.us-east-1.pinecone.io",
  vector = {0.1, 0.2, 0.3, 0.4},
  top_k = 5,
  include_metadata = true,
  filter = {
    category = { ["$eq"] = "docs" }
  }
})

for _, match in ipairs(result.matches or {}) do
  print(match.id .. " (score: " .. match.score .. ")")
  if match.metadata then
    print("  title: " .. (match.metadata.title or "N/A"))
  end
end

list_collections

List all collections in your Pinecone project.

Parameters

None.

Example

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

for _, col in ipairs(result.collections or {}) do
  print(col.name .. " (source: " .. (col.source or "N/A") .. ")")
end

get_current_user

Get information about the currently authenticated Pinecone user.

Parameters

None.

Example

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

print("User: " .. (result.user_name or "N/A"))
print("Email: " .. (result.user_email or "N/A"))

Multi-Account Usage

If you have multiple Pinecone accounts configured, use account-specific namespaces:

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

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

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

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


Common Workflows

Create an index, upsert, and query

-- Step 1: Create an index
local index = app.integrations.pinecone.create_index({
  name = "my-docs",
  dimension = 1536,
  metric = "cosine"
})

-- Step 2: Get the host URL (once index is ready)
local details = app.integrations.pinecone.get_index({ name = "my-docs" })
local host = details.host

-- Step 3: Upsert vectors
app.integrations.pinecone.upsert_vectors({
  index_host = host,
  vectors = {
    { id = "doc1", values = {0.1, 0.2, ...}, metadata = { title = "Doc 1" } },
    { id = "doc2", values = {0.3, 0.4, ...}, metadata = { title = "Doc 2" } }
  }
})

-- Step 4: Query for similar vectors
local results = app.integrations.pinecone.query_vectors({
  index_host = host,
  vector = {0.1, 0.15, ...},
  top_k = 5
})
Raw agent markdown
# Pinecone — Lua API Reference

## list_indexes

List all vector indexes in your Pinecone project.

### Parameters

None.

### Example

```lua
local result = app.integrations.pinecone.list_indexes({})

for _, index in ipairs(result.indexes or {}) do
  print(index.name .. " (" .. index.dimension .. "d, " .. index.metric .. ")")
end
```

---

## get_index

Get detailed information about a specific vector index.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | The index name |

### Example

```lua
local result = app.integrations.pinecone.get_index({
  name = "my-index"
})

print("Host: " .. result.host)
print("Dimension: " .. result.dimension)
print("Status: " .. (result.status and result.status.ready and "ready" or "not ready"))
```

---

## create_index

Create a new serverless vector index in Pinecone.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | Unique index name |
| `dimension` | integer | yes | Vector dimension (e.g., 1536 for OpenAI ada-002) |
| `metric` | string | no | Similarity metric: `"cosine"` (default), `"euclidean"`, or `"dotproduct"` |

### Example

```lua
local result = app.integrations.pinecone.create_index({
  name = "documents",
  dimension = 1536,
  metric = "cosine"
})

print("Created index: " .. result.name)
```

---

## upsert_vectors

Insert or update vectors in an index.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `index_host` | string | yes | The index host URL (from get_index response) |
| `vectors` | array | yes | Array of vector objects |

### Vector Object

| Field | Type | Required | Description |
|-------|------|----------|-------------|
| `id` | string | yes | Unique vector identifier |
| `values` | array | yes | Array of floats (must match index dimension) |
| `metadata` | object | no | Key-value metadata for filtering |

### Example

```lua
local result = app.integrations.pinecone.upsert_vectors({
  index_host = "idx-abc123.svc.us-east-1.pinecone.io",
  vectors = {
    {
      id = "doc1",
      values = {0.1, 0.2, 0.3, 0.4},
      metadata = { title = "Introduction", category = "docs" }
    },
    {
      id = "doc2",
      values = {0.5, 0.6, 0.7, 0.8},
      metadata = { title = "Getting Started", category = "docs" }
    }
  }
})

print("Upserted " .. (result.upserted_count or 0) .. " vectors")
```

---

## query_vectors

Search for similar vectors in an index.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `index_host` | string | yes | The index host URL (from get_index response) |
| `vector` | array | yes | Query vector embedding (must match index dimension) |
| `top_k` | integer | no | Number of results to return (default: 10) |
| `filter` | object | no | Metadata filter expression |
| `include_metadata` | boolean | no | Include metadata in results (default: true) |

### Filter Syntax

Metadata filters use Pinecone's filter expressions:

```lua
filter = {
  category = { ["$eq"] = "docs" }
}

-- Multiple conditions
filter = {
  category = { ["$in"] = { "docs", "blog" } },
  year = { ["$gte"] = 2024 }
}
```

Operators: `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`

### Example

```lua
local result = app.integrations.pinecone.query_vectors({
  index_host = "idx-abc123.svc.us-east-1.pinecone.io",
  vector = {0.1, 0.2, 0.3, 0.4},
  top_k = 5,
  include_metadata = true,
  filter = {
    category = { ["$eq"] = "docs" }
  }
})

for _, match in ipairs(result.matches or {}) do
  print(match.id .. " (score: " .. match.score .. ")")
  if match.metadata then
    print("  title: " .. (match.metadata.title or "N/A"))
  end
end
```

---

## list_collections

List all collections in your Pinecone project.

### Parameters

None.

### Example

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

for _, col in ipairs(result.collections or {}) do
  print(col.name .. " (source: " .. (col.source or "N/A") .. ")")
end
```

---

## get_current_user

Get information about the currently authenticated Pinecone user.

### Parameters

None.

### Example

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

print("User: " .. (result.user_name or "N/A"))
print("Email: " .. (result.user_email or "N/A"))
```

---

## Multi-Account Usage

If you have multiple Pinecone accounts configured, use account-specific namespaces:

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

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

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

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

---

## Common Workflows

### Create an index, upsert, and query

```lua
-- Step 1: Create an index
local index = app.integrations.pinecone.create_index({
  name = "my-docs",
  dimension = 1536,
  metric = "cosine"
})

-- Step 2: Get the host URL (once index is ready)
local details = app.integrations.pinecone.get_index({ name = "my-docs" })
local host = details.host

-- Step 3: Upsert vectors
app.integrations.pinecone.upsert_vectors({
  index_host = host,
  vectors = {
    { id = "doc1", values = {0.1, 0.2, ...}, metadata = { title = "Doc 1" } },
    { id = "doc2", values = {0.3, 0.4, ...}, metadata = { title = "Doc 2" } }
  }
})

-- Step 4: Query for similar vectors
local results = app.integrations.pinecone.query_vectors({
  index_host = host,
  vector = {0.1, 0.15, ...},
  top_k = 5
})
```

Metadata-Derived Lua Example

local result = app.integrations.pinecone.pinecone_list_indexes({})
print(result)

Functions

pinecone_list_indexes

List all vector indexes in your Pinecone project. Returns index names, dimensions, metrics, and status.

Operation
Read read
Full name
pinecone.pinecone_list_indexes
ParameterTypeRequiredDescription
No parameters.

pinecone_get_index

Get detailed information about a specific Pinecone vector index, including its dimension, metric, host URL, and status.

Operation
Read read
Full name
pinecone.pinecone_get_index
ParameterTypeRequiredDescription
name string yes The name of the index to retrieve.

pinecone_create_index

Create a new serverless vector index in Pinecone. Specify the index name, vector dimension, and similarity metric (cosine, euclidean, or dotproduct).

Operation
Write write
Full name
pinecone.pinecone_create_index
ParameterTypeRequiredDescription
name string yes The name for the new index. Must be unique within the project.
dimension integer yes The dimension size of the vectors to be stored (e.g., 1536 for OpenAI text-embedding-ada-002, 3072 for text-embedding-3-large).
metric string no The similarity metric to use: "cosine" (default), "euclidean", or "dotproduct".

pinecone_upsert_vectors

Upsert vectors into a Pinecone index using an index host URL.

Operation
Write write
Full name
pinecone.pinecone_upsert_vectors
ParameterTypeRequiredDescription
index_host string yes The index host URL, such as "https://example.svc.us-east-1.pinecone.io".
vectors array yes Vector records with id, values, and optional metadata.

pinecone_query_vectors

Search for similar vectors in a Pinecone index using a query embedding.

Operation
Read read
Full name
pinecone.pinecone_query_vectors
ParameterTypeRequiredDescription
index_host string yes The index host URL.
vector array yes Query embedding vector values.
top_k integer no Number of top matches to return (default: 10).
filter object no Optional metadata filter expression.
include_metadata boolean no Whether to include metadata in matches (default: true).

pinecone_list_collections

List all collections in your Pinecone project. Collections are static snapshots of indexes used for backups or creating new indexes.

Operation
Read read
Full name
pinecone.pinecone_list_collections
ParameterTypeRequiredDescription
No parameters.

pinecone_get_current_user

Get information about the currently authenticated Pinecone user, including email, name, and project details.

Operation
Read read
Full name
pinecone.pinecone_get_current_user
ParameterTypeRequiredDescription
No parameters.