From the course: OpenAI API for Python Developers

Getting started with OpenAI: The key concepts

From the course: OpenAI API for Python Developers

Getting started with OpenAI: The key concepts

- [Instructor] OpenAI offers a nice quick and easy developer guide in order to get up and running fast with the OpenAI API. So it supports several platforms and programming languages. Developers have the options to select the programming language that they want to work with, for example, with Node.js or Python. So the steps are very easy. First, you want to make sure that Python is properly installed on your machine. Next optional, you can set up if you'd like a virtual environment. Finally, you're going to install the OpenAI Python library. The next step will be to configure your project with an API key in order to be authorized to send your first API request and you'll see that the syntax is very simple. The OpenAI libraries offer convenient interfaces to interact easily with the language models. And speaking about the language models, we're going to check them out right here under introduction, starting with the text generation models, which are powered by the GPT models, which are said to be one of the most advanced language models at the time of recording. So they are capable of understanding natural language. They are trained on large data sets. That makes them capable of performing various text processing tasks. So we're going to have a look of a few examples of what they can do. So, for example, they can help you with drafting documents, writing computer code, even analyzing and summarizing texts and translating documents. So with OpenAI, you can also create assistance to create a custom version of ChatGPT, also powered by the GPT models. They can be connected to built-in tools like advanced data analysis, or the feature function calling, which is in beta at the time of recording, in order to connect your assistance with real time data. Embeddings is another option to create vector-based and custom knowledge database to train the language models with your own data. So you can create smart applications driven by AI and trained with your own data. Another key concept and important concept is tokenization, which is the process of breaking down a piece of text into smaller units called tokens, which is a crucial step in natural language processing that allows the language models to analyze and understand the structure of the input text. So let's see one example with this tool right here. So for example, I'm going to type a piece of text and you're going to see that as I type, you're going to have the breakdown below of the number of tokens that you use. So for example, I'm going to type, "I want to build projects with OpenAI", and right now I am using exactly eight tokens. I'm going to use the same example and use the playground right here. And you're going to make sure that you select chats. We're going to add a new message and submit. And so the assistant is going to generate a new completion. And on the right you're going to find the settings. So first, you have the temperature that allows to control the randomness, the variation between completion with a value between zero and one, which will impact the results, which is generated by the assistance. By default, the assistance will provide with deterministic responses, meaning that you can expect the same response if the value is zero. If you change to one, this will allow to generate different results depending on the task that you want to perform. For example, if you want to create creative stories, you can select one in order to leave some room for creativity. And then below you have the maximum length, which corresponds to the number of tokens that you can use for every prompt and completion. So remember that you pay for every token that you use. So you certainly want to control the maximum of tokens that you use by adjusting the settings, by setting the maximum. So the more token you use, the more credits you spend. So back to the language models, we're going to check out right here. You're going to see the maximum of tokens that you can use for every model. So for example, right here, you have that many tokens that you can use for the GPT-4 models. And if we check out below for the GPT-3.5, you can use that many tokens for every prompt and completion. So let's move on to the quick start guide to get started now with OpenAI. OpenAI provides a quick start guide for an easy start for developers, which is designed to help you get your local development environment set up quickly. And so you'll be ready to send your first requests with the OpenAI APIs.

Contents