I can't send a POST request using PowerAutomate

Hello everyone,
I’m working on a PowerAutomate flow, and I have an Action where I send a POST request to https://api.openai.com/v1/chat/completions in order to execute a script that looks like this:

{
"model":"gpt-4.1",
"temperature":0,
"messages":[
            {"role": "system", "content": prompt_sys},
            {"role": "user", "content": user_message}
        ]

Here I use prompt_sys and user_message just to hide the content but a String is passed there.
When I execute the flow, an error occurs and I can’t know the exact reason, but is the link im using to send the POST request is correct ?

it seems fine, except that you didn’t close the initial curly brace.

Also, you didn’t specify what error are you getting.

You can test out the curl examples in the docs, as they are the closes thing to the payload sent in a request.

The API also likes a nice greeting where you introduce yourself:

HEADERS = {
‘Authorization’: f’Bearer {API_KEY}',
‘Content-Type’: ‘application/json’,
}

You know, just as a formality establishing your ability to pay for services. Or just pick out what is actually needed in forming headers from the whole depending on what isn’t done for you by the the mechanism.

POST /v1/chat/completions HTTP/1.1
Host: api.openai.com
Authorization: Bearer sk-1234567890abcdef
Content-Type: application/json
Content-Length: 123
User-Agent: automated-requests/1.2.1
Accept-Encoding: gzip, deflate
Connection: keep-alive

Thank you for your answers, actualy i found out that somehow my API key was not correctly parsed in my power automate (a \n appeared for no reason at the end of the key) so i stored the key in a variable and loaded it when sending the POST request to the endpoint and it worked.
But I have another question in the same contexte, now i know that the endpoint for chat completions is https://api.openai.com/v1/chat/completions, what is the endpoint for the vector store in order to do a vector search ? (I heard that i cannot do such thing unless i use an Assistant, so i have to replace the vector store with Pinecone or another vector DB, i want to make sure if this is correct or not?)

Well, going into specifics about third party software is a problem since this is not a power automate forum.

But you can create a vector store using a PDF file, in the cookbook there is an example in python for it.

How to adapt it to your backend solution is up to you though.

I think there is a misunderstanding in my last point, i asked about the endpoint used to send a POST request to the vector store, which is indepedendant from any software, and openAI has listed some of the endpoints here https://platform.openai.com/docs/api-reference/responses/create (example: POST https://api.openai.com/v1/responses)
Now im asking about the endpoint for the vector store since i can’t find it. Thank you.

I see. Here it is:

https://api.openai.com/v1/vector_stores

And the docs:
https://platform.openai.com/docs/api-reference/vector-stores/create

2 Likes

Thank you for your help !

2 Likes