ai
OpenAI CLI for Cron Jobs
Use the OpenAI CLI for cron jobs with headless JSON commands, schema discovery, credentials, and permission controls.
15 functions 5 read 10 write API key auth
OpenAI CLI for Cron Jobs
Schedule repeatable integration workflows from cron while keeping credentials in KosmoKrator config.
Use the headless CLI from cron when an operation should run without an interactive agent session. The OpenAI CLI uses the same integration registry as the TUI, Lua runtime, and MCP gateway, but returns predictable command output for automation.
Command Shape
# OpenAI CLI for Cron Jobs
kosmokrator integrations:configure openai --set api_key="$OPENAI_API_KEY" --enable --read allow --write ask --json
kosmo integrations:call openai.openai_chat_completion '{"model":"example_model","messages":"example_messages","temperature":1,"max_tokens":1,"top_p":1,"frequency_penalty":1,"presence_penalty":1,"response_format":"example_response_format"}' --json Discovery Before Execution
Agents and scripts can inspect OpenAI docs and schemas before choosing a function.
kosmo integrations:docs openai --json
kosmo integrations:docs openai.openai_chat_completion --json
kosmo integrations:schema openai.openai_chat_completion --json
kosmo integrations:search "OpenAI" --json
kosmo integrations:list --json Useful OpenAI CLI Functions
| Function | Type | Parameters | Description |
|---|---|---|---|
openai.openai_chat_completion | Write | model, messages, temperature, max_tokens, top_p, frequency_penalty, presence_penalty, response_format | Generate a chat completion using OpenAI GPT models. Send a conversation as an array of messages with role and content. |
openai.openai_create_embedding | Write | model, input | Generate an embedding vector for text input using OpenAI embedding models. |
openai.openai_create_image | Write | model, prompt, n, size, quality, style, response_format | Generate an image from a text prompt using DALL·E. |
openai.openai_transcribe_audio | Write | file_content, filename, model, language, response_format | Transcribe audio into text using OpenAI Whisper. Supports MP3, MP4, WAV, M4A, and WEBM audio files. |
openai.openai_text_to_speech | Write | model, input, voice, speed, response_format | Generate speech audio from text using OpenAI TTS. Returns base64-encoded audio content. |
openai.openai_create_assistant | Write | model, name, description, instructions, tools | Create an OpenAI assistant with a model, name, instructions, and optional tools. |
openai.openai_list_assistants | Read | limit | List all OpenAI assistants available to the authenticated user. |
openai.openai_create_thread | Write | messages | Create a conversation thread for the OpenAI Assistants API. Optionally include initial messages. |
openai.openai_add_message_to_thread | Write | thread_id, role, content | Add a message to an existing conversation thread. |
openai.openai_list_thread_messages | Read | thread_id, limit | List messages in an OpenAI conversation thread. |
openai.openai_create_run | Write | thread_id, assistant_id, instructions | Start an assistant run on a thread. Returns the run with its initial status. |
openai.openai_get_run | Read | thread_id, run_id | Get the status and details of an assistant run on a thread. |
openai.openai_upload_file | Write | file_content, filename, purpose | Upload a file to OpenAI for use with Assistants, Fine-tuning, or Batch API. |
openai.openai_list_files | Read | purpose, limit | List files uploaded to OpenAI, optionally filtered by purpose. |
openai.openai_list_models | Read | none | List all models available from OpenAI, including GPT, DALL·E, Whisper, and embedding models. |
Automation Notes
- Use
--jsonfor machine-readable output. - Keep credentials out of argv by using environment variables or stored KosmoKrator configuration.
- Configure read/write policy before unattended runs; use
--forceonly for trusted automation. - Use the MCP gateway instead when the agent needs dynamic tool discovery inside a conversation.