OpenAI
Documentation for the /openai command to interact with OpenAI models
/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
Options
Option | Description | Required | Platform |
---|---|---|---|
prompt | Your prompt to send to OpenAI | Yes | Discord & Slack |
model | The model to use (default: GPT-3.5 Turbo) | No | Discord (parameter), Slack (flag) |
max_tokens | Maximum tokens in the response (default: 500) | No | Discord (parameter), Slack (flag) |
Example
/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
Options
Option | Description | Required | Platform |
---|---|---|---|
message_id | ID of the message to analyze | Yes | Discord |
instruction | Instructions for analyzing the message (default: “Explain this message in detail:“) | No | Discord |
model | The model to use (default: GPT-3.5 Turbo) | No | Discord (parameter) |
max_tokens | Maximum tokens in the response (default: 500) | No | Discord (parameter) |
Examples
How to get a message ID
To get a message ID in Discord:
- Enable Developer Mode in Discord Settings > Advanced
- Right-click on any message
- Select “Copy ID” from the menu
- 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
Options
Option | Description | Required | Platform |
---|---|---|---|
key | Your OpenAI API key (will remain private) | Yes | Discord (parameter), Slack |
Example
/openai status
Check if you have an API key set.
Usage
Supported Models
The /openai
command supports the following models:
Model | Description | Use Case |
---|---|---|
GPT-3.5 Turbo | Good for most everyday tasks | General purpose chat, simple coding tasks, explanations |
GPT-4o | Most capable model, higher cost | Complex reasoning, advanced code generation, detailed analysis |
GPT-4o Mini | Smaller, faster version of GPT-4o | Good 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.
- You set your OpenAI API key using the
/openai setkey
command - The key is encrypted and stored securely
- 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
andexplain
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
, andstatus
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
Error | Explanation |
---|---|
Invalid API Key | Your API key is incorrect or has been revoked |
Insufficient Quota | Your OpenAI account has reached its quota limit |
Rate Limit | You’ve hit OpenAI’s rate limit, wait and try again |
Context Length | Your prompt is too long for the selected model |
Service Unavailable | OpenAI’s service is temporarily unavailable |