-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdelete_all_assistants.sh
39 lines (32 loc) · 1.06 KB
/
delete_all_assistants.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
# Function to fetch and delete assistants
delete_all_assistants() {
# Get the list of assistants
echo "Fetching list of assistants..."
response=$(curl -s -X GET "https://api.openai.com/v1/assistants" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2")
echo $response
# Check if the response contains assistants
assistants=$(echo "$response" | jq -r '.data[] | .id')
if [[ -z "$assistants" ]]; then
echo "No assistants found to delete."
exit 0
fi
# Iterate over each assistant and delete it
echo "Deleting assistants..."
for assistant_id in $assistants; do
echo "Deleting assistant ID: $assistant_id"
curl -s -X DELETE "https://api.openai.com/v1/assistants/$assistant_id" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "OpenAI-Beta: assistants=v2"
done
echo "All assistants deleted."
}
# Check if jq is installed
if ! command -v jq &> /dev/null; then
echo "Error: jq is not installed. Please install jq to use this script."
exit 1
fi
# Run the function
delete_all_assistants