It's not clear to me exactly why this is happening (and I think it's probably a bug somewhere in the stack) but it seems to be a Powershell-specific thing, not a curl-specific thing. I wrote a little test program that looks like this:
using System;
namespace argvtest
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
int i = 0;
foreach (var arg in args) {
Console.WriteLine(i++ + ": " + arg);
}
}
}
}
After that, I tried running your command as stated, but through my test program:
PS C:\Users\PervonZweigbergk\repos\argvtest\bin\Debug\netcoreapp3.0> .\argvtest.exe "https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01" "-H" "Content-Type: application/json" "-H" "api-key: keygoeshere" "-d" '{"prompt": "tell me a funny story" }'
Hello World!
0: https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01
1: -H
2: Content-Type: application/json
3: -H
4: api-key: keygoeshere
5: -d
6: {prompt: tell
7: me
8: a
9: funny
10: story }
PS C:\Users\PervonZweigbergk\repos\argvtest\bin\Debug\netcoreapp3.0>
As we can see, for some reason, what you're intending to have as a single argument (your JSON payload as the -d argument) at some point ends up being split into multiple arguments and the "'s removed.
A workaround to this seems to be to double the quotes:
PS C:\Users\PervonZweigbergk\repos\argvtest\bin\Debug\netcoreapp3.0> .\argvtest.exe "https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01" "-H" "Content-Type: application/json" "-H" "api-key: keygoeshere" "-d" '{""prompt"": ""tell me a funny story"" }'
Hello World!
0: https://aoai-try-mc.openai.azure.com/openai/deployments/try-davinci/completions?api-version=2022-12-01
1: -H
2: Content-Type: application/json
3: -H
4: api-key: keygoeshere
5: -d
6: {"prompt": "tell me a funny story" }
PS C:\Users\PervonZweigbergk\repos\argvtest\bin\Debug\netcoreapp3.0>
I'm sure there's an interesting reason as to why the command line handling seems "broken" like this, but I at least hope this helps answer your specific question.
Edit: This previous Stack Overflow answer may provide some insight: PowerShell stripping double quotes from command line arguments