KosmoKrator

ai

Groq Lua API for KosmoKrator Agents

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

7 functions 5 read 2 write API key auth

Lua Namespace

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

Groq — Lua API Reference

list_models

List available Groq AI models.

Parameters

None.

Example

local result = app.integrations["groq"].list_models({})

for _, model in ipairs(result.data) do
  print(model.id)
end

create_completion

Create a chat completion using a Groq model.

Parameters

NameTypeRequiredDescription
modelstringyesModel ID, e.g. "llama-3.3-70b-versatile"
messagesarrayyesArray of message objects with role and content
temperaturenumbernoRandomness control (0.0–2.0)
max_tokensintegernoMax tokens in the response
top_pnumbernoNucleus sampling (0.0–1.0)
streambooleannoStream the response (default: false)

Message Format

The messages array contains message objects:

{
  { role = "system", content = "You are a helpful assistant." },
  { role = "user", content = "Hello!" }
}

For multi-turn conversations:

{
  { role = "system", content = "You are a helpful assistant." },
  { role = "user", content = "Hello!" },
  { role = "assistant", content = "Hi there!" },
  { role = "user", content = "Tell me more." }
}

Example

local result = app.integrations["groq"].create_completion({
  model = "llama-3.3-70b-versatile",
  messages = {
    { role = "system", content = "You are a helpful assistant." },
    { role = "user", content = "Write a haiku about programming." }
  },
  temperature = 0.7,
  max_tokens = 100
})

for _, choice in ipairs(result.choices) do
  print(choice.message.content)
end

list_messages

List messages in a Groq Cloud conversation.

Parameters

NameTypeRequiredDescription
conversation_idstringyesThe conversation ID
limitintegernoMax messages per page (default: 20)
afterstringnoCursor for pagination

Example

local result = app.integrations["groq"].list_messages({
  conversation_id = "conv_abc123",
  limit = 10
})

for _, msg in ipairs(result.data) do
  print(msg.role .. ": " .. msg.content)
end

create_message

Create a message in a Groq Cloud conversation.

Parameters

NameTypeRequiredDescription
conversation_idstringyesThe conversation ID
rolestringyesMessage role (e.g., "user", "assistant")
contentstringyesThe message text

Example

local result = app.integrations["groq"].create_message({
  conversation_id = "conv_abc123",
  role = "user",
  content = "What is the capital of France?"
})

print(result.id)
print(result.role .. ": " .. result.content)

list_files

List files uploaded to the Groq Files API.

Parameters

NameTypeRequiredDescription
purposestringnoFilter by purpose (e.g., "batch")
limitintegernoMax files per page (default: 20)
afterstringnoCursor for pagination

Example

local result = app.integrations["groq"].list_files({
  limit = 10
})

for _, file in ipairs(result.data) do
  print(file.id .. " — " .. file.filename .. " (" .. file.bytes .. " bytes)")
end

get_file

Get metadata for an uploaded file.

Parameters

NameTypeRequiredDescription
file_idstringyesThe file identifier, e.g. "file-abc123"

Example

local result = app.integrations["groq"].get_file({
  file_id = "file-abc123"
})

print("File: " .. result.filename)
print("Purpose: " .. result.purpose)
print("Size: " .. result.bytes .. " bytes")
print("Status: " .. result.status)

get_current_user

Get information about the currently authenticated user.

Parameters

None.

Example

local result = app.integrations["groq"].get_current_user({})

print("User: " .. (result.id or "unknown"))

Multi-Account Usage

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

