How to use ChatGPT plugins
ChatGPT plugins, first enable plugins in your ChatGPT settings and select the desired plugins from the plugin store. Then, interact with the model specifying plugin-enabled conversations via the API or ChatGPT interface to access extended capabilities.PREREQUISITES
OpenAI account with ChatGPT Plus or Enterprise accessAPI key with plugin access enabledPython 3.8+pip install openai>=1.0
Setup
Enable plugins in your ChatGPT account settings under the "Beta features" section. Install the openai Python package with pip install openai. Set your API key as an environment variable OPENAI_API_KEY to authenticate requests.
pip install openai>=1.0 Step by step
Use the OpenAI Python SDK to create a chat completion request with plugin-enabled messages. Specify the model that supports plugins (e.g., gpt-4o with plugins enabled) and include plugin calls in the conversation. Below is a minimal example to call a plugin-enabled ChatGPT session.
import os
from openai import OpenAI
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
messages = [
{"role": "system", "content": "You are a helpful assistant with plugin access."},
{"role": "user", "content": "Find me the latest news about AI."}
]
response = client.chat.completions.create(
model="gpt-4o",
messages=messages,
plugins=["news-plugin"] # Example plugin identifier
)
print(response.choices[0].message.content) Latest AI news: [Plugin response with current headlines]
Common variations
You can use async calls with the OpenAI SDK for better performance or stream plugin responses for real-time output. Different models like gpt-4o or gemini-1.5-pro may support different plugins. Adjust the plugins parameter accordingly.
import asyncio
import os
from openai import OpenAI
async def main():
client = OpenAI(api_key=os.environ["OPENAI_API_KEY"])
messages = [
{"role": "system", "content": "You are a helpful assistant with plugin access."},
{"role": "user", "content": "Get weather updates for New York City."}
]
response = await client.chat.completions.acreate(
model="gpt-4o",
messages=messages,
plugins=["weather-plugin"]
)
print(response.choices[0].message.content)
asyncio.run(main()) Current weather in New York City: Sunny, 72°F
Troubleshooting
- If you get an "Unauthorized" error, verify your API key and plugin access permissions.
- If plugins do not respond, ensure they are enabled in your ChatGPT settings and the plugin ID is correct.
- For rate limits, check your OpenAI usage dashboard and upgrade your plan if needed.
Key Takeaways
- Enable plugins in ChatGPT settings before using them via API or UI.
- Use the OpenAI SDK with the correct model and plugin identifiers to call plugins.
- Async and streaming calls improve responsiveness for plugin-enabled chats.
- Check API key permissions and plugin enablement if you encounter errors.