KosmoKrator

data

Voyage AI Lua API for KosmoKrator Agents

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

Lua Namespace

Agents call this integration through app.integrations.voyage_ai.*. Use lua_read_doc("integrations.voyage-ai") 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 Voyage AI workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.voyage_ai.create_embedding({input = "example_input", model = "example_model", input_type = "example_input_type", truncation = true, output_dimension = 1, output_dtype = "example_output_dtype", encoding_format = "example_encoding_format"}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("voyage-ai"))' --json
kosmo integrations:lua --eval 'print(docs.read("voyage-ai.create_embedding"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local voyage_ai = app.integrations.voyage_ai
local result = voyage_ai.create_embedding({input = "example_input", model = "example_model", input_type = "example_input_type", truncation = true, output_dimension = 1, output_dtype = "example_output_dtype", encoding_format = "example_encoding_format"})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.voyage_ai, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.voyage_ai.default.* or app.integrations.voyage_ai.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Voyage AI, use the narrower mcp:lua command.

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.

Voyage AI — Lua API Reference

The voyage-ai integration exposes Voyage AI’s official inference, files, and batch APIs for retrieval workflows.

Use it for text embeddings, contextualized chunk embeddings, multimodal embeddings, reranking, batch input/output files, and long-running batch inference jobs. Responses are returned in Voyage AI’s native JSON shape unless the endpoint returns raw file content.

create_embedding

Create text embeddings.

Required parameters:

  • input: string or string array.
  • model: model name, such as voyage-4, voyage-4-large, voyage-4-lite, or voyage-code-3.

Optional parameters:

  • input_type: query or document.
  • truncation: boolean.
  • output_dimension: integer.
  • output_dtype: float, int8, uint8, binary, or ubinary.
  • encoding_format: base64.
local result = app.integrations["voyage-ai"].create_embedding({
  input = {"Install guide", "API reference"},
  model = "voyage-4",
  input_type = "document",
  output_dimension = 1024
})

create_contextualized_embeddings

Create embeddings where chunks in each inner list are encoded with context from neighboring chunks.

Required parameters:

  • inputs: array of string arrays.
  • model: usually voyage-context-3.

Optional parameters: input_type, output_dimension, output_dtype, encoding_format.

local result = app.integrations["voyage-ai"].create_contextualized_embeddings({
  inputs = {
    {"Intro chunk", "Setup chunk", "API chunk"}
  },
  model = "voyage-context-3",
  input_type = "document"
})

create_multimodal_embeddings

Create embeddings from interleaved text, image, and video content blocks.

Required parameters:

  • inputs: array of objects with content arrays.
  • model: usually voyage-multimodal-3.5.

Optional parameters: input_type, truncation, output_encoding.

local result = app.integrations["voyage-ai"].create_multimodal_embeddings({
  model = "voyage-multimodal-3.5",
  inputs = {
    {
      content = {
        {type = "text", text = "This is a product screenshot."},
        {type = "image_url", image_url = "https://example.test/screenshot.png"}
      }
    }
  }
})

For URL-based image or video inputs, Voyage applies URL safety constraints such as redirect limits, required content-length headers, and robots.txt handling.

rerank

Rerank documents for a query.

Required parameters:

  • query: query string.
  • documents: array of document strings.
  • model: usually rerank-2.5 or rerank-2.5-lite.

Optional parameters:

  • top_k: number of results to return.
  • return_documents: include document text in each result.
  • truncation: boolean.
local ranked = app.integrations["voyage-ai"].rerank({
  query = "How do I upload files?",
  documents = {"Use the Files API.", "Use the Billing API."},
  model = "rerank-2.5",
  top_k = 1,
  return_documents = true
})

upload_file

Upload JSONL content for the Batch API. purpose must be batch.

local file = app.integrations["voyage-ai"].upload_file({
  filename = "batch-input.jsonl",
  content = '{"custom_id":"row-1","body":{"input":"hello"}}' .. "\n",
  purpose = "batch"
})

list_files

List files with optional purpose, limit, order, and after.

local files = app.integrations["voyage-ai"].list_files({
  purpose = "batch",
  limit = 20,
  order = "desc"
})

retrieve_file

Retrieve file metadata by file_id.

local file = app.integrations["voyage-ai"].retrieve_file({
  file_id = "file_abc123"
})

retrieve_file_content

Retrieve file content, usually batch output or error JSONL.

local content = app.integrations["voyage-ai"].retrieve_file_content({
  file_id = "file_output123",
  accept = "text/plain"
})

delete_file

Delete one file by file_id.

app.integrations["voyage-ai"].delete_file({
  file_id = "file_abc123"
})

