0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Azure AI Foundry にデプロイした Phi-4モデルをPowerShell で呼び出す

Posted at

この記事の目的

公式ドキュメントにはリファレンスが記載されているが、実行するとき毎回変換する必要があるため、備忘の為、記載する

実行するAPI

Azure AI FoundryにデプロイしたPhi-4モデルを呼び出すのREST API である chat-completions APIを実行する

Azure AI Foundry から確認できるREST API

image.png

実行方法

PowerShell の Invoke-RestMethod を使用して実行する

実行例

$key = "<api key>"
$Resource = "<Resource 名>"
$apiversion = "<REST APIのバージョン>" #2024-05-01-preview
$url = "https://$Resource.services.ai.azure.com/models/chat/completions?api-version=$apiversion"
$headers = @{}
$headers["Content-Type"]  = "application/json"
$headers["api-key"] = "$key"
$body = '{
  "messages": [{"role":"system","content":"You are an AI assistant that helps people find information."},{"role":"user","content":"test"}],
  "model": "Phi-4",
  "max_tokens": 2048,
  "temperature": 0.8,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "top_p": 0.1
}'

$response = Invoke-RestMethod -Uri $url -Method POST -Headers $headers -Body $body
$response.choices.message
0
0
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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?