NEED HELP making Open AI message's to be dynamic

I’m having an issue whenever I try to make the messages section for open ai api call to be dynamic it gives me a error

I will provide the original API call from Open AI and then my tweaked version to make it dynamic.

Original version:


Dynamic version:


What did you set in value for message?

The messages parameter should look like this:

"messages": [
    {"role": "system", "content": <systemcontent>},
    {"role": "user", "content": <input>}]
}

No… My question is, what did you put in the value? You tried to initialize it with the dynamic message value empty?.. you need to put a value there…
Also, you cannot have dynamic inside dynamic, it won’t work. However, because the full message is dynamic you can encode this part directly in message field when you run the action

This was my answer to the original post :wink:

To initialize the API, use {"role": "system", "content": "you are a helpful assistant}, {"role": "user", "content": "hello"} like you have in your first screenshot, but in the value instead of message instead.

You could also modify your dynamic part for the last one you post:

"messages": [
    {"role": "system", "content": <systemcontent>},
    {"role": "user", "content": <input>}]
}

At this moment, put “You are usefull assitant” (including double quotes) in value for systemcontent and “hello” for input. In WF, you will use the dynamic value:encoded as json-safe (this will add double quotes at beginning and end too)

this worked. Thank youuu

I can’t get it. Do you answer the question with my answer?

"messages": [
    {"role": "system", "content": <systemcontent>},
    {"role": "user", "content": <input>}]
}

But may be I’m lost in translation.

What do you have actually in API Connector