hands-on lab

Introduction to the OpenAI Chat Completions API

Up to 30m
Get guided in a real environmentPractice with a step-by-step scenario in a real, provisioned environment.
Learn and validateUse validations to check your solutions every step of the way.
See resultsTrack your knowledge and monitor your progress.


Large language model (LLM) artificial intelligence (AI) has been used to produce human-like conversations with users through applications like OpenAI's ChatGPT. This lab introduces you to the OpenAI chat completion API and demonstrates how to use it to programmatically generate conversational responses. See what it takes to include generative AI in your applications and how to use it to create engaging user experiences.

You will use the official OpenAI Python client library to interact with the chat completion API in a Jupyter notebook. By iterating on a prompt, you will understand how to improve response quality and accuracy in the context of a conversation.

Learning objectives

Upon completion of this beginner-level lab, you will be able to:

  • Describe the OpenAI chat completion API
  • Explain the different roles available in the conversation
  • Discuss different models and parameters available to tailor the performance of the API

Intended audience

  • Software Developers
  • Machine Learning Engineers
  • Anyone interested in learning about applications of generative AI


Familiarity with the following will ensure the most beneficial lab experience:

  • Python

The following content can be used to fulfill the prerequisites:

Environment before

Environment after

About the author

Logan Rakai, opens in a new tab
Lead Content Developer - Labs
Learning paths

Logan has been involved in software development and research since 2007 and has been in the cloud since 2012. He is an AWS Certified DevOps Engineer - Professional, AWS Certified Solutions Architect - Professional, Microsoft Certified Azure Solutions Architect Expert, MCSE: Cloud Platform and Infrastructure, Google Cloud Certified Associate Cloud Engineer, Certified Kubernetes Security Specialist (CKS), Certified Kubernetes Administrator (CKA), Certified Kubernetes Application Developer (CKAD), and Certified OpenStack Administrator (COA). He earned his Ph.D. studying design automation and enjoys all things tech.

LinkedIn, Twitter, GitHub

Covered topics

Lab steps

Starting the OpenAI Notebook