search
HomeTechnology peripheralsAIIt's finally here, OpenAI officially opens ChatGPT API

It's finally here, OpenAI officially opens ChatGPT API

Developers can now integrate ChatGPT and Whisper models into their applications and products through our API.

In the previous API version, the text-davinci-003 version of the model was used. This model did not have the contextual dialogue function, and the generated content was much worse than ChatGPT, so the community There have also been many projects that package the web version of ChatGPT to provide services, but the stability is not very good because they rely on web pages. Now that the ChatGPT version of the API has been officially released, this is great news for developers. Of course, it is of great significance to OpenAI and even the entire industry. In the next period of time, there is bound to be a new API. A large number of excellent AI applications.

The latest externally released API is driven by gpt-3.5-turbor. This is OpenAI’s most advanced language model. Many things can be done through this API.

  • Write an email or other article
  • Write Python code
  • Answer a question about a set of files
  • Give your software a Natural language interface
  • Language translation
  • Simulating video game characters and more

The new chat model needs to take a series of messages as input so that it can have The contextual dialogue function is now available, and of course you can also perform single-round tasks, the same as before.

To implement the new API, you need the v0.27.0 version of the Python package:

pip3 install openai==v0.27.0

Then you can directly use the openai package to interact with openai:

import openai
openai.api_key = "sk-xxxx"
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "你是一个AI机器人助手。"},
{"role": "user", "content": "哪个队将赢得2023年NBA总冠军?"},
]
)

The most important thing One of the input parameters is messages, which is an array of message objects, each of which contains a role (system, user, assisttant) and message content. The entire conversation can be one message or multiple messages.

Normally, the format of the conversation is to first have a system message. The system message helps to set the behavior of the assistant. User messages are generated by the end users of our application, which are the questions we want to consult. The assistant message is the data fed back to us by openai. Of course, it can also be written by the developer.

When we reply to the last assistant message together, we will have the ability to contextualize it.

import openai
openai.api_key = "sk-xxxx"
response = openai.ChatCompletion.create(
model="gpt-3.5-turbo",
messages=[
{"role": "system", "content": "你是一个AI机器人助手。"},
{"role": "user", "content": "哪个队将赢得2023年NBA总冠军?"},
{"role": "assistant", "content": "湖人队将获得总冠军!"},
{"role": "user", "content": "谁会当选FMVP?"}
]
)
result = ''
for choice in response.choices:
result += choice.message.content

print(result)

For example, if we add the previous message here, we can finally get the contextual message:


Because prediction is actually It is difficult to make the most accurate prediction because many factors may affect this decision. However, the Lakers have many players who have the opportunity to win the FMVP award, such as LeBron James, Anthony Davis, Kyle Kuzma, etc., who may become FMVP.


The above is the detailed content of It's finally here, OpenAI officially opens ChatGPT API. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:51CTO.COM. If there is any infringement, please contact admin@php.cn delete
Gemma Scope: Google's Microscope for Peering into AI's Thought ProcessGemma Scope: Google's Microscope for Peering into AI's Thought ProcessApr 17, 2025 am 11:55 AM

Exploring the Inner Workings of Language Models with Gemma Scope Understanding the complexities of AI language models is a significant challenge. Google's release of Gemma Scope, a comprehensive toolkit, offers researchers a powerful way to delve in

Who Is a Business Intelligence Analyst and How To Become One?Who Is a Business Intelligence Analyst and How To Become One?Apr 17, 2025 am 11:44 AM

Unlocking Business Success: A Guide to Becoming a Business Intelligence Analyst Imagine transforming raw data into actionable insights that drive organizational growth. This is the power of a Business Intelligence (BI) Analyst – a crucial role in gu

How to Add a Column in SQL? - Analytics VidhyaHow to Add a Column in SQL? - Analytics VidhyaApr 17, 2025 am 11:43 AM

SQL's ALTER TABLE Statement: Dynamically Adding Columns to Your Database In data management, SQL's adaptability is crucial. Need to adjust your database structure on the fly? The ALTER TABLE statement is your solution. This guide details adding colu

Business Analyst vs. Data AnalystBusiness Analyst vs. Data AnalystApr 17, 2025 am 11:38 AM

Introduction Imagine a bustling office where two professionals collaborate on a critical project. The business analyst focuses on the company's objectives, identifying areas for improvement, and ensuring strategic alignment with market trends. Simu

What are COUNT and COUNTA in Excel? - Analytics VidhyaWhat are COUNT and COUNTA in Excel? - Analytics VidhyaApr 17, 2025 am 11:34 AM

Excel data counting and analysis: detailed explanation of COUNT and COUNTA functions Accurate data counting and analysis are critical in Excel, especially when working with large data sets. Excel provides a variety of functions to achieve this, with the COUNT and COUNTA functions being key tools for counting the number of cells under different conditions. Although both functions are used to count cells, their design targets are targeted at different data types. Let's dig into the specific details of COUNT and COUNTA functions, highlight their unique features and differences, and learn how to apply them in data analysis. Overview of key points Understand COUNT and COU

Chrome is Here With AI: Experiencing Something New Everyday!!Chrome is Here With AI: Experiencing Something New Everyday!!Apr 17, 2025 am 11:29 AM

Google Chrome's AI Revolution: A Personalized and Efficient Browsing Experience Artificial Intelligence (AI) is rapidly transforming our daily lives, and Google Chrome is leading the charge in the web browsing arena. This article explores the exciti

AI's Human Side: Wellbeing And The Quadruple Bottom LineAI's Human Side: Wellbeing And The Quadruple Bottom LineApr 17, 2025 am 11:28 AM

Reimagining Impact: The Quadruple Bottom Line For too long, the conversation has been dominated by a narrow view of AI’s impact, primarily focused on the bottom line of profit. However, a more holistic approach recognizes the interconnectedness of bu

5 Game-Changing Quantum Computing Use Cases You Should Know About5 Game-Changing Quantum Computing Use Cases You Should Know AboutApr 17, 2025 am 11:24 AM

Things are moving steadily towards that point. The investment pouring into quantum service providers and startups shows that industry understands its significance. And a growing number of real-world use cases are emerging to demonstrate its value out

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools