10
10

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.

Azure OpenAI Service で ChatGPT を REST API から使う

Last updated at Posted at 2023-04-04

※本記事は2023年4月4日時点での情報を元に書かれています。

はじめに

Azure OpenAI ServiceとTeamsの連携アプリを作りたいと思いREST APIの操作方法を調べていたのですが、過渡期なのか様々な情報があり、URIやBodyの正しい形式を見つけるのに苦労したので、備忘録としてシェアします。

Azure OpenAI Service の ChatGPT を呼ぶ REST API の例

  • メソッド: POST
  • ヘッダー:
    Content-type: application/json
    api-key: Azure Portal で取得したキーを入れます
URI
https://[AOAIのリソース名].openai.azure.com/openai/deployments/[AOAI上で作成したChatGPTのモデル名]/chat/completions?api-version=2023-03-15-preview
Body
{
    "messages": [
        {"role": "system", "content": "Assistant is a large language model trained by OpenAI."},
        {"role": "user", "content": "質問内容をここに記載"}
    ],
  "max_tokens": 800,
  "temperature": 0.7,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "top_p": 0.95,
  "stop": [
      "<|im_end|>"
  ]
}

記事投稿時点では上記内容で200 OKが返ってきます。

※最新のEndpoint URIはプレイグラウンドの画面上 コードの表示 から確認できます。
image.png

参考文献

10
10
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
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?