data
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.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 reuse the same stored profile from scripts, coding CLIs, Lua, and MCP.
| Key | Env var | Type | Required | Label |
|---|---|---|---|---|
api_key | OPENAI_API_KEY | Secret secret | yes | API Key |
Command Patterns
The generic command is stable across every integration. The provider shortcut is shorter for humans.
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 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 Discovery
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 Automation Contexts
The same configured command surface works in these environments. The command does not change unless the host wrapper, credentials, or permissions change.
CLI Functions
Every function below can be called headlessly. Commands are highlighted, copyable, and scroll horizontally when payloads are long.
openai.openai_chat_completion
Generate a chat completion using OpenAI GPT models. Send a conversation as an array of messages with role and content.
write - Parameters
- model, messages, temperature, max_tokens, top_p, frequency_penalty, presence_penalty, response_format
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 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
Generate an embedding vector for text input using OpenAI embedding models.
write - Parameters
- model, input
kosmo integrations:call openai.openai_create_embedding '{"model":"example_model","input":"example_input"}' --json kosmo integrations:openai openai_create_embedding '{"model":"example_model","input":"example_input"}' --json openai.openai_create_image
Generate an image from a text prompt using DALL·E.
write - Parameters
- model, prompt, n, size, quality, style, response_format
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 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
Transcribe audio into text using OpenAI Whisper. Supports MP3, MP4, WAV, M4A, and WEBM audio files.
write - Parameters
- file_content, filename, model, language, response_format
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 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
Generate speech audio from text using OpenAI TTS. Returns base64-encoded audio content.
write - Parameters
- model, input, voice, speed, response_format
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 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
Create an OpenAI assistant with a model, name, instructions, and optional tools.
write - Parameters
- model, name, description, instructions, tools
kosmo integrations:call openai.openai_create_assistant '{"model":"example_model","name":"example_name","description":"example_description","instructions":"example_instructions","tools":"example_tools"}' --json 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
List all OpenAI assistants available to the authenticated user.
read - Parameters
- limit
kosmo integrations:call openai.openai_list_assistants '{"limit":1}' --json kosmo integrations:openai openai_list_assistants '{"limit":1}' --json openai.openai_create_thread
Create a conversation thread for the OpenAI Assistants API. Optionally include initial messages.
write - Parameters
- messages
kosmo integrations:call openai.openai_create_thread '{"messages":"example_messages"}' --json kosmo integrations:openai openai_create_thread '{"messages":"example_messages"}' --json openai.openai_add_message_to_thread
Add a message to an existing conversation thread.
write - Parameters
- thread_id, role, content
kosmo integrations:call openai.openai_add_message_to_thread '{"thread_id":"example_thread_id","role":"example_role","content":"example_content"}' --json 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
List messages in an OpenAI conversation thread.
read - Parameters
- thread_id, limit
kosmo integrations:call openai.openai_list_thread_messages '{"thread_id":"example_thread_id","limit":1}' --json kosmo integrations:openai openai_list_thread_messages '{"thread_id":"example_thread_id","limit":1}' --json openai.openai_create_run
Start an assistant run on a thread. Returns the run with its initial status.
write - Parameters
- thread_id, assistant_id, instructions
kosmo integrations:call openai.openai_create_run '{"thread_id":"example_thread_id","assistant_id":"example_assistant_id","instructions":"example_instructions"}' --json kosmo integrations:openai openai_create_run '{"thread_id":"example_thread_id","assistant_id":"example_assistant_id","instructions":"example_instructions"}' --json openai.openai_get_run
Get the status and details of an assistant run on a thread.
read - Parameters
- thread_id, run_id
kosmo integrations:call openai.openai_get_run '{"thread_id":"example_thread_id","run_id":"example_run_id"}' --json kosmo integrations:openai openai_get_run '{"thread_id":"example_thread_id","run_id":"example_run_id"}' --json openai.openai_upload_file
Upload a file to OpenAI for use with Assistants, Fine-tuning, or Batch API.
write - Parameters
- file_content, filename, purpose
kosmo integrations:call openai.openai_upload_file '{"file_content":"example_file_content","filename":"example_filename","purpose":"example_purpose"}' --json kosmo integrations:openai openai_upload_file '{"file_content":"example_file_content","filename":"example_filename","purpose":"example_purpose"}' --json openai.openai_list_files
List files uploaded to OpenAI, optionally filtered by purpose.
read - Parameters
- purpose, limit
kosmo integrations:call openai.openai_list_files '{"purpose":"example_purpose","limit":1}' --json kosmo integrations:openai openai_list_files '{"purpose":"example_purpose","limit":1}' --json openai.openai_list_models
List all models available from OpenAI, including GPT, DALL·E, Whisper, and embedding models.
read - Parameters
- none
kosmo integrations:call openai.openai_list_models '{}' --json 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 8 parameters
kosmo integrations:schema openai.openai_chat_completion --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 2 parameters
kosmo integrations:schema openai.openai_create_embedding --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 7 parameters
kosmo integrations:schema openai.openai_create_image --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 5 parameters
kosmo integrations:schema openai.openai_transcribe_audio --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 5 parameters
kosmo integrations:schema openai.openai_text_to_speech --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 5 parameters
kosmo integrations:schema openai.openai_create_assistant --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 1 parameters
kosmo integrations:schema openai.openai_list_assistants --json | Parameter | Type | Required | Description |
|---|---|---|---|
limit | integer | no | Number of assistants to return (default 20, max 100). |
openai.openai_create_thread 1 parameters
kosmo integrations:schema openai.openai_create_thread --json | Parameter | Type | Required | Description |
|---|---|---|---|
messages | array | no | Initial messages for the thread. Each message has "role" and "content". |
openai.openai_add_message_to_thread 3 parameters
kosmo integrations:schema openai.openai_add_message_to_thread --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 2 parameters
kosmo integrations:schema openai.openai_list_thread_messages --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 3 parameters
kosmo integrations:schema openai.openai_create_run --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 2 parameters
kosmo integrations:schema openai.openai_get_run --json | Parameter | Type | Required | Description |
|---|---|---|---|
thread_id | string | yes | The ID of the thread. |
run_id | string | yes | The ID of the run to check. |
openai.openai_upload_file 3 parameters
kosmo integrations:schema openai.openai_upload_file --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 2 parameters
kosmo integrations:schema openai.openai_list_files --json | Parameter | Type | Required | Description |
|---|---|---|---|
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 0 parameters
kosmo integrations:schema openai.openai_list_models --json | Parameter | Type | Required | Description |
|---|---|---|---|
| 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.