KosmoKrator

ai

OpenAI CLI for AI Agents

Use the OpenAI CLI from KosmoKrator to call OpenAI tools headlessly, return JSON, inspect schemas, and automate workflows from coding agents, scripts, and CI.

15 functions 5 read 10 write API key auth

OpenAI CLI Setup

OpenAI can be configured headlessly with `kosmokrator integrations:configure openai`.

# Install KosmoKrator first if it is not available on PATH.
curl -fsSL https://raw.githubusercontent.com/OpenCompanyApp/kosmokrator/main/install.sh | bash

# Configure and verify this integration.
kosmokrator integrations:configure openai --set api_key="$OPENAI_API_KEY" --enable --read allow --write ask --json
kosmokrator integrations:doctor openai --json
kosmokrator integrations:status --json

Credentials

Authentication type: API key api_key. Configure credentials once, then use the same stored profile from scripts, coding CLIs, Lua code mode, and the MCP gateway.

KeyEnv varTypeRequiredLabel
api_key OPENAI_API_KEY Secret secret yes API Key

Call OpenAI Headlessly

Use the generic call form when another coding CLI or script needs a stable universal interface.

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

Use the provider shortcut form for shorter human-facing commands.

kosmo integrations: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

Agent Discovery Commands

These commands return structured output for coding agents that need to inspect capabilities 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

All CLI Functions

Every function below can be called headlessly. The generic form is stable across all integrations; the provider shortcut is shorter but specific to OpenAI.

openai.openai_chat_completion

Write write

Generate a chat completion using OpenAI GPT models. Send a conversation as an array of messages with role and content.

Parameters
model, messages, temperature, max_tokens, top_p, frequency_penalty, presence_penalty, response_format

Generic CLI call

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

Provider shortcut

kosmo integrations: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

openai.openai_create_embedding

Write write

Generate an embedding vector for text input using OpenAI embedding models.

Parameters
model, input

Generic CLI call

kosmo integrations:call openai.openai_create_embedding '{"model":"example_model","input":"example_input"}' --json

Provider shortcut

kosmo integrations:openai openai_create_embedding '{"model":"example_model","input":"example_input"}' --json

openai.openai_create_image

Write write

Generate an image from a text prompt using DALL·E.

Parameters
model, prompt, n, size, quality, style, response_format

Generic CLI call

kosmo integrations:call openai.openai_create_image '{"model":"example_model","prompt":"example_prompt","n":1,"size":"example_size","quality":"example_quality","style":"example_style","response_format":"example_response_format"}' --json

Provider shortcut

kosmo integrations:openai openai_create_image '{"model":"example_model","prompt":"example_prompt","n":1,"size":"example_size","quality":"example_quality","style":"example_style","response_format":"example_response_format"}' --json

openai.openai_transcribe_audio

Write write

Transcribe audio into text using OpenAI Whisper. Supports MP3, MP4, WAV, M4A, and WEBM audio files.

Parameters
file_content, filename, model, language, response_format

Generic CLI call

kosmo integrations:call openai.openai_transcribe_audio '{"file_content":"example_file_content","filename":"example_filename","model":"example_model","language":"example_language","response_format":"example_response_format"}' --json

Provider shortcut

kosmo integrations:openai openai_transcribe_audio '{"file_content":"example_file_content","filename":"example_filename","model":"example_model","language":"example_language","response_format":"example_response_format"}' --json

openai.openai_text_to_speech

Write write

Generate speech audio from text using OpenAI TTS. Returns base64-encoded audio content.

Parameters
model, input, voice, speed, response_format

Generic CLI call

kosmo integrations:call openai.openai_text_to_speech '{"model":"example_model","input":"example_input","voice":"example_voice","speed":1,"response_format":"example_response_format"}' --json

Provider shortcut

kosmo integrations:openai openai_text_to_speech '{"model":"example_model","input":"example_input","voice":"example_voice","speed":1,"response_format":"example_response_format"}' --json

openai.openai_create_assistant

Write write

Create an OpenAI assistant with a model, name, instructions, and optional tools.

Parameters
model, name, description, instructions, tools

Generic CLI call

kosmo integrations:call openai.openai_create_assistant '{"model":"example_model","name":"example_name","description":"example_description","instructions":"example_instructions","tools":"example_tools"}' --json

Provider shortcut

kosmo integrations:openai openai_create_assistant '{"model":"example_model","name":"example_name","description":"example_description","instructions":"example_instructions","tools":"example_tools"}' --json

openai.openai_list_assistants

Read read

List all OpenAI assistants available to the authenticated user.

Parameters
limit

Generic CLI call

kosmo integrations:call openai.openai_list_assistants '{"limit":1}' --json

Provider shortcut

kosmo integrations:openai openai_list_assistants '{"limit":1}' --json

openai.openai_create_thread

