Loading...
Loading...
Official OpenAI CLI for interacting with the OpenAI REST API from the command line
npx skill4agent add aradotso/devtools-skills openai-cliSkill by ara.so — Devtools Skills collection.
brew install openai/tools/openaigo install 'github.com/openai/openai-cli/cmd/openai@latest'export PATH="$PATH:$(go env GOPATH)/bin"git clone https://github.com/openai/openai-cli.git
cd openai-cli
./scripts/run args...export OPENAI_API_KEY="sk-..."
export OPENAI_ADMIN_KEY="sk-admin-..." # For admin endpoints
export OPENAI_ORG_ID="org-..." # Optional
export OPENAI_PROJECT_ID="proj_..." # Optionalopenai --api-key sk-... responses create --input "Hello"| Variable | Purpose | Required |
|---|---|---|
| Standard API authentication | For standard endpoints |
| Admin API authentication | For admin endpoints |
| Organization identifier | No |
| Project identifier | No |
| Webhook verification | No |
openai [resource] <command> [flags...]openai responses create \
--input "Explain quantum computing in simple terms" \
--model gpt-4openai responses create \
--input "Write a poem about coding" \
--model gpt-4 \
--streamopenai responses create \
--input "What is recursion?" \
--model gpt-4 \
--system "You are a computer science teacher" \
--temperature 0.7openai files create \
--file @training_data.jsonl \
--purpose fine-tuneopenai files listopenai files retrieve file-abc123openai files delete file-abc123openai embeddings create \
--input "The quick brown fox" \
--model text-embedding-3-smallopenai embeddings create \
--input "First text" \
--input "Second text" \
--model text-embedding-3-largeopenai fine-tuning jobs create \
--training-file file-abc123 \
--model gpt-3.5-turboopenai fine-tuning jobs listopenai fine-tuning jobs retrieve ftjob-abc123openai fine-tuning jobs cancel ftjob-abc123openai admin:organization:usage completions \
--start-time 1735689600 \
--end-time 1735776000 \
--bucket-width 1d@openai responses create --arg @input.txtopenai <command> --arg '{image: "@image.jpg"}'openai <command> <<YAML
arg:
image: "@abe.jpg"
YAMLopenai <command> --arg @file://myfile.txtopenai <command> --arg @data://image.pngopenai <command> --arg @file:///tmp/file.txt@openai <command> --username '\@username'--format# Pretty-printed (default for TTY)
openai responses create --input "Hello" --format pretty
# Raw JSON
openai responses create --input "Hello" --format json
# JSONL (one JSON object per line)
openai responses create --input "Hello" --format jsonl
# YAML
openai responses create --input "Hello" --format yaml
# Raw response body
openai responses create --input "Hello" --format raw# Get just the message content
openai responses create \
--input "Hello" \
--transform "choices.0.message.content"
# Get multiple fields
openai responses create \
--input "Hello" \
--transform "{id: id, content: choices.0.message.content}"openai responses create \
--input "Hello" \
--format-error json \
--transform-error "error.message"--api-key # API key (or use OPENAI_API_KEY)
--admin-api-key # Admin key (or use OPENAI_ADMIN_KEY)
--organization # Org ID (or use OPENAI_ORG_ID)
--project # Project ID (or use OPENAI_PROJECT_ID)
--base-url # Custom API endpoint
--debug # Enable debug logging with HTTP details
--version, -v # Show CLI version
--help # Show help for command
--format # Output format (auto, explore, json, jsonl, pretty, raw, yaml)
--format-error # Error output format
--transform # GJSON transform for data output
--transform-error # GJSON transform for error outputwhile true; do
read -p "You: " input
openai responses create \
--input "$input" \
--model gpt-4 \
--format pretty
donewhile IFS= read -r line; do
openai responses create \
--input "$line" \
--model gpt-3.5-turbo \
--format json >> results.jsonl
done < inputs.txtopenai responses create \
--input "Translate to French" \
--model gpt-4 \
--max-tokens 100 \
--temperature 0.3echo "Summarize this text" | openai responses create \
--input "$(cat)" \
--model gpt-4cat document.txt | openai responses create \
--input "Summarize: $(cat -)" \
--model gpt-4openai responses create \
--input '{text: "What is in this image?", image: "@photo.jpg"}' \
--model gpt-4-vision-previewopenai --base-url https://custom.openai.azure.com/v1 \
responses create \
--input "Hello" \
--model gpt-4openai --debug responses create --input "Test"echo $PATH | grep "$(go env GOPATH)/bin"
# If not found:
export PATH="$PATH:$(go env GOPATH)/bin"echo $OPENAI_API_KEY
# Should output: sk-...openai responses create --input "test" --model gpt-3.5-turbo# Absolute path
openai files create --file @/full/path/to/file.jsonl --purpose fine-tune
# Verify file exists
ls -la @file.jsonlfor i in {1..10}; do
openai responses create --input "Request $i"
sleep 1
doneopenai models listopenai responses create --input "Hello" --format jsonopenai responses create --input "Hello" --format pretty | less# Link to specific version
./scripts/link github.com/openai/openai-go@v1.2.3
# Link to local SDK copy
./scripts/link ../openai-go
# Default (../openai-go)
./scripts/linkopenai --version
# or
openai -vopenai --help
openai responses --help
openai responses create --help