bulk_delete_files

Delete multiple files atomically. Voyage requires every ID to be valid or none are deleted.

app.integrations["voyage-ai"].bulk_delete_files({
  file_ids = {"file_abc123", "file_def456"}
})

create_batch

Create a batch inference job. Supported endpoint values are v1/embeddings, v1/contextualizedembeddings, and v1/rerank. completion_window must currently be 12h.

local batch = app.integrations["voyage-ai"].create_batch({
  endpoint = "v1/embeddings",
  input_file_id = "file_abc123",
  completion_window = "12h",
  request_params = {
    model = "voyage-4",
    input_type = "document"
  },
  metadata = {
    corpus = "docs"
  }
})

list_batches

List batch jobs with optional limit and after.

local batches = app.integrations["voyage-ai"].list_batches({
  limit = 20
})

retrieve_batch

Retrieve a batch job by batch_id. Completed batches include output and error file IDs when available.

local batch = app.integrations["voyage-ai"].retrieve_batch({
  batch_id = "batch_abc123"
})

cancel_batch

Cancel a validating or in-progress batch job.

app.integrations["voyage-ai"].cancel_batch({
  batch_id = "batch_abc123"
})

Multi-Account Usage

If multiple Voyage AI accounts are configured, use account-specific namespaces:

app.integrations["voyage-ai"].create_embedding({...})
app.integrations["voyage-ai"].default.create_embedding({...})
app.integrations["voyage-ai"].research.create_embedding({...})
Raw agent markdown
# Voyage AI — Lua API Reference

The `voyage-ai` integration exposes Voyage AI's official inference, files, and batch APIs for retrieval workflows.

Use it for text embeddings, contextualized chunk embeddings, multimodal embeddings, reranking, batch input/output files, and long-running batch inference jobs. Responses are returned in Voyage AI's native JSON shape unless the endpoint returns raw file content.

## create_embedding

Create text embeddings.

Required parameters:

- `input`: string or string array.
- `model`: model name, such as `voyage-4`, `voyage-4-large`, `voyage-4-lite`, or `voyage-code-3`.

Optional parameters:

- `input_type`: `query` or `document`.
- `truncation`: boolean.
- `output_dimension`: integer.
- `output_dtype`: `float`, `int8`, `uint8`, `binary`, or `ubinary`.
- `encoding_format`: `base64`.

```lua
local result = app.integrations["voyage-ai"].create_embedding({
  input = {"Install guide", "API reference"},
  model = "voyage-4",
  input_type = "document",
  output_dimension = 1024
})
```

## create_contextualized_embeddings

Create embeddings where chunks in each inner list are encoded with context from neighboring chunks.

Required parameters:

- `inputs`: array of string arrays.
- `model`: usually `voyage-context-3`.

Optional parameters: `input_type`, `output_dimension`, `output_dtype`, `encoding_format`.

```lua
local result = app.integrations["voyage-ai"].create_contextualized_embeddings({
  inputs = {
    {"Intro chunk", "Setup chunk", "API chunk"}
  },
  model = "voyage-context-3",
  input_type = "document"
})
```

## create_multimodal_embeddings

Create embeddings from interleaved text, image, and video content blocks.

Required parameters:

- `inputs`: array of objects with `content` arrays.
- `model`: usually `voyage-multimodal-3.5`.

Optional parameters: `input_type`, `truncation`, `output_encoding`.

```lua
local result = app.integrations["voyage-ai"].create_multimodal_embeddings({
  model = "voyage-multimodal-3.5",
  inputs = {
    {
      content = {
        {type = "text", text = "This is a product screenshot."},
        {type = "image_url", image_url = "https://example.test/screenshot.png"}
      }
    }
  }
})
```

For URL-based image or video inputs, Voyage applies URL safety constraints such as redirect limits, required content-length headers, and robots.txt handling.

## rerank

Rerank documents for a query.

Required parameters:

- `query`: query string.
- `documents`: array of document strings.
- `model`: usually `rerank-2.5` or `rerank-2.5-lite`.

Optional parameters:

- `top_k`: number of results to return.
- `return_documents`: include document text in each result.
- `truncation`: boolean.

```lua
local ranked = app.integrations["voyage-ai"].rerank({
  query = "How do I upload files?",
  documents = {"Use the Files API.", "Use the Billing API."},
  model = "rerank-2.5",
  top_k = 1,
  return_documents = true
})
```

## upload_file

Upload JSONL content for the Batch API. `purpose` must be `batch`.

```lua
local file = app.integrations["voyage-ai"].upload_file({
  filename = "batch-input.jsonl",
  content = '{"custom_id":"row-1","body":{"input":"hello"}}' .. "\n",
  purpose = "batch"
})
```

