I built an Application using ChatGPT with less than 15 lines of code!

Arthi Rajendran
6 min readDec 30, 2022


If you are hearing the name “ChatGPT” for the very first time, please check out my previous article.

Natural language processing (NLP) is a field of computer science that focuses on the interaction between computers and human (natural) language. It involves analyzing and understanding text and speech and can be used in a variety of applications, such as language translation, text summarization, and chatbots.

In this article, we will explore how to use ChatGPT’s API to build your own NLP tools.

ChatGPT is a large-scale language model developed by OpenAI that can generate human-like text based on a prompt or conversation. It is trained on a vast amount of data, making it capable of generating coherent and diverse responses.

Photo by Asterfolio on Unsplash

How to use ChatGPT’s API:

To use ChatGPT’s API, you will need to sign up for an API key on the OpenAI website. Once you have obtained your API key, you can use the API to send a prompt to ChatGPT and receive a response.

Here is an example of how to use ChatGPT’s API in Python:

import openai
openai.api_key = "your_api_key_here"

def generate_response(prompt):
completions = openai.Completion.create(
message = completions.choices[0].text
return message

prompt = "What is natural language processing?"
response = generate_response(prompt)

In the example above, we are using the openai.Completion.create() function to send a prompt to ChatGPT and receive a response. We can customize the response by adjusting the parameters of the function, such as the temperature and top_p values. The temperature value determines the creativity of the response, with a higher value resulting in more creative and varied responses, and a lower value resulting in more predictable responses. The top_p value determines the probability that the response will be taken from the most likely choices, with a higher value resulting in more predictable responses and a lower value resulting in more varied responses.

Simple tools that you can create using ChatGPT

Now that we have a basic understanding of how to use ChatGPT’s API, let’s explore some potential applications of ChatGPT in NLP.

One possible use of ChatGPT is in building chatbots.

Chatbots are computer programs designed to simulate conversation with human users, often through messaging apps, websites, or mobile apps. By using ChatGPT’s API, you can create a chatbot that can generate human-like responses to user input. This can be useful for customer service, FAQs, and other applications where a chatbot can provide quick and accurate responses to user inquiries.

Another potential application of ChatGPT is in language translation.

By sending a prompt in one language to ChatGPT and receiving a response in another language, you can create a simple translation tool. This could be useful for individuals or organizations looking to communicate with people in different languages.

There are many other potential applications of ChatGPT and NLP in general. For example, you could use NLP to build a text summarization tool, which can automatically condense long texts into shorter summaries. You could also use NLP to analyze sentiment in social media posts or customer reviews or to identify named entities in a text (such as people, organizations, and locations).

Overall, NLP is a rapidly growing field with a wide range of applications, and ChatGPT’s API is a powerful tool that can help you build your own NLP tools. Whether you are a developer, data scientist, or simply interested in NLP, ChatGPT’s API is worth exploring & (even earn money if you will 😉).

Photo by Alexander Mils on Unsplash

Building my own Application using ChatGPT


Have you ever found yourself struggling to write Python code for a specific task or algorithm, but just can’t seem to get the syntax right? Or maybe you’re new to Python and want to learn how to code by seeing examples of working code. In either case, the Python Code Generator tool can help.

Using OpenAI’s API, this tool allows you to input an English prompt describing the task or algorithm you want to implement in Python, and it will generate Python code for you. This can save you time and frustration trying to figure out the correct syntax, and can also serve as a learning tool by allowing you to see how Python code is written for different tasks.

Python Code Generator — Will it replace StackOverflow?

Demo generated by the Author

As you can see it generates a Python code that implements the Linear regression from the scratch

In case you want to use any specific package,

Demo generated by the Author

You can even enter any errors that you might have encountered using the prompt suffix “Fix”. Look at the example below:

Demo generated by the Author

It returned the following response:

#There are a few ways to fix this error, depending on what you are trying to do.
#One way is to install the lifelines package using pip:

pip install lifelines

#Alternatively, if you are using Anaconda, you can install lifelines using conda:

conda install -c conda-forge lifelines

#If you are trying to import lifelines into a Python script or Jupyter notebook, you will need to add the following line at the top of your code:

import sys

You get the idea!

The Python Code Generator is a useful tool for anyone who wants to save time and frustration when writing Python code, or for those who want to learn Python by seeing examples of working code. With the help of OpenAI’s API, this tool can generate Python code for a wide variety of tasks and algorithms, making it a valuable resource for Python developers of all levels.

Now, will it ever replace Stackoverflow?

It is unlikely that ChatGPT, or any other language model, will replace StackOverflow or any other online programming resource. While language models like ChatGPT can provide helpful information and assistance with programming tasks, they are not a replacement for the knowledge and expertise of human programmers and developers.

StackOverflow is a popular online platform for programmers to ask and answer questions, share knowledge, and discuss programming topics. It is a valuable resource for programmers of all skill levels to find solutions to problems and learn from the experiences of others. Language models like ChatGPT can provide additional support and guidance, but they cannot fully replace the human element of programming and problem-solving.

But, unlike StackOverflow, you needn’t dig through so many comments to find the right answer. ChatGPT gives you one solid response.

What are your thoughts? Let me know in the comments.

The Source code for the Python Code Generator Tool is available on my GitHub: https://github.com/arthi-rajendran-DS/Medium-Implementations

In this article, we have explored how to use ChatGPT’s API to build your own NLP tools. ChatGPT is a powerful language model developed by OpenAI that can generate human-like text based on a prompt or conversation. By using ChatGPT’s API, you can create a variety of NLP tools, such as chatbots and language translation tools.

Note: ChatGPT’s API is a paid service and requires an API key to use. Make sure to read the terms of service and pricing information on the OpenAI website before using the API.

Thanks for sticking around until the end. Visit me on my Linkedin to have a more in-depth conversation or any questions.



Arthi Rajendran

A Data Scientist, who is passionate about Healthcare, Data & Machine Learning.