productivity
Groq Lua API for KosmoKrator Agents
Agent-facing Lua documentation and function reference for the Groq KosmoKrator integration.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.
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
Groq workflow without starting an interactive agent session.
kosmo integrations:lua --eval 'dump(app.integrations.groq.list_models({}))' --json kosmo integrations:lua --eval 'print(docs.read("groq"))' --json
kosmo integrations:lua --eval 'print(docs.read("groq.list_models"))' --json Workflow file
Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.
local groq = app.integrations.groq
local result = groq.list_models({})
dump(result) kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json integrations:lua exposes app.integrations.groq, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.groq.default.* or app.integrations.groq.work.* when you configured named credential accounts.
MCP-only Lua
If the script only needs configured MCP servers and does not need Groq, 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.
Groq Lua API Reference
Groq exposes OpenAI-compatible inference endpoints plus Groq-specific batch, file, and closed-beta fine-tuning APIs.
Namespace: app.integrations["groq"]
Common Usage
Use chat completions for normal conversational requests:
local result = app.integrations["groq"].create_completion({
model = "llama-3.3-70b-versatile",
messages = {
{ role = "system", content = "You are concise." },
{ role = "user", content = "Summarize this paragraph." }
},
temperature = 0.2,
max_tokens = 120
})
print(result.choices[1].message.content)
Use payload-based tools when the upstream endpoint has a richer request body:
local response = app.integrations["groq"].create_response({
payload = {
model = "openai/gpt-oss-20b",
input = "Draft a release note."
}
})
local transcription = app.integrations["groq"].create_transcription({
payload = {
model = "whisper-large-v3",
url = "https://example.test/audio/sample.wav",
response_format = "json"
}
})
For local audio or batch file uploads, use file_path inside the payload or as the file upload argument. The path must be readable by the host running the integration.
Tool Groups
Models and Inference
list_models({})get_model({ model = "llama-3.3-70b-versatile" })create_completion({ model = "...", messages = {...}, temperature = 0.2 })create_response({ payload = {...} })
Audio
create_transcription({ payload = { model = "whisper-large-v3", url = "https://example.test/audio.wav" } })create_translation({ payload = { model = "whisper-large-v3", file_path = "/tmp/audio.wav" } })create_speech({ payload = { model = "playai-tts", voice = "...", input = "Text to speak" } })
Speech and downloaded file content may return non-JSON bodies as:
{
content_type = "audio/wav",
body_base64 = "..."
}
Batches and Files
upload_file({ file_path = "/tmp/batch.jsonl", purpose = "batch" })list_files({ purpose = "batch" })get_file({ file_id = "file_123" })download_file({ file_id = "file_123" })delete_file({ file_id = "file_123" })create_batch({ payload = { input_file_id = "file_123", endpoint = "/v1/chat/completions", completion_window = "24h" } })list_batches({ query = { limit = 20 } })get_batch({ batch_id = "batch_123" })cancel_batch({ batch_id = "batch_123" })
Fine Tuning
Groq fine tuning is a closed beta API. These tools expose the documented endpoints, but accounts without access will receive Groq API authorization or availability errors.
list_fine_tunings({})create_fine_tuning({ payload = { input_file_id = "file_123", name = "test-1", type = "lora", base_model = "llama-3.1-8b-instant" } })get_fine_tuning({ id = "fine_tune_123" })delete_fine_tuning({ id = "fine_tune_123" })
Removed Legacy Assumptions
The previous package exposed conversation message and current-user tools for endpoints that are not documented in Groq’s current API reference. They are no longer registered in the provider. Use chat completions or responses with explicit message history, and use list_models for a lightweight credential check.
Return Shapes
Most tools return Groq’s decoded JSON response unchanged so agents can access endpoint-specific fields like choices, usage, data, request_counts, file metadata, and fine-tuning job objects.
Multi-Account Usage
app.integrations["groq"].list_models({})
app.integrations["groq"].default.list_models({})
app.integrations["groq"].work.list_models({})
All accounts expose the same tool names. Only credentials and optional base URL differ.
Raw agent markdown
# Groq Lua API Reference
Groq exposes OpenAI-compatible inference endpoints plus Groq-specific batch, file, and closed-beta fine-tuning APIs.
Namespace: `app.integrations["groq"]`
## Common Usage
Use chat completions for normal conversational requests:
```lua
local result = app.integrations["groq"].create_completion({
model = "llama-3.3-70b-versatile",
messages = {
{ role = "system", content = "You are concise." },
{ role = "user", content = "Summarize this paragraph." }
},
temperature = 0.2,
max_tokens = 120
})
print(result.choices[1].message.content)
```
Use payload-based tools when the upstream endpoint has a richer request body:
```lua
local response = app.integrations["groq"].create_response({
payload = {
model = "openai/gpt-oss-20b",
input = "Draft a release note."
}
})
local transcription = app.integrations["groq"].create_transcription({
payload = {
model = "whisper-large-v3",
url = "https://example.test/audio/sample.wav",
response_format = "json"
}
})
```
For local audio or batch file uploads, use `file_path` inside the payload or as the file upload argument. The path must be readable by the host running the integration.
## Tool Groups
### Models and Inference
- `list_models({})`
- `get_model({ model = "llama-3.3-70b-versatile" })`
- `create_completion({ model = "...", messages = {...}, temperature = 0.2 })`
- `create_response({ payload = {...} })`
### Audio
- `create_transcription({ payload = { model = "whisper-large-v3", url = "https://example.test/audio.wav" } })`
- `create_translation({ payload = { model = "whisper-large-v3", file_path = "/tmp/audio.wav" } })`
- `create_speech({ payload = { model = "playai-tts", voice = "...", input = "Text to speak" } })`
Speech and downloaded file content may return non-JSON bodies as:
```lua
{
content_type = "audio/wav",
body_base64 = "..."
}
```
### Batches and Files
- `upload_file({ file_path = "/tmp/batch.jsonl", purpose = "batch" })`
- `list_files({ purpose = "batch" })`
- `get_file({ file_id = "file_123" })`
- `download_file({ file_id = "file_123" })`
- `delete_file({ file_id = "file_123" })`
- `create_batch({ payload = { input_file_id = "file_123", endpoint = "/v1/chat/completions", completion_window = "24h" } })`
- `list_batches({ query = { limit = 20 } })`
- `get_batch({ batch_id = "batch_123" })`
- `cancel_batch({ batch_id = "batch_123" })`
### Fine Tuning
Groq fine tuning is a closed beta API. These tools expose the documented endpoints, but accounts without access will receive Groq API authorization or availability errors.
- `list_fine_tunings({})`
- `create_fine_tuning({ payload = { input_file_id = "file_123", name = "test-1", type = "lora", base_model = "llama-3.1-8b-instant" } })`
- `get_fine_tuning({ id = "fine_tune_123" })`
- `delete_fine_tuning({ id = "fine_tune_123" })`
## Removed Legacy Assumptions
The previous package exposed conversation message and current-user tools for endpoints that are not documented in Groq's current API reference. They are no longer registered in the provider. Use chat completions or responses with explicit message history, and use `list_models` for a lightweight credential check.
## Return Shapes
Most tools return Groq's decoded JSON response unchanged so agents can access endpoint-specific fields like `choices`, `usage`, `data`, `request_counts`, file metadata, and fine-tuning job objects.
## Multi-Account Usage
```lua
app.integrations["groq"].list_models({})
app.integrations["groq"].default.list_models({})
app.integrations["groq"].work.list_models({})
```
All accounts expose the same tool names. Only credentials and optional base URL differ. local result = app.integrations.groq.list_models({})
print(result) Functions
list_models Read
List available Groq AI models. Returns model IDs, ownership, and other metadata for models accessible via the Groq API.
- Lua path
app.integrations.groq.list_models- Full name
groq.groq_list_models
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_model Read
Retrieve a Groq model by ID.
- Lua path
app.integrations.groq.get_model- Full name
groq.groq_get_model
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_chat_completion Write
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.
- Lua path
app.integrations.groq.create_chat_completion- Full name
groq.groq_create_completion
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
create_response Write
Create a response through Groq beta Responses API.
- Lua path
app.integrations.groq.create_response- Full name
groq.groq_create_response
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_transcription Write
Transcribe audio with Groq.
- Lua path
app.integrations.groq.create_transcription- Full name
groq.groq_create_transcription
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_translation Write
Translate audio into English with Groq.
- Lua path
app.integrations.groq.create_translation- Full name
groq.groq_create_translation
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_speech Write
Generate speech audio from text.
- Lua path
app.integrations.groq.create_speech- Full name
groq.groq_create_speech
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_batch Write
Create a batch job from an uploaded JSONL file.
- Lua path
app.integrations.groq.create_batch- Full name
groq.groq_create_batch
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_batch Read
Retrieve a batch job by ID.
- Lua path
app.integrations.groq.get_batch- Full name
groq.groq_get_batch
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_batches Read
List Groq batch jobs.
- Lua path
app.integrations.groq.list_batches- Full name
groq.groq_list_batches
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
cancel_batch Write
Cancel a Groq batch job.
- Lua path
app.integrations.groq.cancel_batch- Full name
groq.groq_cancel_batch
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
upload_file Write
Upload a file for batch processing.
- Lua path
app.integrations.groq.upload_file- Full name
groq.groq_upload_file
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_files Read
List files uploaded to the Groq Files API. Returns file IDs, filenames, purposes, sizes, and upload timestamps.
- Lua path
app.integrations.groq.list_files- Full name
groq.groq_list_files
| Parameter | Type | Required | Description |
|---|---|---|---|
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. |
get_file Read
Get metadata for an uploaded file in Groq, including its ID, filename, purpose, size in bytes, and processing status.
- Lua path
app.integrations.groq.get_file- Full name
groq.groq_get_file
| Parameter | Type | Required | Description |
|---|---|---|---|
file_id | string | yes | The file identifier (e.g., "file-abc123"). |
download_file Read
Download Groq file content.
- Lua path
app.integrations.groq.download_file- Full name
groq.groq_download_file
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_file Write
Delete an uploaded Groq file.
- Lua path
app.integrations.groq.delete_file- Full name
groq.groq_delete_file
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
list_fine_tunings Read
List Groq fine-tuning jobs.
- Lua path
app.integrations.groq.list_fine_tunings- Full name
groq.groq_list_fine_tunings
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
create_fine_tuning Write
Create a Groq fine-tuning job.
- Lua path
app.integrations.groq.create_fine_tuning- Full name
groq.groq_create_fine_tuning
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
get_fine_tuning Read
Retrieve a Groq fine-tuning job.
- Lua path
app.integrations.groq.get_fine_tuning- Full name
groq.groq_get_fine_tuning
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||
delete_fine_tuning Write
Delete a Groq fine-tuning job.
- Lua path
app.integrations.groq.delete_fine_tuning- Full name
groq.groq_delete_fine_tuning
| Parameter | Type | Required | Description |
|---|---|---|---|
| No parameters. | |||