【入門】OpenAI APIを使って画像生成や音声の翻訳とテキスト書き起こしとかを試す

## 前置き
[【入門】OpenAI入門【はじめの一歩】](https://qiita.com/hedgehog051/items/4b3a59de773c1e05dfb3)の続き
今回はOpenAIのAPIを使って画像生成や音声のテキスト書き起こしを試したメモを放流

## OpenAIのAPIで出来ること
API Referenceがあるのでそれを参考に確認。

https://platform.openai.com/docs/api-reference

|出来ること|概要|
|---|---|
|List models|利用可能なモデルを一覧表示させる|
|Retrieve model|モデルに関する基本情報を取得|
|Completions|渡されたプロンプトから予測を生成して返す|
|Chat|チャットの会話を渡すと返答を返す|
|Edits|渡されたプロンプトに対して編集したものを返す|
|Create image|画像を生成|
|Create image edit|元となる画像とプロンプトにより、編集された画像を生成|
|Create image variation|元となる画像のバリエーションを生成して返す|
|Embeddings|入力テキストに対してベクトル数値を返す|
|Create transcription|元となる音声ファイルに対して入力言語に応じたテキストを返す|
|Create translation|元となる音声ファイルに対して英語に翻訳して返す|
|List files|Fine-tunesで用いるためのファイルのリストを表示|
|Upload file|Fine-tunesで用いるためのファイルをアップロードする|
|Delete file|ファイルを削除する|
|Retrieve file|特定のファイル情報を取得する|
|Retrieve file content|特定のファイルの内容を取得する|
|Create fine-tune|Fine-tunesジョブ(トレーニグデータに合わせたモデルのチューニング)を作成|
|List fine-tunes|Fine-tunesのリストを表示|
|Retrieve fine-tune|Fine-tunesジョブに関する情報を取得|
|Cancel fine-tune|Fine-tunesジョブのキャンセル|
|List fine-tune events|Fine-tunesジョブイベントの詳細ステータスを取得|
|Delete fine-tune model|Fine-tunesモデルの削除|
|Create moderation|モデレーションを作成|

## 事前準備
OpenAIのAPIKeyを取得して環境変数をセット

APIKeyの取得方法は[前回参照](https://qiita.com/hedgehog051/items/4b3a59de773c1e05dfb3)

```
OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxx
```

## モデルの一覧取得

お試しにモデル一覧を取得してみます。
結果が思ったよりも長かったのでjsonファイルとして出力させました。

- エンドポイント
`https://api.openai.com/v1/models`

```
curl https://api.openai.com/v1/models \
  -H "Authorization: Bearer $OPENAI_API_KEY" > listmodel.json
```

↓あまりに長かったので折りたたんでます
<details>
<summary>listmodel.json</summary>
{
  "object": "list",
  "data": [
    {
      "id": "babbage",
      "object": "model",
      "created": 1649358449,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-49FUp5v084tBB49tC4z8LPH5",
          "object": "model_permission",
          "created": 1669085501,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "babbage",
      "parent": null
    },
    {
      "id": "davinci",
      "object": "model",
      "created": 1649359874,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-U6ZwlyAd0LyMk4rcMdz33Yc3",
          "object": "model_permission",
          "created": 1669066355,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci",
      "parent": null
    },
    {
      "id": "babbage-code-search-code",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-4qRnA3Hj8HIJbgo0cGbcmErn",
          "object": "model_permission",
          "created": 1669085863,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "babbage-code-search-code",
      "parent": null
    },
    {
      "id": "text-similarity-babbage-001",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-48kcCHhfzvnfY84OtJf5m8Cz",
          "object": "model_permission",
          "created": 1669081947,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-similarity-babbage-001",
      "parent": null
    },
    {
      "id": "text-davinci-001",
      "object": "model",
      "created": 1649364042,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-MVM5NfoRjXkDve3uQW3YZDDt",
          "object": "model_permission",
          "created": 1669066355,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-davinci-001",
      "parent": null
    },
    {
      "id": "ada",
      "object": "model",
      "created": 1649357491,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-u0nKN4ub7EVQudgMuvCuvDjc",
          "object": "model_permission",
          "created": 1675997661,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "ada",
      "parent": null
    },
    {
      "id": "curie-instruct-beta",
      "object": "model",
      "created": 1649364042,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-JlSyMbxXeFm42SDjN0wTD26Y",
          "object": "model_permission",
          "created": 1669070162,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "curie-instruct-beta",
      "parent": null
    },
    {
      "id": "babbage-code-search-text",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-Lftf8H4ZPDxNxVs0hHPJBUoe",
          "object": "model_permission",
          "created": 1669085863,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "babbage-code-search-text",
      "parent": null
    },
    {
      "id": "babbage-similarity",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-mS20lnPqhebTaFPrcCufyg7m",
          "object": "model_permission",
          "created": 1669081947,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "babbage-similarity",
      "parent": null
    },
    {
      "id": "code-search-babbage-text-001",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-EC5ASz4NLChtEV1Cwkmrwm57",
          "object": "model_permission",
          "created": 1669085863,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "code-search-babbage-text-001",
      "parent": null
    },
    {
      "id": "code-cushman-001",
      "object": "model",
      "created": 1656081837,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-M6pwNXr8UmY3mqdUEe4VFXdY",
          "object": "model_permission",
          "created": 1669066355,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "code-cushman-001",
      "parent": null
    },
    {
      "id": "gpt-3.5-turbo",
      "object": "model",
      "created": 1677610602,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-yIbMckVR4dabPwbxRgyyH8x6",
          "object": "model_permission",
          "created": 1678904782,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "gpt-3.5-turbo",
      "parent": null
    },
    {
      "id": "code-search-babbage-code-001",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-64LWHdlANgak2rHzc3K5Stt0",
          "object": "model_permission",
          "created": 1669085864,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "code-search-babbage-code-001",
      "parent": null
    },
    {
      "id": "text-ada-001",
      "object": "model",
      "created": 1649364042,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-KN5dRBCEW4az6gwcGXkRkMwK",
          "object": "model_permission",
          "created": 1669088497,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-ada-001",
      "parent": null
    },
    {
      "id": "text-embedding-ada-002",
      "object": "model",
      "created": 1671217299,
      "owned_by": "openai-internal",
      "permission": [
        {
          "id": "modelperm-Dbv2FOgMdlDjO8py8vEjD5Mi",
          "object": "model_permission",
          "created": 1678892857,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-embedding-ada-002",
      "parent": null
    },
    {
      "id": "gpt-3.5-turbo-0301",
      "object": "model",
      "created": 1677649963,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-6l8Irp7xKyFvhhfzhhjP5kMu",
          "object": "model_permission",
          "created": 1678904784,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "gpt-3.5-turbo-0301",
      "parent": null
    },
    {
      "id": "text-similarity-ada-001",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-DdCqkqmORpqxqdg4TkFRAgmw",
          "object": "model_permission",
          "created": 1669092759,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-similarity-ada-001",
      "parent": null
    },
    {
      "id": "text-davinci-insert-002",
      "object": "model",
      "created": 1649880484,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-V5YQoSyiapAf4km5wisXkNXh",
          "object": "model_permission",
          "created": 1669066354,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-davinci-insert-002",
      "parent": null
    },
    {
      "id": "ada-code-search-code",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-wa8tg4Pi9QQNaWdjMTM8dkkx",
          "object": "model_permission",
          "created": 1669087421,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "ada-code-search-code",
      "parent": null
    },
    {
      "id": "ada-similarity",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-LtSIwCEReeDcvGTmM13gv6Fg",
          "object": "model_permission",
          "created": 1669092759,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "ada-similarity",
      "parent": null
    },
    {
      "id": "whisper-1",
      "object": "model",
      "created": 1677532384,
      "owned_by": "openai-internal",
      "permission": [
        {
          "id": "modelperm-QHBiJ9UEYGPIpMjIfxJ3XqtJ",
          "object": "model_permission",
          "created": 1678738967,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "whisper-1",
      "parent": null
    },
    {
      "id": "text-davinci-003",
      "object": "model",
      "created": 1669599635,
      "owned_by": "openai-internal",
      "permission": [
        {
          "id": "modelperm-11XYRd8qhdjcS0OA4fkco19K",
          "object": "model_permission",
          "created": 1678585020,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-davinci-003",
      "parent": null
    },
    {
      "id": "code-search-ada-text-001",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-JBssaJSmbgvJfTkX71y71k2J",
          "object": "model_permission",
          "created": 1669087421,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "code-search-ada-text-001",
      "parent": null
    },
    {
      "id": "text-search-ada-query-001",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-1YiiBMYC8it0mpQCBK7t8uSP",
          "object": "model_permission",
          "created": 1669092640,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-ada-query-001",
      "parent": null
    },
    {
      "id": "text-curie-001",
      "object": "model",
      "created": 1649364043,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-fGAoEKBH01KNZ3zz81Sro34Q",
          "object": "model_permission",
          "created": 1669066352,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-curie-001",
      "parent": null
    },
    {
      "id": "text-davinci-edit-001",
      "object": "model",
      "created": 1649809179,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-VzNMGrIRm3HxhEl64gkjZdEh",
          "object": "model_permission",
          "created": 1669066354,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-davinci-edit-001",
      "parent": null
    },
    {
      "id": "davinci-search-document",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-M43LVJQRGxz6ode34ctLrCaG",
          "object": "model_permission",
          "created": 1669066355,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci-search-document",
      "parent": null
    },
    {
      "id": "ada-code-search-text",
      "object": "model",
      "created": 1651172510,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-kFc17wOI4d1FjZEaCqnk4Frg",
          "object": "model_permission",
          "created": 1669087421,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "ada-code-search-text",
      "parent": null
    },
    {
      "id": "text-search-ada-doc-001",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-kbHvYouDlkD78ehcmMOGdKpK",
          "object": "model_permission",
          "created": 1669092640,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-ada-doc-001",
      "parent": null
    },
    {
      "id": "code-davinci-edit-001",
      "object": "model",
      "created": 1649880484,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-WwansDxcKNvZtKugNqJnsvfv",
          "object": "model_permission",
          "created": 1669066354,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "code-davinci-edit-001",
      "parent": null
    },
    {
      "id": "davinci-instruct-beta",
      "object": "model",
      "created": 1649364042,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-k9kuMYlfd9nvFiJV2ug0NWws",
          "object": "model_permission",
          "created": 1669066356,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci-instruct-beta",
      "parent": null
    },
    {
      "id": "code-davinci-002",
      "object": "model",
      "created": 1649880485,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-4AiPCxsg2skckHgRj2KeeTW5",
          "object": "model_permission",
          "created": 1678830868,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "code-davinci-002",
      "parent": null
    },
    {
      "id": "text-similarity-curie-001",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-6dgTTyXrZE7d53Licw4hYkvd",
          "object": "model_permission",
          "created": 1669079883,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-similarity-curie-001",
      "parent": null
    },
    {
      "id": "code-search-ada-code-001",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-8soch45iiGvux5Fg1ORjdC4s",
          "object": "model_permission",
          "created": 1669087421,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "code-search-ada-code-001",
      "parent": null
    },
    {
      "id": "ada-search-query",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-b753xmIzAUkluQ1L20eDZLtQ",
          "object": "model_permission",
          "created": 1669092640,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "ada-search-query",
      "parent": null
    },
    {
      "id": "text-search-davinci-query-001",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-9McKbsEYSaDshU9M3bp6ejUb",
          "object": "model_permission",
          "created": 1669066353,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-davinci-query-001",
      "parent": null
    },
    {
      "id": "curie-search-query",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-sIbfSwzVpVBtymQgOQSLBpxe",
          "object": "model_permission",
          "created": 1677273417,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "curie-search-query",
      "parent": null
    },
    {
      "id": "davinci-search-query",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-lYkiTZMmJMWm8jvkPx2duyHE",
          "object": "model_permission",
          "created": 1669066353,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci-search-query",
      "parent": null
    },
    {
      "id": "text-davinci-insert-001",
      "object": "model",
      "created": 1649880484,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-3gRQMBOMoccZIURE3ZxboZWA",
          "object": "model_permission",
          "created": 1669066354,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-davinci-insert-001",
      "parent": null
    },
    {
      "id": "babbage-search-document",
      "object": "model",
      "created": 1651172510,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-5qFV9kxCRGKIXpBEP75chmp7",
          "object": "model_permission",
          "created": 1669084981,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "babbage-search-document",
      "parent": null
    },
    {
      "id": "ada-search-document",
      "object": "model",
      "created": 1651172507,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-8qUMuMAbo4EwedbGamV7e9hq",
          "object": "model_permission",
          "created": 1669092640,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "ada-search-document",
      "parent": null
    },
    {
      "id": "text-search-curie-query-001",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-Iion0NCpsXPNtIkQ0owQLi7V",
          "object": "model_permission",
          "created": 1677273417,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-curie-query-001",
      "parent": null
    },
    {
      "id": "text-search-babbage-doc-001",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-ao2r26P2Th7nhRFleHwy2gn5",
          "object": "model_permission",
          "created": 1669084981,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-babbage-doc-001",
      "parent": null
    },
    {
      "id": "text-davinci-002",
      "object": "model",
      "created": 1649880484,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-kOLsgLs7IgI9PTPI245IRWZH",
          "object": "model_permission",
          "created": 1676585871,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-davinci-002",
      "parent": null
    },
    {
      "id": "curie-search-document",
      "object": "model",
      "created": 1651172508,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-LDsN5wW8eKVuh1OsyciHntE9",
          "object": "model_permission",
          "created": 1677273417,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "curie-search-document",
      "parent": null
    },
    {
      "id": "text-search-curie-doc-001",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-taUGRSku7bQLa24SNIwYPEsi",
          "object": "model_permission",
          "created": 1677273417,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-curie-doc-001",
      "parent": null
    },
    {
      "id": "babbage-search-query",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-wSs1hMXDKsrcErlbN8HmzlLE",
          "object": "model_permission",
          "created": 1669084981,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "babbage-search-query",
      "parent": null
    },
    {
      "id": "text-babbage-001",
      "object": "model",
      "created": 1649364043,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-a3Ph5FIBbJxsoA4wvx7VYC7R",
          "object": "model_permission",
          "created": 1675105935,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-babbage-001",
      "parent": null
    },
    {
      "id": "text-search-davinci-doc-001",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-qhSf1j2MJMujcu3t7cHnF1DN",
          "object": "model_permission",
          "created": 1669066353,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-davinci-doc-001",
      "parent": null
    },
    {
      "id": "text-search-babbage-query-001",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-Kg70kkFxD93QQqsVe4Zw8vjc",
          "object": "model_permission",
          "created": 1669084981,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-search-babbage-query-001",
      "parent": null
    },
    {
      "id": "curie-similarity",
      "object": "model",
      "created": 1651172510,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-zhWKExSloaQiJgzjVHFmh2wR",
          "object": "model_permission",
          "created": 1675106290,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "curie-similarity",
      "parent": null
    },
    {
      "id": "curie",
      "object": "model",
      "created": 1649359874,
      "owned_by": "openai",
      "permission": [
        {
          "id": "modelperm-oPaljeveTjEIDbhDjzFiyf4V",
          "object": "model_permission",
          "created": 1675106503,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "curie",
      "parent": null
    },
    {
      "id": "text-similarity-davinci-001",
      "object": "model",
      "created": 1651172505,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-OvmcfYoq5V9SF9xTYw1Oz6Ue",
          "object": "model_permission",
          "created": 1669066356,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-similarity-davinci-001",
      "parent": null
    },
    {
      "id": "davinci-similarity",
      "object": "model",
      "created": 1651172509,
      "owned_by": "openai-dev",
      "permission": [
        {
          "id": "modelperm-lYYgng3LM0Y97HvB5CDc8no2",
          "object": "model_permission",
          "created": 1669066353,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": true,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci-similarity",
      "parent": null
    },
    {
      "id": "cushman:2020-05-03",
      "object": "model",
      "created": 1590625110,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-FAup8P1KqclNlTsunLDRiesT",
          "object": "model_permission",
          "created": 1590625111,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": true,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "cushman:2020-05-03",
      "parent": null
    },
    {
      "id": "ada:2020-05-03",
      "object": "model",
      "created": 1607631625,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-9TYofAqUs54vytKYL0IX91rX",
          "object": "model_permission",
          "created": 1607631626,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "ada:2020-05-03",
      "parent": null
    },
    {
      "id": "babbage:2020-05-03",
      "object": "model",
      "created": 1607632611,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-jaLAcmyyNuaVmalCE1BGTGwf",
          "object": "model_permission",
          "created": 1607632613,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "babbage:2020-05-03",
      "parent": null
    },
    {
      "id": "curie:2020-05-03",
      "object": "model",
      "created": 1607632725,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-bt6R8PWbB2SwK5evFo0ZxSs4",
          "object": "model_permission",
          "created": 1607632727,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "curie:2020-05-03",
      "parent": null
    },
    {
      "id": "davinci:2020-05-03",
      "object": "model",
      "created": 1607640163,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-99cbfQTYDVeLkTYndX3UMpSr",
          "object": "model_permission",
          "created": 1607640164,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci:2020-05-03",
      "parent": null
    },
    {
      "id": "if-davinci-v2",
      "object": "model",
      "created": 1610745990,
      "owned_by": "openai",
      "permission": [
        {
          "id": "snapperm-58q0TdK2K4kMgL3MoHvGWMlH",
          "object": "model_permission",
          "created": 1610746036,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "if-davinci-v2",
      "parent": null
    },
    {
      "id": "if-curie-v2",
      "object": "model",
      "created": 1610745968,
      "owned_by": "openai",
      "permission": [
        {
          "id": "snapperm-fwAseHVq6NGe6Ple6tKfzRSK",
          "object": "model_permission",
          "created": 1610746043,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "if-curie-v2",
      "parent": null
    },
    {
      "id": "if-davinci:3.0.0",
      "object": "model",
      "created": 1629420755,
      "owned_by": "openai",
      "permission": [
        {
          "id": "snapperm-T53lssiyMWwiuJwhyO9ic53z",
          "object": "model_permission",
          "created": 1629421809,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": true,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "if-davinci:3.0.0",
      "parent": null
    },
    {
      "id": "davinci-if:3.0.0",
      "object": "model",
      "created": 1629498070,
      "owned_by": "openai",
      "permission": [
        {
          "id": "snapperm-s6ZIAVMwlZwrLGGClTXqSK3Q",
          "object": "model_permission",
          "created": 1629498084,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": true,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci-if:3.0.0",
      "parent": null
    },
    {
      "id": "davinci-instruct-beta:2.0.0",
      "object": "model",
      "created": 1629501914,
      "owned_by": "openai",
      "permission": [
        {
          "id": "snapperm-c70U4TBfiOD839xptP5pJzyc",
          "object": "model_permission",
          "created": 1629501939,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": true,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "davinci-instruct-beta:2.0.0",
      "parent": null
    },
    {
      "id": "text-ada:001",
      "object": "model",
      "created": 1641949608,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-d2PSnwFG1Yn9of6PvrrhkBcU",
          "object": "model_permission",
          "created": 1641949610,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-ada:001",
      "parent": null
    },
    {
      "id": "text-davinci:001",
      "object": "model",
      "created": 1641943966,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-Fj1O3zkKXOQy6AkcfQXRKcWA",
          "object": "model_permission",
          "created": 1641944340,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-davinci:001",
      "parent": null
    },
    {
      "id": "text-curie:001",
      "object": "model",
      "created": 1641955047,
      "owned_by": "system",
      "permission": [
        {
          "id": "snapperm-BI9TAT6SCj43JRsUb9CYadsz",
          "object": "model_permission",
          "created": 1641955123,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-curie:001",
      "parent": null
    },
    {
      "id": "text-babbage:001",
      "object": "model",
      "created": 1642018370,
      "owned_by": "openai",
      "permission": [
        {
          "id": "snapperm-7oP3WFr9x7qf5xb3eZrVABAH",
          "object": "model_permission",
          "created": 1642018480,
          "allow_create_engine": false,
          "allow_sampling": true,
          "allow_logprobs": true,
          "allow_search_indices": false,
          "allow_view": true,
          "allow_fine_tuning": false,
          "organization": "*",
          "group": null,
          "is_blocking": false
        }
      ],
      "root": "text-babbage:001",
      "parent": null
    }
  ]
}
</details>

## Completions①

- エンドポイント
`https://api.openai.com/v1/completions`

以下のプロパティで実行
|model|max_tokens|temperature|
|---|---|---|
|text-davinci-003|500|0.6|

```
curl https://api.openai.com/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "text-davinci-003",
    "prompt": "ねこについて教えて",
    "max_tokens": 500,
    "temperature": 0.6
  }'
```

### 結果
```json
{
    "id":"cmpl-6wQJgOz1NsTc93cWj6E0vKvXww5Sj",
    "object":"text_completion",
    "created":1679382204,
    "model":"text-davinci-003",
    "choices":[{
        "text":"ください\n\n猫は、古くから人々の間で愛されてきた家畜です。猫は、活発で好奇心旺盛な動物で、人間の周囲で活動します。猫は、自分の好きなものを求めて独自の活動を行います。猫には、毛並みの美しさや可愛らしさ、そして楽しい振る舞いが特徴です。また、猫は、自分の主人を守り、家にいる他の人々を慰めたり励ましたりすることもできます。",
        "index":0,
        "logprobs":null,
        "finish_reason":"stop"
    }],
    "usage":{
        "prompt_tokens":13,
        "completion_tokens":234,
        "total_tokens":247
    }
}
```

## Completions②

- エンドポイント
`https://api.openai.com/v1/completions`

以下のプロパティで実行
**※max_tokensを500から50に変更**
|model|max_tokens|temperature|
|---|---|---|
|text-davinci-003|50|0.6|

```
curl https://api.openai.com/v1/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "text-davinci-003",
    "prompt": "ねこについて教えて",
    "max_tokens": 50,
    "temperature": 0.6
  }'
```

### 結果
max_tokensの値を小さくしたので**choices**の**text**レスポンス文も短くなりました。

```json
{
    "id":"cmpl-6wQJgOz1NsTc93cWj6E0vKvXww5Sj",
    "object":"text_completion",
    "created":1679382540,
    "model":"text-davinci-003",
    "choices":[{
        "text":"ください\n\n猫は、古くから人間と共に暮らしてきた動物です。体長は20〜40セン",
        "index":0,
        "logprobs":null,
        "finish_reason":"stop"
    }],
    "usage":{
        "prompt_tokens":13,
        "completion_tokens":50,
        "total_tokens":63
    }
}
```

## Generations①

- エンドポイント
`https://api.openai.com/v1/images/generations`

以下のプロパティで実行
※sizeは**256x256**、**512x512**、**1024x1024**が対応
※nで生成数を指定します。
|prompt|n|size|
|---|---|---|
|3匹の子猫|1|512x512|

```
curl https://api.openai.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "prompt": "3匹の子猫",
    "n": 1,
    "size": "512x512"
  }'
```

### 結果
```
{
  "created": 1679382879,
  "data": [
    {
      "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-SqGU1dqkLg8g9Ody7Ml4M6dY/user-jtzfSHyU8hN3sppSNiFFlLED/img-BmwXUB1vz3AMw8bauAYASEDq.png?st=2023-03-21T06%3A14%3A39Z&se=2023-03-21T08%3A14%3A39Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-21T04%3A47%3A46Z&ske=2023-03-22T04%3A47%3A46Z&sks=b&skv=2021-08-06&sig=cRD37OwyZOCY1E9M2HW78LmLoedIT8vedtPpw2m%2Bmgk%3D"
    }
  ]
}
```

### 生成された猫画像
![img-BmwXUB1vz3AMw8bauAYASEDq.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/354022/45b58ecd-06fe-4a34-8c3a-d4f0acda4b2d.png)

## Generations②

- エンドポイント
`https://api.openai.com/v1/images/generations`

以下のプロパティで実行
※もう少し可愛いのが欲しいのでpromptを**3匹の可愛い子猫**に変更して再度実行
sizeも**1024x1024**に変更
|prompt|n|size|
|---|---|---|
|3匹の可愛い子猫|1|1024x1024|

```
curl https://api.openai.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "prompt": "3匹の可愛い子猫",
    "n": 1,
    "size": "512x512"
  }'
```

### 結果
```
{
  "created": 1678968882,
  "data": [
    {
      "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-SqGU1dqkLg8g9Ody7Ml4M6dY/user-jtzfSHyU8hN3sppSNiFFlLED/img-Jl8N65rQd5QdK9OX6p3RnvqE.png?st=2023-03-16T11%3A14%3A42Z&se=2023-03-16T13%3A14%3A42Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-15T23%3A05%3A41Z&ske=2023-03-16T23%3A05%3A41Z&sks=b&skv=2021-08-06&sig=cF4be6s5LIbvslktMpDplmHBmTi2f/AOLMu0Ejo57qg%3D"
    }
  ]
}
```

### 生成された猫画像
可愛いのが生成されたので大勝利
![img-Jl8N65rQd5QdK9OX6p3RnvqE (1).png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/354022/6eef50df-277b-5065-a3a5-5fc8bc05eacf.png)

## Variations

- エンドポイント
`https://api.openai.com/v1/images/variations`

以下のプロパティで実行
カレントに先程の画像(**neko.png**)をおいて実行
バリエーションを2つ生成
|image|n|size|
|---|---|---|
|neko.png|2|1024x1024|

```
curl https://api.openai.com/v1/images/variations \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F image="@neko.png" \
  -F n=2 \
  -F size="1024x1024"
```

### 結果
```
{
  "created": 1678969111,
  "data": [
    {
      "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-SqGU1dqkLg8g9Ody7Ml4M6dY/user-jtzfSHyU8hN3sppSNiFFlLED/img-Q6SwvQkbQjfujX5tmqYUErdH.png?st=2023-03-16T11%3A18%3A31Z&se=2023-03-16T13%3A18%3A31Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-15T21%3A20%3A15Z&ske=2023-03-16T21%3A20%3A15Z&sks=b&skv=2021-08-06&sig=P4nNiQzy2QtTleXsS6IqD%2BiDUZlbVAAsT9qwagcwk0I%3D"
    },
    {
      "url": "https://oaidalleapiprodscus.blob.core.windows.net/private/org-SqGU1dqkLg8g9Ody7Ml4M6dY/user-jtzfSHyU8hN3sppSNiFFlLED/img-oaXslQh6P7O1SdE72cKDAo21.png?st=2023-03-16T11%3A18%3A31Z&se=2023-03-16T13%3A18%3A31Z&sp=r&sv=2021-08-06&sr=b&rscd=inline&rsct=image/png&skoid=6aaadede-4fb3-4698-a8f6-684d7786b067&sktid=a48cca56-e6da-484e-a814-9c849652bcb3&skt=2023-03-15T21%3A20%3A15Z&ske=2023-03-16T21%3A20%3A15Z&sks=b&skv=2021-08-06&sig=21wzcLJt4UNc1X%2Bp7S6S4bPgdnNOixgHwEd6tiWqxtM%3D"
    }
  ]
}
```

### 生成されたバリエーション
構成はほぼ同じですが猫が向いている方向などやや違うバリエーションが生成されました
- バリエーション1
![img-Q6SwvQkbQjfujX5tmqYUErdH (1) (1).png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/354022/d6d5be10-0c41-ee38-1925-5c6ebfae4e76.png)


- バリエーション2
![img-oaXslQh6P7O1SdE72cKDAo21 (1).png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/354022/5f966909-b8b4-cbe5-2bbd-7a26cf0a2abc.png)

## Transcriptions

- エンドポイント
`https://api.openai.com/v1/audio/transcriptions`

以下のプロパティで実行
カレントにテキスト起こしさせたい音声ファイル(**audio.mp3**)をおいて実行
[サンプル音声](http://pro-video.jp/voice/announce/)
|file|model|
|---|---|
|audio.mp3|whisper-1|

```
curl https://api.openai.com/v1/audio/transcriptions \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@audio.mp3" \
  -F model="whisper-1"
```

### 結果
```
{
    "text":"海外旅行に行きたいけど、なかなか休みも取れないし、流行りの店にも飽きちゃった。 親子でアウトドア体験もいいけど、用意も必要、なかなか一歩が踏み出せない。 アンディは困っていました。息子のケンがテレビで見たアメリカのバーベキューを食べたいというのです。 アメリカのバーベキューはワイルドだ。じいちゃんがよくやってくれたと思い出話をしてたせいでしょうか。"
}% 
```


## Translations

- エンドポイント
`https://api.openai.com/v1/audio/translations`

以下のプロパティで実行
英語翻訳させたい音声ファイル(**audio.mp3**)をおいて実行
[サンプル音声](http://pro-video.jp/voice/announce/)
|file|model|
|---|---|
|audio.mp3|whisper-1|

```
curl https://api.openai.com/v1/audio/translations \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: multipart/form-data" \
  -F file="@audio.mp3" \
  -F model="whisper-1"
```

### 結果
```
{
    "text":"I want to go on a trip abroad, but I can't take a break and I'm tired of the trendy restaurants. It's good to have an outdoor experience with your parents, but you need to be prepared. It's hard to take a step forward. Andy was in trouble. His son Ken wants to eat American barbecue that he saw on TV. American barbecue is wild. Is it because he was talking about his memories that his grandfather did it well?"
}%   
```

### DeePLで再翻訳
どっちも性能が良すぎる...
![スクリーンショット 2023-03-21 16.39.40.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/354022/af852fed-1106-7060-218f-96ae54dd877b.png)

## おわり
今回はOpenAIのAPIの中でも特にイメージのつきやすいものをシンプルにCURLで実行してその一端に触れてみました。純粋にAIの性能の高さに驚かされたのと面白みと可能性を感じる部分だと思いました。次回はChatGPTも使いつつこれらをアプリケーションに組み込んで実行したものを投稿したいと思います。

## Devトーク
弊社でQiitaのDevトークを活用しています。
それぞれのテーマについて雑談してみたい方がいましたら是非お話しましょう!

https://jobs.qiita.com/dev_talks?employer=608&utm_campaign=organization-nav-bar&utm_medium=referral&utm_source=qiita