r/PowerShell • • Apr 08 '23

ShellGPT - A PowerShell Module for the APIs of OpenAI

Hei everyone

While trying to get a grasp of OpenAI's publicly available APIs, I stitched together a set of PowerShell functions that provide a simple interface for accessing OpenAI's GPT API endpoints that I wanted to share.

I called this Module "ShellGPT" and it is available on Github: https://github.com/yamautomate/ShellGPT

With it, you can generate natural language text, translate text, summarize articles, create images, create fine-tuned models, feed text-files, PDFs, .JSONs and more.

It provides a straightforward syntax for calling the API and handling the response, making it easy to integrate GPT into your PowerShell scripts. This means you can now leverage the power of OpenAI's GPT language model directly from PowerShell and your scripts and runbooks.

It is far from perfect but does the job.

Feel free to raise issues, clone, fork or contribute :)

PS: I think I need to rename it. There seem to be some other ShellGPTs...

120 Upvotes

18 comments sorted by

9

u/atinylittleshell Apr 08 '23

In case you are thinking about renaming to PowerGPT - that's also there already :D https://github.com/ouromoros/PowerGPT (not mine).

12

u/yamautomate Apr 08 '23

I initially named it PowerGPT and renamed to ShellGPT because of that repo xD

5

u/[deleted] Apr 08 '23

As far as actual modules go, that repo is pretty awful. It would not pass muster if submitted to PSGallery.

0

u/[deleted] Apr 09 '23

[deleted]

6

u/NegativeC00L Apr 09 '23

From the guy that brought us Import-Excel

8

u/Sin_of_the_Dark Apr 08 '23

PSGPT sounds catchy if you're still iffy on the name. This is some good work.

2

u/yamautomate Apr 09 '23

I think that will be it! Thanks. Hopefully I can rename it in time before some1 else claims that šŸ˜†

4

u/MechAming Apr 08 '23

Is it free to use chatgpt api? If so that's awesome. Hopefully it will stay that way.

5

u/yamautomate Apr 09 '23

AFAIK you get a certain amount of credits free of charge. Like 18$ you can spend on requests for free. Then, you pay based on your token usage. Iā€˜m at 3$ used out of those 18$, so it lasts a bit :)

1

u/TheRealZero Apr 09 '23

There is also an expiration date on the $18 though! Luckily gpt3.5-turbo is relatively cheap. :)

4

u/Bissquitt Apr 08 '23

No. I believe its only free in the web interface, not api and even then you are limited to a certain amount of requests.

2

u/mrmattipants Apr 09 '23

Thanks for the heads-up! Much appreciated.

2

u/Kathiey Apr 10 '23

Looks interesting! Will try it.

1

u/Prior-Advertising208 Dec 02 '23

I installed this the other night but I need to change the API key and I don't know how to get back to that option. Could someone please help or direct me to a tutorial for changing the api_key?

1

u/appositereboot Jan 04 '24

Is there a way to get ShellGPT to use the $OPENAI_API_KEY environment variable instead of setting it at the start of each session?

1

u/_Aurelios Jan 13 '24

gedit ~/.config/shell_gpt/.sgptrc and add your key