GPT-4-Vision in Powershell - base64 works but URL does not

Thanks for getting back to me, I think I sorted it myself between when I asked and when you answered. For posterity though I came up with:


   $b64 = [convert]::ToBase64String((get-content -path $path -Encoding byte))


...

        $obody = @{
            model = "gpt-4-vision-preview"
            messages = @(
                @{
                    role = "user"
                    content = @(
                        @{
                            type = "text"
                            text = "summary"
                        },
                        @{
                            type = "image_url"
                            image_url = @{
                                url = "data:image/png;base64,$b64"
                            }
                        }
                    )
                }
            )
            max_tokens = 300
        } | ConvertTo-Json -Depth 10



        $url = "https://api.openai.com/v1/chat/completions"
        $response = Invoke-RestMethod -Method POST -Uri $url -Headers $oheaders -body $obody -ContentType application/json