-- Default account (always works)
app.integrations["groq"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["groq"].default.function_name({...})

-- Named accounts
app.integrations["groq"].work.function_name({...})
app.integrations["groq"].personal.function_name({...})

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

Raw agent markdown
# Groq — Lua API Reference

## list_models

List available Groq AI models.

### Parameters

None.

### Example

```lua
local result = app.integrations["groq"].list_models({})

for _, model in ipairs(result.data) do
  print(model.id)
end
```

---

## create_completion

Create a chat completion using a Groq model.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `model` | string | yes | Model ID, e.g. `"llama-3.3-70b-versatile"` |
| `messages` | array | yes | Array of message objects with `role` and `content` |
| `temperature` | number | no | Randomness control (0.0–2.0) |
| `max_tokens` | integer | no | Max tokens in the response |
| `top_p` | number | no | Nucleus sampling (0.0–1.0) |
| `stream` | boolean | no | Stream the response (default: false) |

### Message Format

The `messages` array contains message objects:

```lua
{
  { role = "system", content = "You are a helpful assistant." },
  { role = "user", content = "Hello!" }
}
```

For multi-turn conversations:

```lua
{
  { role = "system", content = "You are a helpful assistant." },
  { role = "user", content = "Hello!" },
  { role = "assistant", content = "Hi there!" },
  { role = "user", content = "Tell me more." }
}
```

### Example

```lua
local result = app.integrations["groq"].create_completion({
  model = "llama-3.3-70b-versatile",
  messages = {
    { role = "system", content = "You are a helpful assistant." },
    { role = "user", content = "Write a haiku about programming." }
  },
  temperature = 0.7,
  max_tokens = 100
})

for _, choice in ipairs(result.choices) do
  print(choice.message.content)
end
```

---

## list_messages

List messages in a Groq Cloud conversation.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `conversation_id` | string | yes | The conversation ID |
| `limit` | integer | no | Max messages per page (default: 20) |
| `after` | string | no | Cursor for pagination |

### Example

```lua
local result = app.integrations["groq"].list_messages({
  conversation_id = "conv_abc123",
  limit = 10
})

for _, msg in ipairs(result.data) do
  print(msg.role .. ": " .. msg.content)
end
```

---

## create_message

Create a message in a Groq Cloud conversation.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `conversation_id` | string | yes | The conversation ID |
| `role` | string | yes | Message role (e.g., `"user"`, `"assistant"`) |
| `content` | string | yes | The message text |

### Example

```lua
local result = app.integrations["groq"].create_message({
  conversation_id = "conv_abc123",
  role = "user",
  content = "What is the capital of France?"
})

print(result.id)
print(result.role .. ": " .. result.content)
```

---

## list_files

List files uploaded to the Groq Files API.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `purpose` | string | no | Filter by purpose (e.g., `"batch"`) |
| `limit` | integer | no | Max files per page (default: 20) |
| `after` | string | no | Cursor for pagination |

### Example

```lua
local result = app.integrations["groq"].list_files({
  limit = 10
})

for _, file in ipairs(result.data) do
  print(file.id .. " — " .. file.filename .. " (" .. file.bytes .. " bytes)")
end
```

---

## get_file

Get metadata for an uploaded file.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `file_id` | string | yes | The file identifier, e.g. `"file-abc123"` |

### Example

```lua
local result = app.integrations["groq"].get_file({
  file_id = "file-abc123"
})

print("File: " .. result.filename)
print("Purpose: " .. result.purpose)
print("Size: " .. result.bytes .. " bytes")
print("Status: " .. result.status)
```

---

## get_current_user

Get information about the currently authenticated user.

### Parameters

None.

### Example

```lua
local result = app.integrations["groq"].get_current_user({})

print("User: " .. (result.id or "unknown"))
```

---

## Multi-Account Usage

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

```lua
-- Default account (always works)
app.integrations["groq"].function_name({...})

-- Explicit default (portable across setups)
app.integrations["groq"].default.function_name({...})

-- Named accounts
app.integrations["groq"].work.function_name({...})
app.integrations["groq"].personal.function_name({...})
```

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

Metadata-Derived Lua Example

local result = app.integrations.groq.groq_list_models({})
print(result)

Functions

groq_list_models

List available Groq AI models. Returns model IDs, ownership, and other metadata for models accessible via the Groq API.

Operation
Read read
Full name
groq.groq_list_models
ParameterTypeRequiredDescription
No parameters.

groq_create_completion

Create a chat completion using a Groq model. Send a list of messages and receive an AI-generated response with ultra-low latency. Supports configurable parameters like temperature, max_tokens, and top_p.

Operation
Write write
Full name
groq.groq_create_completion
ParameterTypeRequiredDescription
model string yes The model ID to use (e.g., "llama-3.3-70b-versatile", "mixtral-8x7b-32768", "gemma2-9b-it").
messages array yes Array of message objects. Each message should have a "role" ("system", "user", or "assistant") and "content" string.
temperature number no Controls randomness in generation (0.0–2.0). Lower values are more deterministic, higher values more creative.
max_tokens integer no Maximum number of tokens to generate in the response.
top_p number no Nucleus sampling parameter (0.0–1.0). Limits cumulative probability of tokens considered.
stream boolean no Whether to stream the response. Defaults to false.

groq_list_messages

List messages in a Groq Cloud conversation. Returns message content, role, and metadata for each message in the conversation.

Operation
Read read
Full name
groq.groq_list_messages
ParameterTypeRequiredDescription
conversation_id string yes The conversation ID to list messages for.
limit integer no Maximum number of messages to return per page (default: 20).
after string no Cursor for pagination — message ID to start after.

groq_create_message

Create a message in a Groq Cloud conversation. Send a message with a specified role and content to a conversation.

Operation
Write write
Full name
groq.groq_create_message
ParameterTypeRequiredDescription
conversation_id string yes The conversation ID to add the message to.
role string yes The role of the message author (e.g., "user", "assistant").
content string yes The text content of the message.

groq_list_files

List files uploaded to the Groq Files API. Returns file IDs, filenames, purposes, sizes, and upload timestamps.

Operation
Read read
Full name
groq.groq_list_files
ParameterTypeRequiredDescription
purpose string no Filter files by purpose (e.g., "batch").
limit integer no Maximum number of files to return per page (default: 20).
after string no Cursor for pagination — file ID to start after.

groq_get_file

Get metadata for an uploaded file in Groq, including its ID, filename, purpose, size in bytes, and processing status.

Operation
Read read
Full name
groq.groq_get_file
ParameterTypeRequiredDescription
file_id string yes The file identifier (e.g., "file-abc123").

groq_get_current_user

Get information about the currently authenticated Groq user, including user ID, email, and organization details.

Operation
Read read
Full name
groq.groq_get_current_user
ParameterTypeRequiredDescription
No parameters.