2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【カスタムGPTs】actions機能を使ってWebAPIを呼び出し、映画推薦GPTを作る!

Last updated at Posted at 2024-01-18

はじめに

GPTsが使えるようになったので、どうせなら面白いAPIを使ってカスタムGPTを作りたい! ということでTMBDのWebAPIを呼び出し、最近のトレンド映画をおすすめしてくれる"Movie Friend"というカスタムGPTを開発しました。この記事ではその過程を通してカスタムGPTにWebAPIを導入する方法を紹介します。

作成したGPTはこちらです。

※ この記事では、既にGPTの基本設定が完了していることを前提とします。基本設定については別の記事で紹介しています。

TMBDのAPIkeyの取得

今回使用したのはTMBDのAPIです。

  1. Get API Keyをクリック
    image.png

  2. 取得したAPIキーは安全に保管してください
    image.png

APIの導入方法

  1. Create new actionをクリック
    image.png

  2. AuthenticationにAPIKeyを入力
    ※ Bearer認証を用いるので、APIKeyとBearerを選択してください。
    image.png

  3. SchemaExampleをWetherに変更
    image.png

  4. Schemaの各項目を編集
    TMBDで最新の映画の情報を取り出すエンドポイントを指定するURLは
    https://api.themoviedb.org/3/trending/all/day
    これをSchemaで指定していきます。以下のように記入します。

{
  "openapi": "3.1.0",
  "info": {
    "title": "Get Movie Information",
    "description": "Retrieves movie information from the movie db api",
    "version": "v1.0.0"
  },
  "servers": [
    {
      "url": "https://api.themoviedb.org"
    }
  ],
  "paths": {
    "/3/trending/all/day": {
      "get": {
        "description": "Get the trending movies for today",
        "operationId": "GetTrendingMoviesToday",
        "deprecated": false
      }
    }
  },
  "components": {
    "schemas": {}
  }
}

動作を確認

プレビューで動作を確認します。
最初はエンドポイントへの接続に許可が必要なので確認が出てきたらAllowを選択してください。
映画が推薦されたら完成です🎉

スクリーンショット 2024-01-18 12.29.51.png

公開設定

SaveUpdateを行う際、Anyone with a linkEveryoneを選択すると以下のようにエラーが表示されるはずです。

TMBCのプライバシーポリシーのURL( https://www.themoviedb.org/privacy-policy ) をActionsの設定画面に追加してください。

image.png

これで、全ての範囲で公開ができるようになるはずです!

最後に

APIが使えると開発の幅がグッと広がりますね!これからも様々な面白いGPTを開発していきたいと思います。

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?