OpenAI CLI

CLI commands for OpenAI provider

Diagram

Input

Agent

Output

OpenAI CLI Commands

Manage and test OpenAI provider via the command line.

Environment Setup

bash
export OPENAI_API_KEY=sk-...

Commands

Check Provider Status

bash
praisonai-ts providers doctor openai

Output:

Provider Doctor: openai

  Package: @ai-sdk/openai
  Description: OpenAI GPT models
  Environment Variable: OPENAI_API_KEY
  Status: ✅ Ready
  Key Preview: sk-p...xxxx

  Modalities:
    Text/Chat: ✅  Embeddings: ✅  Image: ✅
    Audio: ✅  Speech: ✅  Tools: ✅

JSON Output

bash
praisonai-ts providers doctor openai --json

Output:

json
{
  "success": true,
  "data": {
    "provider": "openai",
    "env_key": "OPENAI_API_KEY",
    "has_key": true,
    "key_preview": "sk-p...xxxx",
    "package": "@ai-sdk/openai",
    "description": "OpenAI GPT models",
    "modalities": {
      "text": true,
      "chat": true,
      "embeddings": true,
      "image": true,
      "audio": true,
      "speech": true,
      "tools": true
    },
    "status": "ready"
  }
}

Test Provider

bash
praisonai-ts providers test openai gpt-4o-mini

Output:

ℹ Testing openai/gpt-4o-mini...

  ✅ Test Passed
  Provider: openai
  Model: gpt-4o-mini
  Latency: 1523ms
  Response: "Test ok."

Test with JSON Output

bash
praisonai-ts providers test openai gpt-4o-mini --json

Output:

json
{
  "success": true,
  "data": {
    "provider": "openai",
    "model": "gpt-4o-mini",
    "status": "success",
    "latency_ms": 1523,
    "response_preview": "Test ok."
  }
}

Chat with OpenAI

bash
praisonai-ts chat "What is 2+2?" --provider openai --model gpt-4o-mini

List All Providers

bash
praisonai-ts providers list

Advanced Usage

Custom Base URL (Proxy)

bash
export OPENAI_BASE_URL=https://my-proxy.example.com/v1
praisonai-ts providers test openai gpt-4o-mini

As of PR #4505, the same OPENAI_BASE_URL is honoured in the SDK’s env-only path too — an Agent built without an explicit baseURL picks it up on the next call. See JS Credential Rotation.

With Organization ID

bash
export OPENAI_ORG_ID=org-xxxxx
praisonai-ts providers test openai gpt-4o

Verbose Output

bash
praisonai-ts providers doctor openai --verbose

Options Reference

OptionDescription
--jsonOutput in JSON format
--verboseShow detailed information
--model <model>Specify model for test

Troubleshooting

Missing API Key

Status: ❌ Missing API Key

Solution:

bash
export OPENAI_API_KEY=sk-your-key-here

Connection Error

Error: Network error

Solution: Check your internet connection and any proxy settings.

Invalid Model

Error: Model not found

Solution: Use a valid model name like gpt-4o-mini, gpt-4o, or gpt-4-turbo.

Related