## list_files

List files with optional `purpose`, `limit`, `order`, and `after`.

```lua
local files = app.integrations["voyage-ai"].list_files({
  purpose = "batch",
  limit = 20,
  order = "desc"
})
```

## retrieve_file

Retrieve file metadata by `file_id`.

```lua
local file = app.integrations["voyage-ai"].retrieve_file({
  file_id = "file_abc123"
})
```

## retrieve_file_content

Retrieve file content, usually batch output or error JSONL.

```lua
local content = app.integrations["voyage-ai"].retrieve_file_content({
  file_id = "file_output123",
  accept = "text/plain"
})
```

## delete_file

Delete one file by `file_id`.

```lua
app.integrations["voyage-ai"].delete_file({
  file_id = "file_abc123"
})
```

## bulk_delete_files

Delete multiple files atomically. Voyage requires every ID to be valid or none are deleted.

```lua
app.integrations["voyage-ai"].bulk_delete_files({
  file_ids = {"file_abc123", "file_def456"}
})
```

## create_batch

Create a batch inference job. Supported `endpoint` values are `v1/embeddings`, `v1/contextualizedembeddings`, and `v1/rerank`. `completion_window` must currently be `12h`.

```lua
local batch = app.integrations["voyage-ai"].create_batch({
  endpoint = "v1/embeddings",
  input_file_id = "file_abc123",
  completion_window = "12h",
  request_params = {
    model = "voyage-4",
    input_type = "document"
  },
  metadata = {
    corpus = "docs"
  }
})
```

## list_batches

List batch jobs with optional `limit` and `after`.

```lua
local batches = app.integrations["voyage-ai"].list_batches({
  limit = 20
})
```

## retrieve_batch

Retrieve a batch job by `batch_id`. Completed batches include output and error file IDs when available.

```lua
local batch = app.integrations["voyage-ai"].retrieve_batch({
  batch_id = "batch_abc123"
})
```

## cancel_batch

Cancel a validating or in-progress batch job.

```lua
app.integrations["voyage-ai"].cancel_batch({
  batch_id = "batch_abc123"
})
```

## Multi-Account Usage

If multiple Voyage AI accounts are configured, use account-specific namespaces:

```lua
app.integrations["voyage-ai"].create_embedding({...})
app.integrations["voyage-ai"].default.create_embedding({...})
app.integrations["voyage-ai"].research.create_embedding({...})
```
Metadata-derived Lua example
local result = app.integrations.voyage_ai.create_embedding({input = "example_input", model = "example_model", input_type = "example_input_type", truncation = true, output_dimension = 1, output_dtype = "example_output_dtype", encoding_format = "example_encoding_format"})
print(result)

Functions

create_embedding Read

Create text embeddings with Voyage AI. Use input_type=query for search queries and input_type=document for indexed documents.

Lua path
app.integrations.voyage_ai.create_embedding
Full name
voyage-ai.voyage_ai_create_embedding
ParameterTypeRequiredDescription
input string,array yes Single text string or array of text strings.
model string yes Embedding model name, e.g. voyage-4, voyage-4-large, voyage-4-lite, voyage-code-3.
input_type string no Input intent. Use query or document for retrieval workflows.
truncation boolean no Whether to truncate inputs to fit model context. Defaults to true upstream.
output_dimension integer no Optional output dimensions: commonly 2048, 1024, 512, or 256 for supported models.
output_dtype string no Embedding data type.
encoding_format string no Optional base64 encoding for embeddings.
create_contextualized_embeddings Read

Create contextualized chunk embeddings. Pass inputs as an array of arrays where each inner array contains chunks from one document or one query/document item.

Lua path
app.integrations.voyage_ai.create_contextualized_embeddings
Full name
voyage-ai.voyage_ai_create_contextualized_embeddings
ParameterTypeRequiredDescription
inputs array yes Array of arrays of strings to embed together with context.
model string yes Model name. Recommended: voyage-context-3.
input_type string no Input intent. Use query or document for retrieval workflows.
output_dimension integer no Output dimensions. voyage-context-3 supports 2048, 1024, 512, 256.
output_dtype string no Embedding data type.
encoding_format string no Optional base64 encoding for embeddings.
create_multimodal_embeddings Read

Create Voyage AI multimodal embeddings from inputs containing interleaved text, image, or video content blocks.

Lua path
app.integrations.voyage_ai.create_multimodal_embeddings
Full name
voyage-ai.voyage_ai_create_multimodal_embeddings
ParameterTypeRequiredDescription
inputs array yes Array of objects with a content array of text/image/video blocks.
model string yes Model name. Recommended: voyage-multimodal-3.5.
input_type string no Input intent. Use query or document for retrieval workflows.
truncation boolean no Whether to truncate inputs to fit model context.
output_encoding string no Optional base64 encoding for embeddings.
rerank Read

