├── requirements.txt ├── Dowload_OAI_API_Checker.exe_file.txt ├── README.md └── OAI_API_Checker.py /requirements.txt: -------------------------------------------------------------------------------- 1 | openai==0.27.4 2 | requests==2.28.2 3 | colorama==0.4.6 4 | -------------------------------------------------------------------------------- /Dowload_OAI_API_Checker.exe_file.txt: -------------------------------------------------------------------------------- 1 | I have moved the OAI_API_Checker.exe from github itself to external drive (Proton Drive) in order to save space on your PC (I was retarder and was committing binary files) 2 | Now you can download the OAI_API_Checker.exe here: 3 | https://drive.proton.me/urls/4T2QGJFBGM#fW0YsN9WskCG 4 | https://drive.proton.me/urls/4T2QGJFBGM#fW0YsN9WskCG 5 | https://drive.proton.me/urls/4T2QGJFBGM#fW0YsN9WskCG 6 | https://drive.proton.me/urls/4T2QGJFBGM#fW0YsN9WskCG 7 | https://drive.proton.me/urls/4T2QGJFBGM#fW0YsN9WskCG 8 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # OAI API Checker 2 | ## Program that allows you to check all the available information about your OAI API keys 3 | 4 | !!**Out of date for now, use kkc instead in the meantime: https://github.com/CncAnon1/kkc**!! 5 | 6 | **Download**: OAI_API_Checker.exe - https://drive.proton.me/urls/4T2QGJFBGM#fW0YsN9WskCG 7 | 8 | Basically, you put in one or an array of keys and the program analyzes them for you. 9 | 10 | It prints out what models are available for the key and if it is out of quota or not. It will also store the gpt-4 and turbo keys in their respective .txt files in the folder where you run the program. 11 | 12 | Program is pretty fast and reliable. Just in case, the program will generate a .log file where all debug info will be stored. Feel free to send them to me in case of bugs and errors (buhankoanon@proton.me). 13 | 14 | In this repository, you can find a a link to compiled .exe file of the program (all necessary libraries included), as well as a source Python code. 15 | 16 | In order to run the source Python code, you will need Python, pip and modules such as openai, requests, colorama. 17 | -------------------------------------------------------------------------------- /OAI_API_Checker.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import openai 3 | import requests 4 | from datetime import datetime, timedelta 5 | import sys 6 | import time 7 | import threading 8 | from concurrent.futures import ThreadPoolExecutor 9 | import colorama 10 | import logging 11 | from math import ceil 12 | 13 | colorama.init() 14 | 15 | logging.basicConfig(filename='OAI_API_Checker_logs.log', level=logging.DEBUG, format='%(asctime)s %(levelname)s: %(message)s', datefmt='%Y-%m-%d %H:%M:%S') 16 | 17 | def log_and_print(message, log_level=logging.INFO): 18 | print(message) 19 | logging.log(log_level, message) 20 | 21 | def list_models(api_key): 22 | openai.api_key = api_key 23 | models = openai.Model.list() 24 | return [model.id for model in models['data']] 25 | 26 | def filter_models(models, desired_models): 27 | return [model for model in models if model in desired_models] 28 | 29 | def try_complete(api_key): 30 | openai.api_key = api_key 31 | response = openai.ChatCompletion.create( 32 | model="gpt-3.5-turbo", 33 | max_tokens=1, 34 | messages=[{'role':'user', 'content': ''}] 35 | ) 36 | 37 | RED = "\033[31m" 38 | YELLOW = "\033[33m" 39 | #GREEN = "\033[32m" 40 | #BLINK = "\033[5m" 41 | RESET = "\033[0m" 42 | 43 | def check_key(api_key, retry_count=3): 44 | result = f"{api_key}\n" 45 | has_gpt_4_32k = False 46 | model_ids = [] 47 | errors = [] 48 | 49 | models = list_models(api_key) 50 | filtered_models = filter_models(models, desired_models) 51 | 52 | if filtered_models: 53 | for model_id in filtered_models: 54 | result += f" - {model_id}\n" 55 | model_ids.append(model_id) 56 | else: 57 | result += " No desired models available.\n" 58 | 59 | has_gpt_4 = "gpt-4" in model_ids 60 | has_gpt_4_32k = "gpt-4-32k" in model_ids 61 | has_only_turbo = "gpt-3.5-turbo" in model_ids and not has_gpt_4 62 | 63 | try: 64 | for attempts in range(retry_count): 65 | try: 66 | try_complete(api_key) 67 | break 68 | except Exception as e: 69 | error_message = str(e) 70 | if "The server is overloaded or not ready yet" in error_message: 71 | logging.info(f'Error encountered when generating a completion on attempt {attempts+1}: {error_message}. Retrying...') 72 | time.sleep(5) 73 | continue 74 | else: 75 | raise e 76 | 77 | except Exception as e: 78 | error_message = str(e) 79 | if "You exceeded your current quota" in error_message: 80 | result += f"{YELLOW} This key has exceeded its current quota{RESET}\n" 81 | elif "Your account is not active" in error_message: 82 | result += f"{RED} Error: Your account is not active, please check your billing details on our website.{RESET}\n" 83 | else: 84 | result += f"{RED} Unexpected Error at check_key: {error_message}{RESET}\n" 85 | errors.append((api_key, error_message)) 86 | 87 | return result, has_gpt_4, has_gpt_4_32k, has_only_turbo, errors 88 | 89 | def checkkeys(api_keys): 90 | working_gpt_4_keys = set() 91 | no_quota_gpt_4_keys = set() 92 | working_gpt_4_32k_keys = set() 93 | no_quota_gpt_4_32k_keys = set() 94 | working_only_turbo_keys = set() 95 | no_quota_only_turbo_keys = set() 96 | result = '' 97 | total_errors = [] 98 | with ThreadPoolExecutor(max_workers=100) as executor: 99 | futures = [executor.submit(check_key, api_key) for api_key in api_keys] 100 | 101 | for idx, future in enumerate(futures, start=1): 102 | result += f"API Key {idx}:\n" 103 | key = api_keys[idx - 1] 104 | try: 105 | key_result, has_gpt_4, has_gpt_4_32k, has_only_turbo, errors = future.result() 106 | total_errors.extend(errors) 107 | 108 | result += key_result 109 | 110 | if has_only_turbo and "Error" not in key_result and "This key has exceeded its current quota" not in key_result and "This key is invalid or revoked" not in key_result: 111 | working_only_turbo_keys.add(key) 112 | if has_gpt_4 and not has_gpt_4_32k and "Error" not in key_result and "This key has exceeded its current quota" not in key_result and "This key is invalid or revoked" not in key_result: 113 | working_gpt_4_keys.add(key) 114 | if has_gpt_4_32k and "Error" not in key_result and "This key has exceeded its current quota" not in key_result and "This key is invalid or revoked" not in key_result: 115 | working_gpt_4_32k_keys.add(key) 116 | 117 | if has_only_turbo and "This key has exceeded its current quota" in key_result: 118 | no_quota_only_turbo_keys.add(key) 119 | if has_gpt_4 and "This key has exceeded its current quota" in key_result: 120 | no_quota_gpt_4_keys.add(key) 121 | if has_gpt_4_32k and "This key has exceeded its current quota" in key_result: 122 | no_quota_gpt_4_32k_keys.add(key) 123 | 124 | except Exception as e: 125 | error_message = str(e) 126 | if "Incorrect API key provided" in error_message: 127 | result += f"{key}\n" 128 | result += f"{RED} This key is invalid or revoked{RESET}\n" 129 | elif "You must be a member of an organization to use the API" in error_message: 130 | result += f"{key}\n" 131 | result += f"{RED} Error: You must be a member of an organization to use the API. Please contact us through our help center at help.openai.com.{RESET}\n" 132 | elif "This key is associated with a deactivated account" in error_message: 133 | result += f"{key}\n" 134 | result += f"{RED} Error: This key is associated with a deactivated account. If you feel this is an error, contact us through our help center at help.openai.com.{RESET}\n" 135 | else: 136 | result += f"{RED} Unexpected Error at checkkeys: {error_message}{RESET}\n" 137 | total_errors.append((api_keys[idx - 1], error_message)) 138 | result += '\n' 139 | 140 | with open('turbo.txt', 'w') as f: 141 | if len(working_only_turbo_keys) > 0: 142 | f.write('Working API keys with GPT-3.5-Turbo model:\n') 143 | f.write('\n'.join(working_only_turbo_keys) + '\n\n') 144 | if len(no_quota_only_turbo_keys) > 0: 145 | f.write('Valid API keys with GPT-3.5-Turbo model and no quota left:\n') 146 | f.write('\n'.join(no_quota_only_turbo_keys) + '\n\n') 147 | 148 | with open('gpt4.txt', 'w') as f: 149 | if len(working_gpt_4_32k_keys) > 0: 150 | f.write('Working API keys with GPT-4-32k model:\n') 151 | f.write('\n'.join(working_gpt_4_32k_keys) + '\n\n') 152 | if len(no_quota_gpt_4_32k_keys) > 0: 153 | f.write('Valid API keys with GPT-4-32k model and no quota left:\n') 154 | f.write('\n'.join(no_quota_gpt_4_32k_keys) + '\n\n') 155 | if len(working_gpt_4_keys) > 0: 156 | f.write('Working API keys with GPT-4 model:\n') 157 | f.write('\n'.join(working_gpt_4_keys) + '\n\n') 158 | if len(no_quota_gpt_4_keys) > 0: 159 | f.write('Valid API keys with GPT-4 model and no quota left:\n') 160 | f.write('\n'.join(no_quota_gpt_4_keys) + '\n\n') 161 | 162 | with open('unexpected_errors.txt', 'w') as f: 163 | for i, (api_key, error) in enumerate(total_errors, start=1): 164 | f.write(f"Error #{i}:\n") 165 | f.write(f"API Key: {api_key}\n") 166 | f.write(f"Error Message: {error}\n\n") 167 | 168 | result += f"\nNumber of working API keys with only 'gpt-3.5-turbo' model: {len(working_only_turbo_keys)}\n" 169 | for key in working_only_turbo_keys: 170 | result += f"{key}\n" 171 | result += f"\nNumber of working API keys with 'gpt-4' model: {len(working_gpt_4_keys)}\n" 172 | for key in working_gpt_4_keys: 173 | result += f"{key}\n" 174 | result += f"\nNumber of working API keys with 'gpt-4-32k' model: {len(working_gpt_4_32k_keys)}\n" 175 | for key in working_gpt_4_32k_keys: 176 | result += f"{key}\n" 177 | result += f"\nNumber of valid API keys with only 'gpt-3.5-turbo' model and NO quota left: {len(no_quota_only_turbo_keys)}\n" 178 | for key in no_quota_only_turbo_keys: 179 | result += f"{key}\n" 180 | result += f"\nNumber of valid API keys with 'gpt-4' model and NO quota left: {len(no_quota_gpt_4_keys)}\n" 181 | for key in no_quota_gpt_4_keys: 182 | result += f"{key}\n" 183 | result += f"\nNumber of valid API keys with 'gpt-4-32k' model and NO quota left: {len(no_quota_gpt_4_32k_keys)}\n" 184 | for key in no_quota_gpt_4_32k_keys: 185 | result += f"{key}\n" 186 | 187 | return result 188 | 189 | def animate_processing_request(): 190 | while not processing_done: 191 | sys.stdout.write("\rProcessing... |") 192 | time.sleep(0.1) 193 | sys.stdout.write("\rProcessing... /") 194 | time.sleep(0.1) 195 | sys.stdout.write("\rProcessing... -") 196 | time.sleep(0.1) 197 | sys.stdout.write("\rProcessing... \\") 198 | time.sleep(0.1) 199 | sys.stdout.write("\rDone! \n") 200 | 201 | if __name__ == '__main__': 202 | api_keys = [] 203 | desired_models = ["gpt-3.5-turbo", "gpt-4", "gpt-4-32k"] 204 | log_and_print("Enter the API keys (one key per line). Press Enter twice when you're done:") 205 | while True: 206 | try: 207 | api_key = input() 208 | except: 209 | break 210 | 211 | if not api_key: 212 | break 213 | api_keys.append(api_key.strip()) 214 | 215 | processing_done = False 216 | animation_thread = threading.Thread(target=animate_processing_request) 217 | animation_thread.start() 218 | 219 | result = checkkeys(api_keys) 220 | 221 | processing_done = True 222 | animation_thread.join() 223 | 224 | log_and_print("\n" + result) 225 | 226 | input("Press Enter to exit...") --------------------------------------------------------------------------------