Prompt Engineering in Python, with GPT, and the OpenAI API
Keep adding new skills with 10,000+ programs for $239 (usually $399). Save now.
Prompt Engineering in Python, with GPT, and the OpenAI API
This course is part of Building with OpenAI API Specialization
Included with
Learn more
Ask Coursera
Recommended experience
Recommended experience
What you'll learn
Design effective prompts for coaching, chatbots, and data extraction tasks.
Mitigate hallucinations and optimize GPT responses using advanced techniques.
Implement chain-of-thought prompting and emotion-driven prompt strategies.
Use Python and the OpenAI API to build smart, scalable chatbots and extract structured data.
Skills you'll gain
Tools you'll learn
Details to know
6 assignments
See how employees at top companies are mastering in-demand skills
Build your subject-matter expertise
- Learn new concepts from industry experts
- Gain a foundational understanding of a subject or tool
- Develop job-relevant skills with hands-on projects
- Earn a shareable career certificate
There are 6 modules in this course
Updated in May 2025.
This course now features Coursera Coach! A smarter way to learn with interactive, real-time conversations that help you test your knowledge, challenge assumptions, and deepen your understanding as you progress through the course. Master the art of prompt engineering in Python and unlock the full potential of GPT models and the OpenAI API. This course will teach you how to create, improve, and fine-tune prompts for various tasks, from personal coaching to building chatbots. You'll gain hands-on experience in iterative prompt design, mitigating hallucinations, and extracting structured information with JSON mode. The course begins with an introduction to prompt engineering fundamentals and explores how GPT models work in practical scenarios. You'll learn to set up your OpenAI API key, implement chain-of-thought prompting, and compare model versions like GPT-3.5 and GPT-4. Through real-world examples, youβll also tackle advanced topics such as emotion-driven prompts and exponential backoff strategies. In later modules, you'll build your own Python API chatbot, enhance multi-turn conversations, and use GPT for extracting numerical values and image-based input. Techniques like "prompt hacking" and smart prompting will teach you how to maximize GPTβs performance, even with older models. This course is ideal for developers, data enthusiasts, and AI professionals seeking to master prompt engineering. Basic Python knowledge is required, and the course is designed for an intermediate difficulty level.
In this module, we will introduce the course by outlining its structure, goals, and unique value propositions. You will gain an understanding of prompt engineering basics and learn how the course content and instruction remain up-to-date with cutting-edge developments in the field.
What's included
4 videos2 readings
4 videosβ’Total 12 minutes
- Course Overview and Key Points of Differenceβ’6 minutes
- Introductionβ’5 minutes
- This course gets updated, and your instructor gets "updated"Part 01β’1 minute
- This course gets updated, and your instructor gets "updated"Part 02β’1 minute
2 readingsβ’Total 20 minutes
- Introduction to the Course 'Prompt Engineering in Python, with GPT, and the OpenAI API'β’10 minutes
- Full Course Resourcesβ’10 minutes
In this module, we will explore how to leverage ChatGPT as a personal coach to support your growth and learning. You will learn how to access course materials, craft coaching prompts, and identify the limitations of the tool. Additionally, weβll discuss using custom GPTs to elevate your Python learning experience.
What's included
5 videos1 assignment
5 videosβ’Total 26 minutes
- Turning ChatGPT into a Personal Coachβ’8 minutes
- How to download course prompts, code, and connect to resourcesβ’1 minute
- Coach Prompt Deep Diveβ’4 minutes
- Where ChatGPT failsβ’11 minutes
- Learning Python with Custom GPTsβ’2 minutes
1 assignmentβ’Total 15 minutes
- ChatGPT as a Personal Coach - Assessmentβ’15 minutes
In this module, we will dive into advanced prompting strategies to maximize GPT's capabilities while addressing common challenges. You will learn to iteratively improve prompts, apply chain-of-thought methods, and mitigate hallucinations. Additionally, youβll explore findings from research like EmotionPrompt and implement practical solutions for real-world scenarios.
What's included
14 videos1 assignment
14 videosβ’Total 55 minutes
- Setting up your OpenAI API Keyβ’4 minutes
- Learning Outcomes for the First Notebookβ’2 minutes
- Python API Prompting and Iterative Prompt Improvement Part 1β’9 minutes
- Make sure that your version of the openai package is greater than 1.0.0β’1 minute
- Using GPT-4 and Other Model Versionsβ’3 minutes
- Iterative Prompting Improvement Part 2β’5 minutes
- Emphasizing an Important Point β’0 minutes
- Optional: Implementing Exponential Backoff for Querying the OpenAI APIβ’1 minute
- How we have applied Chain-of-Thought promptingβ’5 minutes
- Chain-Of-Thought Prompting - the formal introductionβ’3 minutes
- Reasoning Modelsβ’2 minutes
- Inducing and Mitigating Hallucination in LLMsβ’12 minutes
- EmotionPrompt - Findings from the Paperβ’4 minutes
- EmotionPrompt in Practiceβ’4 minutes
1 assignmentβ’Total 15 minutes
- Building up Prompts, Mitigating Hallucination, and Getting the Best Answers - Assessmentβ’15 minutes
In this module, we will focus on building a chat bot using the Python API and refining prompt engineering techniques for advanced use cases. You will learn how to enhance conversation flow through prompt hacking and implement exponential backoff strategies for robust, multi-turn interactions.
What's included
3 videos1 assignment
3 videosβ’Total 13 minutes
- Python API Chat Botβ’6 minutes
- Prompt Hackingβ’6 minutes
- Optional: Implementing Exponential Backoff for Multi-Turn Conversationsβ’1 minute
1 assignmentβ’Total 15 minutes
- Python API Chat Bot, and Prompt Hacking -Assessmentβ’15 minutes
In this module, we will focus on techniques for extracting numerical values from text data and validating the accuracy of your extraction methods. Additionally, you will explore how to leverage JSON mode and optimize prompts to push GPT-3.5 performance closer to GPT-4, unlocking more powerful and structured outcomes.
What's included
2 videos1 assignment
2 videosβ’Total 18 minutes
- Extracting Numerical Values from Text Data, and Testing the Extractionβ’6 minutes
- JSON Mode, and pushing GPT 3.5 to the level of GPT 4 with smart promptingβ’12 minutes
1 assignmentβ’Total 15 minutes
- Extracting Numerical Values from Text Data, Testing your Prompts, and JSON Mode - Assessmentβ’15 minutes
In this module, we will explore the concept of multimodal prompting, focusing on how GPT models interpret and utilize images. You will learn how to incorporate visual inputs into prompts to provide richer context and improve the accuracy of model outputs.
What's included
1 video1 reading2 assignments
1 videoβ’Total 9 minutes
- Image Understanding AKA "Vision"β’9 minutes
1 readingβ’Total 10 minutes
- Conclusion to the Course 'Prompt Engineering in Python, with GPT, and the OpenAI API'β’10 minutes
2 assignmentsβ’Total 75 minutes
- Full Course Assessmentβ’60 minutes
- Full Course Practice Assessmentβ’15 minutes
Earn a career certificate
Add this credential to your LinkedIn profile, resume, or CV. Share it on social media and in your performance review.
Instructor
Offered by
Explore more from Machine Learning
Guided Project
- Status: FreeD
DeepLearning.AI
Project
- Status: Free Trial
Course
Why people choose Coursera for their career
Frequently asked questions
Yes, you can preview the first video and view the syllabus before you enroll. You must purchase the course to access content not included in the preview.
If you decide to enroll in the course before the session start date, you will have access to all of the lecture videos and readings for the course. Youβll be able to submit assignments once the session starts.
Once you enroll and your session begins, you will have access to all videos and other resources, including reading items and the course discussion forum. Youβll be able to view and submit practice assessments, and complete required graded assignments to earn a grade and a Course Certificate.
More questions
Financial aid available,
