How to convert GPT-3 prompts into code

OpenAI provides a no code web based interface called Playground to interact with the GPT-3 API without writing any code. It enables you to prompt the GPT-3 API right in the browser.

It’s good place to try and see how the GPT-3 API works and arrive at a good enough prompt that works for your case.

But once you are done with that, you need to convert the prompt into code so that use it programmiticvally, whether in automation or in GPT-3 enabled product.

In this article, I am going to show you how to use the OpenAI Playground to convert the prompts into code.

Table of Contents

Playground to Code

This is how a prompt looks like in the OpenAI Playground

GPT-3 Playground

But, what if you want the same prompt wrapped in some code to use in your app?

You can get Python Code equivalent for the GPT-3 prompt by clicking on the Export Code “<>” button right in the Playground

GPT-3 Playground Python Code

Get the cURL command also right from the Playground too.

GPT-3 Playground cURL command

You can run this from your command line program.

But what if you needed Node/JavaScript Code for prompting GPT-3 API?

Well, you can take the cURL command code you got from the Playground(see the previous tweet) and drop it in a “cURL to code” converter tool and get the JavaScript code
GPT-3 Prompt - JavaScript

You can also do this for other language like R, PHP, Go, Rust, etc.

Do you want to prompt GPT-3 from those languages? Check out the cURL to Code converter tool to do these conversions.

Conclusion

Going from writing a prompt in GPT-3 playground to calling that prompt right from your code is easy. We can use various tools provided by OpenAI or 3rd party to convert the prompts into code.

Happy prompting!