I have Azure Open AI resource. I want to create a simple title based on a user input. For example, when the user inputs
azure openai uses apikey, so this header is incorrect Authorization: Bearer ${openaiApiKey}
, should be just api-key: xxxx
try out below curl example for a test, then you can adjust your code
curl -i --location 'https://xxxxx.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-08-01-preview' \
--header 'Content-Type: application/json' \
--header 'api-key: xxxxxxx' \
--data '{
"messages": [
{
"role": "system",
"content": [
{
"type": "text",
"text": "You are a helpful assistant who talks like a pirate."
}
]
},
{
"role": "user",
"content": [
{
"type": "text",
"text": "Good day, who am I talking to?"
}
]
},
{
"role": "assistant",
"content": [
{
"type": "text",
"text": "Ahoy there, matey! What be bringin ye to these waters today? "
}
]
}
],
"temperature": 0.7,
"top_p": 0.95,
"max_tokens": 800
}'