Write write

Create a conversation thread for the OpenAI Assistants API. Optionally include initial messages.

Parameters
messages

Generic CLI call

kosmo integrations:call openai.openai_create_thread '{"messages":"example_messages"}' --json

Provider shortcut

kosmo integrations:openai openai_create_thread '{"messages":"example_messages"}' --json

openai.openai_add_message_to_thread

Write write

Add a message to an existing conversation thread.

Parameters
thread_id, role, content

Generic CLI call

kosmo integrations:call openai.openai_add_message_to_thread '{"thread_id":"example_thread_id","role":"example_role","content":"example_content"}' --json

Provider shortcut

kosmo integrations:openai openai_add_message_to_thread '{"thread_id":"example_thread_id","role":"example_role","content":"example_content"}' --json

openai.openai_list_thread_messages

Read read

List messages in an OpenAI conversation thread.

Parameters
thread_id, limit

Generic CLI call

kosmo integrations:call openai.openai_list_thread_messages '{"thread_id":"example_thread_id","limit":1}' --json

Provider shortcut

kosmo integrations:openai openai_list_thread_messages '{"thread_id":"example_thread_id","limit":1}' --json

openai.openai_create_run

Write write

Start an assistant run on a thread. Returns the run with its initial status.

Parameters
thread_id, assistant_id, instructions

Generic CLI call

kosmo integrations:call openai.openai_create_run '{"thread_id":"example_thread_id","assistant_id":"example_assistant_id","instructions":"example_instructions"}' --json

Provider shortcut

kosmo integrations:openai openai_create_run '{"thread_id":"example_thread_id","assistant_id":"example_assistant_id","instructions":"example_instructions"}' --json

openai.openai_get_run

Read read

Get the status and details of an assistant run on a thread.

Parameters
thread_id, run_id

Generic CLI call

kosmo integrations:call openai.openai_get_run '{"thread_id":"example_thread_id","run_id":"example_run_id"}' --json

Provider shortcut

kosmo integrations:openai openai_get_run '{"thread_id":"example_thread_id","run_id":"example_run_id"}' --json

openai.openai_upload_file

Write write

Upload a file to OpenAI for use with Assistants, Fine-tuning, or Batch API.

Parameters
file_content, filename, purpose

Generic CLI call

kosmo integrations:call openai.openai_upload_file '{"file_content":"example_file_content","filename":"example_filename","purpose":"example_purpose"}' --json

Provider shortcut

kosmo integrations:openai openai_upload_file '{"file_content":"example_file_content","filename":"example_filename","purpose":"example_purpose"}' --json

openai.openai_list_files

Read read

List files uploaded to OpenAI, optionally filtered by purpose.

Parameters
purpose, limit

Generic CLI call

kosmo integrations:call openai.openai_list_files '{"purpose":"example_purpose","limit":1}' --json

Provider shortcut

kosmo integrations:openai openai_list_files '{"purpose":"example_purpose","limit":1}' --json

openai.openai_list_models

Read read

List all models available from OpenAI, including GPT, DALL·E, Whisper, and embedding models.

Parameters
none

Generic CLI call

kosmo integrations:call openai.openai_list_models '{}' --json

Provider shortcut

kosmo integrations:openai openai_list_models '{}' --json

Function Schemas

Use these parameter tables when building CLI payloads without calling integrations:schema first.

openai.openai_chat_completion

Generate a chat completion using OpenAI GPT models. Send a conversation as an array of messages with role and content.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_chat_completion --json
ParameterTypeRequiredDescription
model string yes Model ID (e.g., "gpt-4o", "gpt-4o-mini", "gpt-4-turbo").
messages array yes Array of message objects, each with "role" (system, user, assistant) and "content".
temperature number no Sampling temperature between 0 and 2. Higher values produce more random output.
max_tokens integer no Maximum number of tokens to generate in the response.
top_p number no Nucleus sampling parameter. Use temperature or top_p, but not both.
frequency_penalty number no Penalty for frequent tokens (-2.0 to 2.0).
presence_penalty number no Penalty for new tokens (-2.0 to 2.0).
response_format object no Response format, e.g. {"type": "json_object"} for JSON output.

openai.openai_create_embedding

Generate an embedding vector for text input using OpenAI embedding models.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_create_embedding --json
ParameterTypeRequiredDescription
model string yes Embedding model ID (e.g., "text-embedding-3-small", "text-embedding-3-large").
input string yes Text string or array of strings to embed.

openai.openai_create_image

Generate an image from a text prompt using DALL·E.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_create_image --json
ParameterTypeRequiredDescription
model string no Model ID (e.g., "dall-e-3", "dall-e-2"). Default: "dall-e-2".
prompt string yes Text description of the desired image.
n integer no Number of images to generate (1-10 for DALL·E 2, only 1 for DALL·E 3).
size string no Image size: "256x256", "512x512", "1024x1024", "1024x1792", "1792x1024".
quality string no Image quality: "standard" or "hd" (DALL·E 3 only).
style string no Image style: "vivid" or "natural" (DALL·E 3 only).
response_format string no Response format: "url" or "b64_json".

