DEV Community

UEDA Akira
UEDA Akira

Posted on

Practical Guide to Developing a ChatGPT Plugin: A Case Study of Sakenowa

We've just released the Sakenowa ChatGPT plugin. It's a plugin that utilizes data from Sakenowa to provide detailed information about different brands of Japanese sake and offer recommendations.

Sakenowa on the plugin store

This article shares the challenges, insights, and developer perspectives we encountered during the development of the ChatGPT plugin. We hope this can be of help to those planning to embark on their own development journey.

Local Development

During development, it's okay to deploy the API server in your local environment.

In a production environment, ChatGPT's server communicates with the API server as follows:

Production environment

In a local environment, the browser communicates directly:

Local environment

Because the browser communicates with the API server from the ChatGPT page (chat.openai.com), it is necessary to set up CORS on the API server.

Authentication

The authentication method for the API server is specified in the manifest file (ai-plugin.json). In the Sakenowa ChatGPT plugin, we used service_http. A pre-registered key is set as a Bearer token in the Authorization header, which you can confirm on the API side.

Example of an Authorization header:

Authorization: Bearer <API-KEY>
Enter fullscreen mode Exit fullscreen mode

The key is registered during the plugin application process.

Manifest File

The manifest file (ai-plugin.json) needs to be deployed as /.well-known/ai-plugin.json on the public server.

There are people who have compiled various plugin manifest files and API specification files: https://github.com/sisbell/chatgpt-plugin-store

As can be seen here, most plugins are accessible to anyone. However, as long as the plugin can be accessed from the ChatGPT server, it's sufficient, and access can be restricted. The range of IP addresses used by ChatGPT's server is listed in the ChatGPT plugin documentation.

According to ChatGPT's Plugin devtools, the description_for_model value in the manifest file is embedded directly into the prompt, so there's little point in hiding it. There's no guarantee that other parts of the manifest file won't be embedded in the future. You should only include information in the manifest file that you are willing to make public.

By the way, the part embedded in the prompt can be answered by asking ChatGPT. The Sakenowa ChatGPT plugin doesn't publicly release its manifest file, but ChatGPT can provide the information.

description of the plugin

API Specification File

According to ChatGPT Plugin devtools, the contents of the API specification file are converted to TypeScript and embedded into the prompt. For the Sakenowa ChatGPT plugin, the content is embedded as follows (slightly abbreviated):

namespace sakenowa {
// Search brands by query
type search__brands = (_: {
// query string that will match with brand name. Can be Japanese name (Kanji or Hiragana), English name and also part of them.
brand?: string,
// search by area. It should be official Japanese prefecture numbers
area?: number[],
)} => any;
} // namespace sakenowa
Enter fullscreen mode Exit fullscreen mode

While the return type is defined in the API specification file and should be an essential piece of information for selecting the optimal endpoint, it is set to any here. Even though array length limitations are specified in the API specification file, they don't appear here. However, the description values seem to be output as comments, so it may be beneficial to write information here.

This format suggests that information like the API server's URL won't be embedded in the prompt. But, as the future is uncertain, you need to treat it as potentially public. Also, access can be restricted to only ChatGPT's server by specifying an IP address range.

API spec

Going Public! How to Get Users?

As of May 29, 2023, the review process is stated to be completed within seven days after application. The Sakenowa ChatGPT plugin took exactly seven days.

After going public, we issued a press release. Typically, for a smartphone app, we would provide the store's URL for users to access it directly. However, the ChatGPT plugin store does not have a URL. Additionally, since there is no search function, users will need to locate the plugin from a list that spans approximately 20 pages. We anticipate improvements in this area soon.

Re-verification

If you change the manifest file after the plugin has been approved and listed in the store, it will be removed from the store and re-verification will be required. From what I've heard, the current situation is as follows:

  • Even if the plugin is removed from the store, users who are already using it can continue to do so.
  • The time it takes for re-verification varies, sometimes it's three days, but other times it can take up to a week.

This issue is being discussed in OpenAI's forum, so I believe it will be improved eventually. However, for now, you need to understand that changing the manifest file after release is a challenging task.

Conclusion

The official documentation for ChatGPT plugin development is well-written, so you're unlikely to struggle due to a lack of information. However, there are difficulties that developers may encounter, such as the re-verification process after going public.

In this article, I've shared knowledge and experience gained during the development of the Sakenowa ChatGPT plugin. I hope this can serve as a supplement to the official documentation, and prove useful for those about to develop a ChatGPT plugin.

Top comments (0)