Last active
September 20, 2024 02:02
-
-
Save dfinke/75c0b31605b39b43f06568abaf581f8e to your computer and use it in GitHub Desktop.
PowerShell script for querying AI models via GitHub API and retrieving chat completions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$prompt = "capital of france?" | |
$model = "gpt-4o-mini" | |
# $model = "o1-preview" | |
$headers = @{ | |
"Content-Type" = "application/json" | |
"Authorization" = "Bearer $($env:GITHUB_TOKEN)" | |
} | |
$body = @{ | |
"messages" = @(@{"role" = "user"; "content" = $prompt }) | |
"model" = $model | |
} | |
$result = Invoke-RestMethod -Method Post -Uri "https://models.inference.ai.azure.com/chat/completions" -Headers $headers -Body ($body | ConvertTo-Json) | |
$result.choices[0].message.content |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment