Learn how to use ChatGPT's prompt portal and API, whether you're new to AI or trying to build your first chatbot.
Version 1.2.0: Updated outline to split documentation into three overall parts with introduction.
- ChatGPT, and AI in general, is less like C-3PO and more like a bunch of well-meaning worms doing their best.
- After a high-level introduction, this guide divides into sections for just using the prompt portal in Part A and then using the actual API in Part B. Part C is a reference for all users.
- AI is only as good as the data it's trained on. The better and more specific your prompt and parameters, the more helpful ChatGPT can be.
- Avoid sharing any private or sensitive data. Assume that everything you write to ChatGPT will eventually be hacked and printed somewhere on the Internet.
The goal of this open-source guide is to establish foundational knowledge of ChatGPT and basic concepts behind AI and machine learning. This could be your first-ever guide to ChatGPT, whether you've never touched code before and are only using the popular chat functionality or a developer using the API to build your first ChatGPT app.
The saying is already cliche, and it's true: AI will probably not take your job, but it will change your job.
NOTE: For the sake of simplicity and accessibility, we're using GPT-3. GPT-4 is available but only in beta. This guide will be updated once GPT-4 and future versions are more widely available.
IMPORTANT: Be mindful of everything you send to ChatGPT. Do not share private information that you would not want ChatGPT to remember and store. Assume that everything you write to ChatGPT will eventually be hacked and printed somewhere else on the Internet.
I. Introduction
- Overview of ChatGPT
- How You Can Use ChatGPT
- Metaphors For What ChatGPT Can (and Can't) Do
II. Getting Started (Prompt Portal)
- Step-by-Step Guide
- Writing Your First Prompt
- The Art of a Good Prompt
III. Examples of ChatGPT Prompts
- General Learning, Troubleshooting, Or Brainstorming
- Editing, Summarizing, and Translating Text
- Creating Your Own Study Guide
- Generating Project Ideas
- Preparing Your Resume For A Specific Application
- Preparing For A Job Interview
- Working In Excel
- Writing Shell (Linux) Commands
- Writing Git Commands
- Improving Code & Getting Feedback
- Extracting Data
- Generating Dummy Data
- Generating Documentation
- Understanding and Fixing Errors
- Writing Tests
- Building An API
- Natural Language Programming
- Python Examples
- HTML, CSS, and JavaScript Examples
- React Examples
- SQL Examples
IV. Getting Started (ChatGPT's API)
- System Requirements
- Installing Dependencies
- Running the Code
V. Usage
- Overview of API Features
- Using
chat_cli.py
(ChatGPT in the Command Line) - Using
chat_ui.py
(ChatGPT Deployed on Localhost)
VI. API Reference
- API Documentation & Quick Links
- Obtaining an API key
- API Example Applications
VII. Giving Thanks
- Closing Credits
- Cited Sources
- Open-Source Contributing
VIII. Glossary
- Artificial Intelligence (AI)
- Machine Learning
- Natural Language Processing (NLP)
- Chatbot
- Deep Learning
- Neural Network
- Generative Model
- Transformer Model
- API (Application Programming Interface)
This section introduces ChatGPT and the concepts of AI, machine learning, natural language processing, and the Transformer model, while also sharing initial use cases and metaphors for non-developers and software engineers.
ChatGPT is a computer program that can understand and generate human-like language to have conversations with people.
This is the answer I got when I asked ChatGPT to explain itself in one sentence to someone who knows nothing about ChatGPT or AI.
Here's a more specific definition:
ChatGPT is a state-of-the-art, large-scale natural language processing model based on the Transformer architecture, which can generate human-like text and perform various language-related tasks with high accuracy.
This time, I asked ChatGPT to sum itself up in one sentence to an AI and machine learning expert. Pretty cool, right?
OK ... but what does this all mean?
AI (Artificial Intelligence) is a type of computer technology that allows machines to perform tasks that normally require human intelligence. Machine Learning is a subset of AI that enables machines to learn from data and improve their performance without being explicitly programmed; in a way, it's learning from itself. Give it a goal and a data set to learn from and it'll do the rest.
So in relation to AI and machine learning, ChatGPT is a particular machine learning model that has been trained on a lot of text data to generate human-like responses and carry out natural language processing tasks.
Natural language processing models are AI models that enable computers to understand, interpret, and generate human language, allowing them to interact with humans through speech or text. There are many types of AI models, and more details will come in a future version of this guide. For now, it's important to know that ChatGPT uses the Transformer model. Compared to other AI models, the Transformer model is better at generating responses that focus on the context of a conversation. What makes ChatGPT special is that it can be picky and focus on the most relevant parts of a user's input instead of having to process an entire sequence at once.
If you'd like to read more on AI and machine learning beyond this guide, my favorite book right now is Janelle Shane's 'You Look Like a Thing and I Love You,' which informs a lot of the high-level concepts found in this guide.
For non-developers, some examples include:
- Ask questions or give commands to ChatGPT to then take specific actions and steps.
- i.e. Explain JavaScript like I'm a 5-year-old, and then explain it to me like I'm a senior engineer.
- Generate ideas, documentation, or dummy data.
- i.e. I need some sample data. I need a JSON array of 10 colleges with at least 10 fields each.
- Extract summaries, key words, and other data from text, links, or other online resources.
- i.e. I'm applying for this role [paste in job posting URL or text] what keywords should I include on my resume?
- Draft personalized study guides for future learning.
- i.e. Give me a study plan to learn Python for data science within a month with free video resources.
- Create first drafts of various text content.
- i.e. I have three years of experience coding in HTML, CSS, and JavaScript. Write a resume for me.
- Present high-level or technical problems and ask ChatGPT for potential solutions and examples.
- i.e. Write an Excel formula to add up values in cells B2 through B10.
- Refine text or code with specific goals.
- i.e. Here is my resume [paste in text] do you spot any typos? If so, please list them.
For software engineers, more examples include:
- Develop chatbots for customer service or sales.
- Create virtual assistants for personal or business use.
- Integrate ChatGPT with NLP tools to automate tasks.
- Generate actual content drafts for marketing or advertising campaigns.
There are a few different ways to approach ChatGPT. Here are a few metaphors to get you started:
ChatGPT is helpful when assisting you in work that might be too repetitive or time-consuming and involves a lot of known data. If you feel comfortable handing off work to ChatGPT that you also can fact-check and fine-tune on your own, you're in good hands. And though interns are helpful, we still need to review the results before putting them into practice; if you submit your work and something goes wrong, do you want to tell your boss, "Well, that's what ChatGPT gave me?"
If the Internet is its sacred text, ChatGPT interprets and conveys its information in a way that's easy to read and digest for as many people as possible. This communication can help visualize and break-down complicated or abstract ideas. It should also be taken with a grain of salt and not be a substitute for your own knowledge or abilities. AI is only as good and bias as the data it's trained on. ChatGPT is only as informed as the Internet allows it to be.
ChatGPT's access to information is impressive. Still, dumb questions don't yield smart answers. ChatGPT will not be able to always figure out the intent or context of your questions unless you explicitly tell it so. This is where the famous expression "garbage in, garbage out" comes in. The better your questions and data, the better ChatGPT can help.
It's very excited to play fetch with you (retrieve whatever data is needed to help you solve your problem) but it can't understand what you're trying to do. You can train a dog to fetch a stick (like you can train an algorithm with machine learning to do a specific task), but a dog doesn't understand what a "stick" is like a human understands a stick; a dog can only understand that you want "stick." ChatGPT only wants a treat and to be told it's a good boy. (Janelle Shane)
It learns by example (like algorithms learning from data) and has no idea what it should or shouldn't imitate, unless you tell it so. (Janelle Shane)
Janelle Shane's five principles of "AI Weirdness":
- The dangers of AI is not that it's too smart but that it's not smart enough.
- AI has the approximate brainpower of a worm.
- AI doesn't really understand the problem you want it to solve.
- AI, however, will do exactly what you tell it to do (or at least try its best).
- AI will take the path of least resistance.
So ChatGPT is less an intelligent machine that's timid and uptight from its own knowledge and servitude and more like a bunch of well-meaning worms doing their best.
Part A provides a beginner's guide to ChatGPT for non-developers and software engineers who want to use ChatGPT's prompt portal to generate responses to their text inputs.
This section provides steps for getting started with ChatGPT's prompt portal and how to write your first prompts.
All you need is a free OpenAI account:
- Sign up for OpenAI.
- Access the prompt portal.
- Enter your text input.
- Watch ChatGPT generate its output.
TROUBLESHOOTING: Sometimes when using ChatGPT on the web, if you don't use it after a few minutes, you'll get errors with each new prompt you try to enter. Refreshing your web browser fixes this issue.
All you have to do is write your prompt in the "Send a message" text box, press enter, and watch ChatGPT respond.
Try entering this prompt to start: "Tell me a dad joke."
ChatGPT is only as good as your prompt. Here are some starting tips on writing good prompts:
- Keep your prompt clear and concise.
- Ask a specific question or give a clear command. Don't write something broad or open-ended.
- Provide context for your prompt; ChatGPT will not be able to pick this up on its own.
- Use correct grammar and spelling.
- Avoid biased or discriminatory language.
Where to eat in Chi.
Can you recommend any good restaurants in Chicago?
I'm visiting Chicago for the first time this summer and am looking for some great places to eat. Specifically, I'm interested in seafood and italian cuisine. Do you have any recommendations for restaurants that fit this criteria? The closer these recommendations are to mass transit, the better. I don't want to spend more than $100 on a meal if possible.
This section provides real ChatGPT prompt examples and their sources as needed. Each bullet point is a prompt that you would type into ChatGPT, and each sub-bullet is a follow-up prompt that you can write in the same open window.
- What are the top 3 books for learning Java? (Mosh)
- List 10 science fiction books. (OpenAI)
- What are the key takeaways from Kurt Vonnegut's novel 'Slaughterhouse-Five'? (Mosh)
- What does the word "monozygotic" mean?
- Now give me a synonym.
- Now use it in 10 sentences. (Santrel)
- How do I become a front-end developer? (Mosh)
- I want to hire a graphic designer to design my website. We've agreed that they will deliver the first draft in two weeks and offer three iterations free of charge. Any iteration after will be charged at $50/hour. Write a contract draft for us that I'll then review with my lawyer. (Mosh)
- Write an email to my boss asking for a raise. I've worked at this company for 2 years and successfully delivered several projects on time. (Mosh)
- I want to learn about the fetch API. What are the steps that I should take?
- Tell me more about #2.
- Show me an example of the fetch API and a POST request.
- Show me this example using async await.
- What are some good books about the fetch API?
- What about YouTube videos? (Traversy)
- Give me some ideas for an app that uses the geolocation API.
- Tell me more about #3. (Traversy)
- Correct this to standard English: [Paste in text you wish to correct]. (OpenAI)
- Summarize this for a second-grade student: [Paste in text you wish to summarize]. (OpenAI)
- Translate this into 1. French, 2. Spanish and 3. Japanese: What rooms do you have available? (OpenAI)
- Convert movie titles into emoji: Back to the Future, Batman, Transformers, and Star Wars. (OpenAI)
- A neutron star is the collapsed core of a massive supergiant star, which had a total mass of between 10 and 25 solar masses, possibly more if the star was especially metal-rich.[1] Neutron stars are the smallest and densest stellar objects, excluding black holes and hypothetical white holes, quark stars, and strange stars.[2] Neutron stars have a radius on the order of 10 kilometres (6.2 mi) and a mass of about 1.4 solar masses.[3] They result from the supernova explosion of a massive star, combined with gravitational collapse, that compresses the core past white dwarf star density to that of atomic nuclei. Tl;dr. (OpenAI)
- Create an analogy for this phrase: Questions are like arrows. (OpenAI)
- Convert this from first-person to third person (gender female): I decided to make a movie about Ada Lovelace. (OpenAI)
- Give me a study plan to learn Python for data science with resources and a timeline. (Tina Huang)
- Act as a coding tutor that creates study plans to help people learn to code. You will be provided with the goal of the student, their time commitment, and resource preferences. You will create a study plan with timelines and links to resources. Only include relevant resources because time is limited. My first request: "I want to become a data scientist but I do not know how to code. I can study 10 hours per week and only want video resources. I want to learn to code in Python. Create a study plan for me." (Tina Huang)
- Act as an expert data scientist and create an exploratory data analysis Python data science project about Naruto the anime. (Tina Huang)
- I'm applying for this role; its application text is below in quotes. Please return keywords that I should include in my resume. "[Paste in the text of the application]."
- I also need to write a cover letter for this application. What information should I include?
- Here is the company's website [paste in website URL] are there any details I should add to my resume and cover letter based on their website?
- I've updated my resume to include these keywords [paste in text of the updated resume] does this resume text properly incorporate the keywords of this job position? Don't mind the structure or format of the resume text.
- I have three years of experience coding in HTML, CSS, and JavaScript. Write a resume for me. (Mosh)
- I'm applying for a front-end engineer role at Netflix. Write a cover letter for me. (Mosh)
- Act as a technical interviewer and ask me 5 questions about JavaScript
- What is the answer to the first question? (Mosh)
- You are conducting an interview for a senior Front End developer role. I want you to ask me difficult React.js, HTML, CSS, and JavaScript interview questions. Your response should contain the difficulty rating, but do not give me the answer or any other information. Start by asking me one question. (Web Dev Simplified)
- Can you give me an HTML question about accessibility? (Web Dev Simplified)
- Explain JavaScript like I'm a 5-year-old. (Fireship)
- What are the three most important concepts to know in React.js? (Fireship)
- Write an Excel formula to add up values in cells B2 through B10.
- Can you explain how this function works? (Kevin Stratvert)
- Write an Excel formula to calculate the profit. The revenue is in cell A2 and the cost is in B2. (Kevin Stratvert)
- Write an Excel formula to find "Sugar Cookie" in a table and return the price.
- Can I use any other functions? (Kevin Stratvert)
- Write an Excel formula to extract all the text before the @ character in cell A2. (Kevin Stratvert)
- Write an Excel formula to count the number of unique values in a list. (Kevin Stratvert)
- Write an Excel macro to send emails. Use the following subject: "Kevin Cookie Company Invoice." Use the following text: "You owe the Kevin Cookie Company X." Take the value X from column A. Send it to the email address listed in column B. (Kevin Stratvert)
- Write a bash command to find the name of all jpeg files in a directory and write them all to a text file. (Mosh)
- How do I know how many lines of code I've committed to a Git repository? (Mosh)
- How can I improve this code? [Then paste the code.] (Mosh)
- Can you provide some feedback on this code? [Then paste the code.] (Traversy)
- As a senior technical writer, please review and give feedback on the README to this GitHub project: [paste in GitHub URL]. This README acts like documentation for a beginner's guide to ChatGPT. This URL includes an example of documentation that is considered "good" and which I'd like to use as a reference: [paste in URL]. This ChatGPT README should incorporate the DITA documentation concepts of Concept, Procedure/Task, and API. The README should have imperative voice and should avoid implicit voice, adverbs, and filler words that don't add any value.
- Search this README and return any words with implicit voice, any words that are adverbs, and any filler words.
- Based on this Wikipedia article, when was the first Model T made? [Then paste in the article text or wiki url.]
- Now output that as a Python variable. (Santrel)
- Generate dummy data for a table called Customers. Each customer should have an ID, first name, last name, and city. I don't need a Python script. Just give me the data.
- Create a Python class for storing these objects. (Mosh)
- I need some sample data. I need a JSON array of 10 coding bootcamps with at least 10 fields each.
- Take out the programming languages field.
- Give me the same data in XML. (Traversy)
- Generate the documentation for this API. [Then paste in the GitHub repo URL.] (Traversy)
- I need to make a glossary for a study guide I'm making on ChatGPT. What key terms should I include in this new glossary to help beginners who are new to ChatGPT, AI, and machine learning?
- Uncaught TypeError: Cannot read property 'bar' of undefined (Mosh)
- Can you tell me what this error message means and how to fix it? [Then paste in code and error message.] (Traversy)
- Can you generate a unit test for the searchStates function using JEST? [Paste in code.] (Traversy)
- I need an API built with Express.js to return the list of products. Each product should have attributes like ID, title, description, price, and imageURL.
- Modify the code and retrieve the products from a MongoDB database.
- Use TypeScript in this code.
- Generate this API using Python and FastAPI. (Mosh)
- I need a REST API built with Rust. It should have products with the fields of id, name, description, and category_id. The category_id should have a relationship with another resource called categories. Categories should have an id and a name field. Let's use an SQLite database. Use any frameworks and libraries that you see fit. (Traversy)
- Write a python function for generating a random password.
- What does [line of code I don't understand] do in this code?
- What is the time complexity of this function?
- Write unit tests for this function.
- Convert this Python code to JavaScript. (Mosh)
- How can I scrape a web page using Python? (Traversy)
- Give me a function to convert c to f in Python. (Traversy)
- Write the HTML and CSS code for displaying a card. Add a button below the card content. When I hover my mouse over the card, I want the card to slightly slide up.
- Can you rewrite this code using TailwindCSS?
- When I click on the button, send an HTTP request to /api/products. Instead of the fetch API, use Axios. (Mosh)
- I need the HTML and CSS in separate files for a blog homepage with a navbar with a logo on the left and links on the right. A hero area with a background image and centered text. Under that should be 3 cards in a horizontal flexbox. The cards should have light gray background and a box shadow. Use light blues and greens and use the poppies font. (Traversy)
- Give the background-color CSS code for a color like a blue sky at dusk. (OpenAI)
- Create a React component for displaying a card.
- Deconstruct the props parameter. (Mosh)
- Create a basic react component that says hello world. CODE ONLY.
- Add a button that toggles the visibility of the text.
- Now write a test for this app using Playwright.
- Document this code. (Fireship)
- Write an SQL query to generate a table called products with 4 columns. (Mosh)
- Write an SQL query to generate a table called products with these columns: Id (int), Title (string), Category (int), unitPrice (float), and imageUrl (string). (Mosh)
- Write an SQL query to retrieve the top 5 customers in Manhattan.
- Revise this query and join the customers table with the orders table to find out how much each customer has spent. Then pick the top 5 who have spent the most. (Mosh)
Part B provides a beginner's guide to ChatGPT for software engineers who want to integrate ChatGPT into their own applications.
This section reviews the technology and packages needed to get started with ChatGPT's API and how to run this guide's example code.
ChatGPT
Mac
- macOS 10.15 or later
- At least 4GB of RAM
- 2GHz Intel Core i5 or equivalent CPU
Windows:
- Windows 10 or later
- At least 4GB of RAM
- 2GHz Intel Core i5 or equivalent CPU
Linux:
- Ubuntu 18.04 or later, or a similar Linux distribution
- At least 4GB of RAM
- 2GHz Intel Core i5 or equivalent CPU
Both chatbot examples in this guide are written in Python, so download the latest version of the following:
As of this writing, this guide is using the API model version "gpt-3.5-turbo," though this may be updated in a future release.
Though this guide focuses on Python, other languages can use OpenAI's API. For example, Fireship has a great video on using ChatGPT to build a "Hello, World" React app, and Web Dev Simplified made a great video reviewing the basics of creating a chatbot with vanilla JavaScript.
This GitHub includes the Python files chat_cli.py
and chat_ui.py
. These are simple examples that we'll use to visualize ChatGPT's API in action. To run the code in either .py
file:
- Open a new terminal.
- Run the python command and the name of the file. (i.e
python chat_cli.py
orpython chat_ui.py
). - The terminal will provide next steps.
When you want to stop either program:
- Go into the terminal where you're running the chat.
- On your keyboard, keypress
control + c
.
This section introduces the actual uses of the ChatGPT API and reviews the beginner examples found in chat_cli.py
and chat_ui.py
. These concepts will be explored even further in the API Reference section.
ChatGPT is unique in how much it can offer to users. Notable features include:
- Easy integration: you only need a few lines of code to add ChatGPT into your app. See
chat_cli.py
andchat_ul.py
to see this code in action. - Customizable response parameters: it's possible to control a response's length, its temperature (rate of randomness), the number of responses at a time, and more.
- Rich responses: ChatGPT can be flexible with the type of content it responds with, including longform prose, bullet-point lists, and code snippets.
- Multi-turn conversations: ChatGPT can remember previous user inputs and take them into consideration when generating new responses.
ChatGPT is constantly changing and updating. To see all updates made so far, please refer to OpenAI's ever-evolving release notes.
This is a very simple example of how to build your own chatbot that runs in the command line with ChatGPT. The file's main feature is its chatbot
function, which is broken down like so:
message_history = []
We first create an empty list called message_history
that'll store our chat's conversation. We then create a while
loop that'll repeat until the user manually stop the app. The following code snippets live inside this while
loop.
user_input = input("USER PROMPT > ")
print(f"YOU ASKED: '{user_input}' ...")
We prompt the user to input data, which we store in our new variable user_input
. Printing user_input
confirms to the user what they entered.
message_history.append({"role": "user", "content": user_input})
We then append our new user_input
into message_history
, as well as its role as a "user." We then create a try-except
block that'll handle potential errors.
completion = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=message_history,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
This is how we finally begin talking to ChatGPT - by creating a completion
. This basic openai.ChatCompletion.create()
method includes the following:
model
: the specific GPT-3 language model we're using.messages
: our chat history.max_tokens
: the max number of tokens to generate in a response.n
: the number of responses to return at a time.stop
: define any specific conditions that'll stop a response.temperature
: the level of randomness in a generated response; from 0 to 1, the closer to 1 - the "higher" the temperature - the more random the response.
reply_content = completion.choices[0].message.content
print("CHATGPT RESPONSE:", reply_content)
Our new reply_content
variable extracts and stores our API's completion
. The API provides a lot of information, but reply_content
is only concern with the content of the actual message. Printing reply_content
allows the user to see the API's response and only the information they want to see.
message_history.append({
"role": "assistant",
"content": reply_content
})
We then append our new reply_content
to message_history
, and note its role as an "assistant."
This cycle repeats until the user manually stops the app with the keypress control + c
.
except openai.error.OpenAIError as error:
print("OpenAI API error:", error)
All the above code under the try
block is executed when there are no issues. When issues do come up, this except
block kicks in. This is an exception handler that'll print any errors to the user for future troubleshooting.
This an example of how to deploy a simple chatbot locally in your web browser. The overall structure is similar to chat_cli.py
, but it's worth nothing this important difference:
messages = [{
"role":
"system",
"content":
"You are a music curator with decades of experience in the music industry who helps people discover great new music from any era or genre. You value the classics yet always try to steer new listeners to discover music they might not have heard before."
}]
By defining messages
early with this specific "system" content, we're setting the context for our chatbot. With this example, the chatbot now acts like a music curator. However, it's easy to change the system's content to set the chatbot to talk like a financial planner, or a sassy middle school teacher.
This section breaks down ChatGPT's overall documentation with related links on obtaining API keys and example projects to get you started. When in doubt, you can always go straight to the source and explore from there: https://platform.openai.com/
For the scope of this guide, it's best to start with these documentation sections:
- Introduction
- Overview
- Key concepts: Prompts, Tokens, and Models
- Next steps
- Quickstart
- Introduction: An intro to "Completion"
- Start with an instruction
- Add some examples
- Adjust your settings: An intro to "Temperature"
- Build your application (Node.js or Python/Flask)
- Pricing
- Closing
- Next steps
- Libraries
- Python
- Node.js
- Community libraries (multiple languages)
- Models
- Overview
- Model compatibility: API endpoints and model names
- Model updates
- GPT-4 (limited beta)
- GPT-3.5
- DALL-E (beta): generate and edit images using NLP
- Whisper (beta): convert audio into text
- Embeddings: convert text into a numerical form
- Moderation: detection of sensitive or unsafe text
- GPT-3
- Tutorials
- Website Q&A with Embeddings
- Text completion
- Introduction
- Prompt design: showing and telling, providing quality data, checking your settings, and more
- Inserting text
- Editing text
- Chat completion
- Introduction: examples of the API response format and managing tokens
- Instructing chat models
- Chat vs Completions
- FAQ
- Image generation w/ DALL-E
- Introduction
- Usage: Generations, Edits, and Variations
- Language-specific tips: Node.js, TypeScript, and error handling
- Fine-tuning
- Preparing your dataset
- Advanced usage
- Weights & Biases
- Example notebooks: Classification and Question answering
- Embeddings
- Overview
- Use cases
- Limitations & risks
- Speech to text w/ Whisper
- Overview
- Quickstart: Transcriptions and Translations
- Supported languages
- Longer inputs
- Prompting
- Moderation
- Overview
- Quickstart
- Rate limits
- Overview
- Error mitigation
- Rate limit increase
- Error codes
- API errors: 401, 429, and 500
- Python library errors
- Safety best practices
- The Moderation API
- Adversarial testing
- Human in the loop (HITL)
- Prompt engineering
- Know your customer (KYC)
- Constrain user input and limit output tokens
- Allow users to report issues
- Understand and communicate limitations
- End-user IDs
- Production best practices
After you've created an OpenAI account, head to the API keys page and follow its steps. Always keep this key safe and secret.
ChatGPT's API is a powerful tool that can address a wide range of problems. OpenAI's Examples page includes a long list of example applications that use ChatGPT in different use cases. Here are some popular examples:
- Q&A: Answer questions based on existing knowledge.
- Factual answering: Direct the model to provide factual answers and address knowledge gaps.
- JavaScript helper chatbot: Message-style bot that answers JavaScript questions.
- ML/AI language model tutor: Bot that answers questions about language models.
- Friend chat: Emulate a text message conversation.
- Chat: Open ended conversation with an AI assistant.
- Marv the sarcastic chat bot: Marv is a factual chatbot that is also sarcastic.
- Classification: Classify items into categories via example.
- Advanced tweet classifier: Advanced sentiment detection for a piece of text.
- Keywords: Extract keywords from a block of text.
- Tweet classifier: Basic sentiment detection for a piece of text.
- Airport code extractor: Extract airport codes from text.
- Extract contact information: Extract contact information from a block of text.
- Grammar correction: Corrects sentences into standard English.
- English to other languages: Translates English text into French, Spanish and Japanese.
- Summarize for a 2nd grader: Translate difficult text into simpler concepts.
- Natural language to OpenAI API: Create code to call to the OpenAI API using a natural language instruction.
- Natural language to Stripe API: Create code to call the Stripe API using natural language.
- SQL translate: Translate natural language to SQL queries.
- Python to natural language: Explain a piece of Python code in human understandable language.
- Calculate Time Complexity: Find the time complexity of a function.
- Translate programming languages: Translate from one programming language to another.
- Explain code: Explain a complicated piece of code.
- Python bug fixer: Find and fix bugs in source code.
- JavaScript to Python: Convert simple JavaScript expressions into Python.
- Write a Python docstring: Write a docstring for a Python function.
- JavaScript one line function: Turn a JavaScript function into a one liner.
- Text to command: Translate text into programmatic commands.
- Parse unstructured data: Create tables from long form text.
- SQL request: Create simple SQL queries.
- Movie to Emoji: Convert movie titles into emoji.
- Ad from product description: Turn a product description into ad copy.
- Product name generator: Create product names from examples words.
- TL;DR summarization: Summarize text by adding a 'tl;dr:' to the end of a text passage.
- Spreadsheet creator: Create spreadsheets of various kinds of data.
- Science fiction book list maker: Create a list of items for a given topic.
- Mood to color: Turn a text description into a color.
- Analogy maker: Create analogies.
- Micro horror story creator: Creates two to three sentence short horror stories from a topic input.
- Third-person converter: Converts first-person POV to the third-person.
- Notes to summary: Turn meeting notes into a summary.
- VR fitness idea generator: Create ideas for fitness and virtual reality games.
- Essay outline: Generate an outline for a research topic.
- Recipe creator: Create a recipe from a list of ingredients.
- Turn by turn directions: Convert natural language to turn-by-turn directions.
- Restaurant review creator: Turn a few words into a restaurant review.
- Create study notes: Provide a topic and get study notes.
- Interview questions: Create interview questions.
Part C provides credits, cited sources, contribution steps, and a glossary for both non-developers and software engineers.
This section includes the credits and cited sources that made this guide possible, as well as how you can contribute to this open-source guide.
A shout-out to Nick Arocho for his initial guidance on where to get started with ChatGPT. Videos by The AI Advantage and sentdex helped me get started with ChatGPT's API in Python and Gradio. Doodles by Doodle Ipsum. And again, Janelle Shane's book is a must-read.
The following videos were vital in helping me make this guide. For further learning, I encourage you to watch these videos by the following creators:
Contributions to this guide are welcomed.
This guide aims to solve the problems of accessibility with getting started with ChatGPT, which can be confusing for developers new to AI. This guide is build with markdown and Python.
This guide has the following goals and objectives:
- Get rid of any README typos or improper grammar.
- Refactor
chat_cli.py
andchat_ui.py
to be as simple and readable as possible. - Create
pytest
forchat_cli.py
andchat_ui.py
. - Include JavaScript API code samples to mirror the logic and workflow of
chat_cli.py
andchat_ui.py
. - Flesh out the API Reference section to include more concrete examples and breakdowns of key concepts so that users don't have to always click on the reference links. (i.e. Why do we call it a "Completion"? Can we quickly explain what it is in this README?)
- Add more necessary terms to this README's Glossary.
- Expand the Introduction section to include brief histories of AI, machine learning, OpenAI, and ChatGPT. (No more than a paragraph for each.)
- Add more helpful prompts to the Examples of ChatGPT Prompts section.
- Translate README text into another language for those whose native reading language is not English.
- Include screenshots and more helpful visual aids.
Contributions that help achieve these goals are welcomed.
Please follow these coding standards and conventions when making changes to the codebase:
- Use consistent indentation.
- Use descriptive variable names and avoid abbreviations or acronyms that are not widely recognized.
- Use comments to explain non-obvious code.
If you encounter a bug or issue, please report it using the issue tracker. To ensure that we can reproduce and fix the issue, please provide the following information:
- Provide clear steps to reproduce the bug or issue.
- Include any relevant error messages or screenshots.
- Indicate the severity of the bug or issue.
To contribute:
- Fork this repository.
- Create a new branch for your feature or bug fix.
- Make your changes, test your changes, and commit them with descriptive commit messages.
- Push your changes to your forked repository.
- Open a pull request to this repository.
Your pull request will be reviewed and merged if it meets our guidelines and standards. Thank you for contributing to our project.
We expect all contributors to adhere to the code of conduct based on the Contributor Covenant.
Don't be a dork. Be decent.
This section provides a glossary for the terms frequently used in this guide that may not be familiar with all readers.
The ability of machines to perform tasks that would typically require human intelligence, such as learning, problem-solving, and decision-making.
A subfield of AI that involves training machines to learn from data, so they can make predictions or decisions without being explicitly programmed.
A subfield of AI that focuses on the interaction between machines and humans using natural language, such as speech or text.
A computer program that uses NLP to simulate conversation with human users, typically through messaging applications or voice assistants.
A subfield of machine learning that involves training neural networks with many layers to recognize patterns in data.
A type of machine learning algorithm that is modeled after the structure of the human brain and consists of interconnected nodes or neurons that process information.
A type of AI model that generates new data that is similar to the training data it was trained on, such as text or images.
A type of neural network that is widely used for NLP tasks, such as language translation, text summarization, and question answering.
A set of rules and protocols that allows different software applications to communicate with each other. In the context of this project, it refers to the programming interface provided by ChatGPT that allows developers to integrate the model into their own applications.
© 2023 Brady Gerber. All Rights Reserved.