KosmoKrator

ai

Jina AI Lua API for KosmoKrator Agents

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

5 functions 5 read 0 write API key auth

Lua Namespace

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

Jina AI — Lua API Reference

Search the web using Jina AI.

Parameters

NameTypeRequiredDescription
qstringyesThe search query string

Examples

local result = app.integrations.jinaai.search({
  q = "Laravel 12 new features"
})

for _, item in ipairs(result.data.result) do
  print(item.title .. ": " .. item.url)
end

read

Read and extract clean content from a URL.

Parameters

NameTypeRequiredDescription
urlstringyesThe URL to read and extract content from

Examples

Read a web page

local result = app.integrations.jinaai.read({
  url = "https://laravel.com/docs/12.x"
})

print(result.data.content)

ground

Ground a statement against provided context — verify whether a claim is supported by reference text.

Parameters

NameTypeRequiredDescription
statementstringyesThe statement or claim to verify
contextstringyesThe reference context text to ground the statement against

Examples

Verify a claim

local result = app.integrations.jinaai.ground({
  statement = "Laravel 12 was released in 2025",
  context = "Laravel 12 was officially released on March 11, 2025, introducing new features like conversational exception handling and improved queue management."
})

for _, fact in ipairs(result.data.facts) do
  print(fact.statement .. ": " .. fact.grounded)
end

embeddings

Generate text embeddings — convert text into dense vector representations.

Parameters

NameTypeRequiredDescription
inputarrayyesAn array of strings to generate embeddings for
modelstringnoThe embedding model (e.g., "jina-embeddings-v3")

Available Models

jina-embeddings-v3, jina-embeddings-v2-base-en, jina-embeddings-v2-base-de, jina-embeddings-v2-base-es, jina-embeddings-v2-base-code, jina-embeddings-v2-base-zh

Examples

Generate embeddings for texts

local result = app.integrations.jinaai.embeddings({
  input = {
    "Laravel is a PHP framework",
    "Vue.js is a JavaScript framework"
  },
  model = "jina-embeddings-v3"
})

