/openai Command

The /openai command allows you to interact with OpenAI’s powerful language models using your own API key. You can send prompts to models like GPT-3.5 Turbo, GPT-4o, and GPT-4o Mini to generate responses, analyze messages, and more.

Available Subcommands

/openai ask

Send a prompt to OpenAI and get a response.

Usage

/openai ask prompt: <your prompt> model: [GPT-3.5 Turbo|GPT-4o|GPT-4o Mini] max_tokens: [value]

Options

OptionDescriptionRequiredPlatform
promptYour prompt to send to OpenAIYesDiscord & Slack
modelThe model to use (default: GPT-3.5 Turbo)NoDiscord (parameter), Slack (flag)
max_tokensMaximum tokens in the response (default: 500)NoDiscord (parameter), Slack (flag)

Example

/openai ask prompt: Write a short poem about programming in Python model: GPT-4o

/openai explain (Discord only)

Analyze a message in the conversation by using OpenAI models. You need to provide the ID of the message you want to analyze.

Note: The explain command is currently only available on Discord and not implemented in Slack, despite being mentioned in the help message.

Usage

/openai explain message_id: <message_id> instruction: [instruction] model: [GPT-3.5 Turbo|GPT-4o|GPT-4o Mini] max_tokens: [value]

Options

OptionDescriptionRequiredPlatform
message_idID of the message to analyzeYesDiscord
instructionInstructions for analyzing the message (default: “Explain this message in detail:“)NoDiscord
modelThe model to use (default: GPT-3.5 Turbo)NoDiscord (parameter)
max_tokensMaximum tokens in the response (default: 500)NoDiscord (parameter)

Examples

/openai explain message_id: 1234567890123456789 instruction: Please explain what this code does and suggest improvements

How to get a message ID

To get a message ID in Discord:

  1. Enable Developer Mode in Discord Settings > Advanced
  2. Right-click on any message
  3. Select “Copy ID” from the menu
  4. Use this ID with the explain command

Output Format

The response appears as a Discord embed with:

  • Title: “Analysis of Message”
  • Description: The AI’s analysis of the referenced message
  • Fields:
    • Original Message: Truncated content of the referenced message (up to 300 characters)
    • From: Username or nickname of the message author
    • Model: The AI model used for analysis
  • Footer: “Powered by OpenAI”
  • Timestamp: When the analysis was generated

/openai setkey

Set your OpenAI API key (encrypted and private).

Usage

/openai setkey key: <your_openai_api_key>

Options

OptionDescriptionRequiredPlatform
keyYour OpenAI API key (will remain private)YesDiscord (parameter), Slack

Example

/openai setkey key: sk-...your-api-key...

/openai status

Check if you have an API key set.

Usage

/openai status

Supported Models

The /openai command supports the following models:

ModelDescriptionUse Case
GPT-3.5 TurboGood for most everyday tasksGeneral purpose chat, simple coding tasks, explanations
GPT-4oMost capable model, higher costComplex reasoning, advanced code generation, detailed analysis
GPT-4o MiniSmaller, faster version of GPT-4oGood balance of capability and speed

How It Works

The OpenAI command uses your personal OpenAI API key to send requests to OpenAI’s API. Your API key is encrypted before being stored and is only decrypted when needed to make API calls.

  1. You set your OpenAI API key using the /openai setkey command
  2. The key is encrypted and stored securely
  3. When you use /openai ask or /openai explain, the bot:
    • Decrypts your API key
    • Sends your prompt to OpenAI
    • Returns the generated response in a formatted embed

Platform-Specific Implementations

Discord Implementation

  • Commands use Discord’s slash command parameter system with named parameters (e.g., prompt:, model:)
  • Supports both ask and explain commands
  • The explain command requires a message ID to identify which message to analyze
  • Responses are formatted as embeds with prompt and model information
  • All operations happen directly in the chat where the command is invoked

Slack Implementation

  • Commands use flags for optional parameters (e.g., --model gpt-4o, --max_tokens 1000)
  • The prompt comes before any flags
  • Currently only supports ask, setkey, and status commands
  • The explain command mentioned in the help is not currently implemented
  • Responses use Slack Block Kit for rich formatting with sections for prompt and response

Notes

  • Your API key is encrypted and only used when you invoke the command
  • Using this command will consume tokens from your OpenAI account
  • Be aware of OpenAI’s rate limits and quota limitations
  • Your prompts and OpenAI’s responses are visible in the channel where you use the command

Common Errors

ErrorExplanation
Invalid API KeyYour API key is incorrect or has been revoked
Insufficient QuotaYour OpenAI account has reached its quota limit
Rate LimitYou’ve hit OpenAI’s rate limit, wait and try again
Context LengthYour prompt is too long for the selected model
Service UnavailableOpenAI’s service is temporarily unavailable