この記事の目的
公式ドキュメントにはリファレンスが記載されているが、実行するとき毎回変換する必要があるため、備忘の為、記載する
実行するAPI
Azure AI FoundryにデプロイしたPhi-4モデルを呼び出すのREST API である chat-completions APIを実行する
Azure AI Foundry から確認できるREST API
実行方法
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