for _, embedding in ipairs(result.data) do
  print("Embedding index " .. embedding.index .. ": " .. #embedding.embedding .. " dimensions")
end

rerank

Rerank documents by relevance to a query.

Parameters

NameTypeRequiredDescription
querystringyesThe query to rank documents against
documentsarrayyesAn array of document strings to rank
modelstringnoThe reranking model (e.g., "jina-reranker-v2-base-multilingual")
top_nintegernoMaximum number of top results to return

Available Models

jina-reranker-v2-base-multilingual, jina-reranker-v1-turbo-en, jina-reranker-v1-tiny-en, jina-colbert-v1-en, jina-colbert-v2

Examples

Rerank search results

local result = app.integrations.jinaai.rerank({
  query = "How to install Laravel",
  documents = {
    "Laravel is a web application framework with expressive, elegant syntax.",
    "To install Laravel, use Composer: composer create-project laravel/laravel example-app",
    "Vue.js is a progressive JavaScript framework for building user interfaces.",
    "Laravel Sail provides a Docker-based development environment."
  },
  top_n = 2
})

for _, doc in ipairs(result.results) do
  print("Rank " .. doc.index .. " (score: " .. doc.relevance_score .. "): " .. doc.document.text:sub(1, 80))
end

Multi-Account Usage

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

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

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

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

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

Raw agent markdown
# Jina AI — Lua API Reference

## search

Search the web using Jina AI.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `q` | string | yes | The search query string |

### Examples

### Basic web search

```lua
local result = app.integrations.jinaai.search({
  q = "Laravel 12 new features"
})

for _, item in ipairs(result.data.result) do
  print(item.title .. ": " .. item.url)
end
```

---

## read

Read and extract clean content from a URL.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `url` | string | yes | The URL to read and extract content from |

### Examples

### Read a web page

```lua
local result = app.integrations.jinaai.read({
  url = "https://laravel.com/docs/12.x"
})

print(result.data.content)
```

---

## ground

Ground a statement against provided context — verify whether a claim is supported by reference text.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `statement` | string | yes | The statement or claim to verify |
| `context` | string | yes | The reference context text to ground the statement against |

### Examples

### Verify a claim

```lua
local result = app.integrations.jinaai.ground({
  statement = "Laravel 12 was released in 2025",
  context = "Laravel 12 was officially released on March 11, 2025, introducing new features like conversational exception handling and improved queue management."
})

for _, fact in ipairs(result.data.facts) do
  print(fact.statement .. ": " .. fact.grounded)
end
```

---

## embeddings

Generate text embeddings — convert text into dense vector representations.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `input` | array | yes | An array of strings to generate embeddings for |
| `model` | string | no | The embedding model (e.g., `"jina-embeddings-v3"`) |

### Available Models

`jina-embeddings-v3`, `jina-embeddings-v2-base-en`, `jina-embeddings-v2-base-de`, `jina-embeddings-v2-base-es`, `jina-embeddings-v2-base-code`, `jina-embeddings-v2-base-zh`

### Examples

### Generate embeddings for texts

```lua
local result = app.integrations.jinaai.embeddings({
  input = {
    "Laravel is a PHP framework",
    "Vue.js is a JavaScript framework"
  },
  model = "jina-embeddings-v3"
})

for _, embedding in ipairs(result.data) do
  print("Embedding index " .. embedding.index .. ": " .. #embedding.embedding .. " dimensions")
end
```

---

## rerank

Rerank documents by relevance to a query.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `query` | string | yes | The query to rank documents against |
| `documents` | array | yes | An array of document strings to rank |
| `model` | string | no | The reranking model (e.g., `"jina-reranker-v2-base-multilingual"`) |
| `top_n` | integer | no | Maximum number of top results to return |

### Available Models

`jina-reranker-v2-base-multilingual`, `jina-reranker-v1-turbo-en`, `jina-reranker-v1-tiny-en`, `jina-colbert-v1-en`, `jina-colbert-v2`

### Examples

### Rerank search results

```lua
local result = app.integrations.jinaai.rerank({
  query = "How to install Laravel",
  documents = {
    "Laravel is a web application framework with expressive, elegant syntax.",
    "To install Laravel, use Composer: composer create-project laravel/laravel example-app",
    "Vue.js is a progressive JavaScript framework for building user interfaces.",
    "Laravel Sail provides a Docker-based development environment."
  },
  top_n = 2
})

for _, doc in ipairs(result.results) do
  print("Rank " .. doc.index .. " (score: " .. doc.relevance_score .. "): " .. doc.document.text:sub(1, 80))
end
```

---

## Multi-Account Usage

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

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

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

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

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

Metadata-Derived Lua Example

local result = app.integrations.jinaai.jinaai_search({
  q = "example_q"
})
print(result)

Functions

jinaai_read

Read and extract clean content from a URL using Jina AI Reader. Returns the main text content of a web page, stripping away navigation, ads, and other clutter. Useful for reading articles, documentation, or any web page.

Operation
Read read
Full name
jinaai.jinaai_read
ParameterTypeRequiredDescription
url string yes The URL to read and extract content from.

jinaai_ground

Ground a statement against provided context using Jina AI. Verifies whether a claim or statement is supported by the given reference text. Returns grounding results indicating which parts of the statement are supported or contradicted.

Operation
Read read
Full name
jinaai.jinaai_ground
ParameterTypeRequiredDescription
statement string yes The statement or claim to verify.
context string yes The reference context text to ground the statement against.

jinaai_embeddings

Generate text embeddings using Jina AI. Converts text into dense vector representations useful for semantic search, similarity comparison, clustering, and retrieval-augmented generation (RAG).

Operation
Read read
Full name
jinaai.jinaai_embeddings
ParameterTypeRequiredDescription
input array yes An array of strings to generate embeddings for. Each string is embedded independently.
model string no The embedding model to use (e.g., "jina-embeddings-v3"). Defaults to the Jina AI default model.

jinaai_rerank

Rerank documents by relevance to a query using Jina AI. Takes a query and a list of text documents, then returns them sorted by relevance with scores. Useful for improving search results or filtering the most relevant content.

Operation
Read read
Full name
jinaai.jinaai_rerank
ParameterTypeRequiredDescription
query string yes The query to rank documents against.
documents array yes An array of document strings to rank by relevance to the query.
model string no The reranking model to use (e.g., "jina-reranker-v2-base-multilingual"). Defaults to the Jina AI default model.
top_n integer no Maximum number of top results to return. Defaults to all documents.