Rerank documents for a query using Voyage AI cross-encoder rerankers. Use after lexical or vector retrieval to improve final context quality.

Lua path
app.integrations.voyage_ai.rerank
Full name
voyage-ai.voyage_ai_rerank
ParameterTypeRequiredDescription
query string yes Query to rank documents against.
documents array yes Documents to rerank. Maximum 1,000 documents.
model string yes Reranker model. Recommended: rerank-2.5 or rerank-2.5-lite.
top_k integer no Number of most relevant documents to return.
return_documents boolean no Whether to include source documents in the response.
truncation boolean no Whether to truncate inputs to fit model context. Defaults to true upstream.
upload_file Write

Upload a JSONL file for Voyage AI Batch API. The file content must already be formatted for the selected batch endpoint.

Lua path
app.integrations.voyage_ai.upload_file
Full name
voyage-ai.voyage_ai_upload_file
ParameterTypeRequiredDescription
filename string yes Filename to send to Voyage AI, usually ending in .jsonl.
content string yes Raw JSONL file content.
purpose string no File purpose. Currently must be batch. Defaults to batch.
list_files Read

List Voyage AI files, optionally filtered by purpose and paginated by cursor.

Lua path
app.integrations.voyage_ai.list_files
Full name
voyage-ai.voyage_ai_list_files
ParameterTypeRequiredDescription
purpose string no Only return files with this purpose.
limit integer no Number of files to return. Range: 1-10000.
order string no Sort order by created_at.
after string no Pagination cursor: file ID after which to continue.
retrieve_file Read

Retrieve metadata for a Voyage AI file by file_id.

Lua path
app.integrations.voyage_ai.retrieve_file
Full name
voyage-ai.voyage_ai_retrieve_file
ParameterTypeRequiredDescription
file_id string yes Voyage AI file ID.
retrieve_file_content Read

Retrieve raw content for a Voyage AI file, such as batch output or error JSONL.

Lua path
app.integrations.voyage_ai.retrieve_file_content
Full name
voyage-ai.voyage_ai_retrieve_file_content
ParameterTypeRequiredDescription
file_id string yes Voyage AI file ID.
accept string no Accept header. Defaults to text/plain.
delete_file Write

Delete one Voyage AI file by file_id.

Lua path
app.integrations.voyage_ai.delete_file
Full name
voyage-ai.voyage_ai_delete_file
ParameterTypeRequiredDescription
file_id string yes Voyage AI file ID to delete.
bulk_delete_files Write

Delete one or more Voyage AI files in an all-or-nothing bulk delete operation.

Lua path
app.integrations.voyage_ai.bulk_delete_files
Full name
voyage-ai.voyage_ai_bulk_delete_files
ParameterTypeRequiredDescription
file_ids array yes File IDs to delete.
create_batch Write

Create a Voyage AI batch inference job for embeddings, contextualized embeddings, or rerank requests using an uploaded JSONL file.

Lua path
app.integrations.voyage_ai.create_batch
Full name
voyage-ai.voyage_ai_create_batch
ParameterTypeRequiredDescription
endpoint string yes Batch endpoint: v1/embeddings, v1/contextualizedembeddings, or v1/rerank.
input_file_id string yes Uploaded JSONL file ID with purpose=batch.
completion_window string yes Completion window. Currently only 12h is supported.
request_params object yes Endpoint parameters shared by every request in the batch, excluding per-line input data.
metadata object no Optional metadata object. Upstream supports up to 16 key-value pairs.
list_batches Read

List Voyage AI batch jobs with optional pagination.

Lua path
app.integrations.voyage_ai.list_batches
Full name
voyage-ai.voyage_ai_list_batches
ParameterTypeRequiredDescription
limit integer no Number of batches to return. Range: 1-100.
after string no Pagination cursor: batch ID after which to continue.
retrieve_batch Read

Retrieve a Voyage AI batch job by batch_id.

Lua path
app.integrations.voyage_ai.retrieve_batch
Full name
voyage-ai.voyage_ai_retrieve_batch
ParameterTypeRequiredDescription
batch_id string yes Voyage AI batch ID.
cancel_batch Write

Cancel a Voyage AI batch job that is currently validating or in_progress.

Lua path
app.integrations.voyage_ai.cancel_batch
Full name
voyage-ai.voyage_ai_cancel_batch
ParameterTypeRequiredDescription
batch_id string yes Voyage AI batch ID to cancel.