openai.openai_transcribe_audio

Transcribe audio into text using OpenAI Whisper. Supports MP3, MP4, WAV, M4A, and WEBM audio files.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_transcribe_audio --json
ParameterTypeRequiredDescription
file_content string yes Base64-encoded audio file content.
filename string yes Filename with extension (e.g., "audio.mp3", "recording.wav").
model string yes Model to use for transcription (e.g., "whisper-1").
language string no ISO 639-1 language code (e.g., "en", "fr", "de").
response_format string no Output format: "json", "text", "srt", "verbose_json", "vtt".

openai.openai_text_to_speech

Generate speech audio from text using OpenAI TTS. Returns base64-encoded audio content.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_text_to_speech --json
ParameterTypeRequiredDescription
model string yes TTS model ID (e.g., "tts-1", "tts-1-hd").
input string yes Text to convert to speech (max 4096 characters).
voice string yes Voice to use: "alloy", "echo", "fable", "onyx", "nova", or "shimmer".
speed number no Speed of speech (0.25 to 4.0). Default: 1.0.
response_format string no Audio format: "mp3", "opus", "aac", "flac", "wav". Default: "mp3".

openai.openai_create_assistant

Create an OpenAI assistant with a model, name, instructions, and optional tools.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_create_assistant --json
ParameterTypeRequiredDescription
model string yes Model ID (e.g., "gpt-4o").
name string no Name of the assistant.
description string no Description of the assistant.
instructions string no System instructions for the assistant.
tools array no Array of tool objects the assistant can use (e.g., code_interpreter, file_search).

openai.openai_list_assistants

List all OpenAI assistants available to the authenticated user.

Operation
Read read
Schema command
kosmo integrations:schema openai.openai_list_assistants --json
ParameterTypeRequiredDescription
limit integer no Number of assistants to return (default 20, max 100).

openai.openai_create_thread

Create a conversation thread for the OpenAI Assistants API. Optionally include initial messages.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_create_thread --json
ParameterTypeRequiredDescription
messages array no Initial messages for the thread. Each message has "role" and "content".

openai.openai_add_message_to_thread

Add a message to an existing conversation thread.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_add_message_to_thread --json
ParameterTypeRequiredDescription
thread_id string yes The ID of the thread to add the message to.
role string yes Role of the message sender: "user" or "assistant".
content string yes Text content of the message.

openai.openai_list_thread_messages

List messages in an OpenAI conversation thread.

Operation
Read read
Schema command
kosmo integrations:schema openai.openai_list_thread_messages --json
ParameterTypeRequiredDescription
thread_id string yes The ID of the thread to list messages from.
limit integer no Number of messages to return (default 20, max 100).

openai.openai_create_run

Start an assistant run on a thread. Returns the run with its initial status.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_create_run --json
ParameterTypeRequiredDescription
thread_id string yes The ID of the thread to run the assistant on.
assistant_id string yes The ID of the assistant to use for this run.
instructions string no Override the assistant's default instructions for this run.

openai.openai_get_run

Get the status and details of an assistant run on a thread.

Operation
Read read
Schema command
kosmo integrations:schema openai.openai_get_run --json
ParameterTypeRequiredDescription
thread_id string yes The ID of the thread.
run_id string yes The ID of the run to check.

openai.openai_upload_file

Upload a file to OpenAI for use with Assistants, Fine-tuning, or Batch API.

Operation
Write write
Schema command
kosmo integrations:schema openai.openai_upload_file --json
ParameterTypeRequiredDescription
file_content string yes Base64-encoded file content.
filename string yes Filename with extension (e.g., "data.jsonl", "document.txt").
purpose string yes Purpose of the file: "assistants", "assistants_output", "batch", "fine-tune", "vision".

openai.openai_list_files

List files uploaded to OpenAI, optionally filtered by purpose.

Operation
Read read
Schema command
kosmo integrations:schema openai.openai_list_files --json
ParameterTypeRequiredDescription
purpose string no Filter by purpose: "assistants", "assistants_output", "batch", "fine-tune", "vision".
limit integer no Number of files to return (default 20, max 10000).

openai.openai_list_models

List all models available from OpenAI, including GPT, DALL·E, Whisper, and embedding models.

Operation
Read read
Schema command
kosmo integrations:schema openai.openai_list_models --json
ParameterTypeRequiredDescription
No parameters.

Permissions

Headless calls still follow the integration read/write permission policy. Configure read/write defaults with integrations:configure. Add --force only for trusted automation that should bypass that policy.