The term API is not unfamiliar. Simply put, an API is a special string key made up of letters, numbers, and some symbols, for example yzwfwFefwf321joOjolj-jFjjo. After connecting to your program through an API string, you can use the functions behind the API. Take OpenAI as an example: OpenAI opens up different ChatGPT models for us to use. One API can use all ChatGPT functions and the corresponding models. Different models have different functions: some output plain text, some can interpret images, some can interpret video, and some specialize in processing speech.
For different models, you can refer to the API types listed officially by OpenAI, https://platform.openai.com/docs/overview
[baike]The relationship between ChatGPT and OpenAI API[/baike]Many people think that the ChatGPT API and the OpenAI API are the same thing. At present, this understanding is roughly right, but not accurate. OpenAI divides the API and ChatGPT into two different projects; if you want to use them, you need to pay separately. Currently, the APIs provided by OpenAI are mainly ChatGPT models; later, models such as Sora and voice cloning may also be integrated into the OpenAI API. After purchasing the API, you can use almost all functions, but purchasing ChatGPT Plus only lets you use all functions of the ChatGPT web version. Everyone should be able to understand this now.
[baike]What scenarios is API suitable for[/baike]API is suitable for automated programs, for example, embedding the API into Python scripts or websites and interacting with the API through program logic to output content. In real tasks, it is impossible for us to manually copy and paste massive amounts of daily work content data into the ChatGPT chat window and have it work for us, but we can put our work data together and send it to the API for transmission. In this way, we can closely integrate our work with AI and use the functional advantages of ChatGPT to help us work. Another important feature is that the API has no conversation count limit; it only has API rate and token limits, and this amount is very large.
To help everyone understand API work scenarios more clearly, the moderator will demonstrate with several API use cases he usually uses.
Example 1: Submit the user visit statistics of our www.niuboyi.com website to the API, and let it help me analyze user behavior and then provide a plan to improve user experience. Our website's statistics themselves also provide an API; I only need to submit this API to OpenAI's API to easily achieve this. Dozens of lines of code can easily handle it, and completing this script takes only a few minutes.
Example 2: I used a Python script to write a local ChatGPT conversation function. This is the same as using it on the web page. I can enter a prompt, then execute this script, and it will return content to me and save it to the corresponding file. This makes it convenient for me to save text and perform secondary processing.
Example 3: I chose a different model. This model is used to recognize images. I use Python to extract local video frame images and then transcode them, and give the transcoded images to the API so that it can help me restore and interpret the images. In this way, the ability to interpret video is achieved.
It is not limited to local scripts. We can integrate it into apps, software, or website applications. For example, I made this video interpretation script into a web version. As shown, enter your API, video URL, and prompt, and it can interpret it. However, it is still a semi-finished product and is only used for teaching.
[baike]How beginners can use API[/baike]Beginners should not be intimidated when they see script code. The moderator tells you that in the future everyone can easily write any code. You do not need to learn a large amount of programming content; you only need to simply understand the logic of the code, and leave the rest to AI to complete. You only need to direct AI, tell it your purpose, and let it write the code. The moderator himself does not have very deep programming skills, but I understand a little of mainstream languages, so I can understand what it means. This is very suitable for me. Moreover, technical people all over the world are now using AI to write code, because AI is fully capable of it, which has greatly improved our work efficiency. In the future, humans will no longer need to learn to write code; they only need to learn how to direct AI to write code.
Demonstration of specific steps
Prompt template: tell AI your purpose + what scenario you are using it in + your capabilities + supporting content
Prompt example: I want to send my work notes on my computer to your API every day at 6 p.m. You help me analyze my work content, and guide me on how my work quality is and how to solve problems and optimize work tasks. Give me an automated script and the software installation and other content needed. I hope you will guide me patiently and use plain language as much as possible in the process, telling me that this is very simple.
[baike]How to buy API most appropriately[/baike]
The moderator has already paved the way for you. The cheapest and most reliable way is to buy API through resellers; you can buy it on Taobao. Enter OpenAI API or ChatGPT API, and choose the version you want to buy. Version 3.5 can only transmit text, while version 4.0 can recognize images, speech, and other content. You can buy direct issue or forwarding; I recommend direct issue. The difference between direct issue and forwarding lies in the network environment: forwarding means someone else buys it and then acts as a proxy for you to use; direct issue means the API bought by someone else is resold directly to you. Resellers have ways to get it at a very low price. If you want to learn more about this, we can discuss it further.
[baike]How to use it more economically[/baike]Generally, an API is valid for only one month and has a certain quota; this quota is the token usage. The official price for the GPT-4 API is 10 yuan per 1 million tokens. This is not much for anyone with a large workload, so you need to arrange your usage reasonably. This token usage includes sending and return combined, totaling 1 million, so when you need to process data well in the script to make it concise and accurate, you should limit the number of tokens sent and returned during testing. |