# Issue with OpenAI API in WeWeb: Variable Not Updating in Request Body

**URL:** https://community.weweb.io/t/issue-with-openai-api-in-weweb-variable-not-updating-in-request-body/16859
**Category:** How do I?
**Created:** [February 26, 2025, 8:36am UTC](https://community.weweb.io/t/issue-with-openai-api-in-weweb-variable-not-updating-in-request-body/16859 "2025-02-26T08:36:28Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Kevin\_otto](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@Kevin\_otto](https://community.weweb.io/u/Kevin_otto)
#### Post date: [February 26, 2025, 8:36am UTC](https://community.weweb.io/t/issue-with-openai-api-in-weweb-variable-not-updating-in-request-body/16859/1 "2025-02-26T08:36:28Z")

</div>

Hello everyone,

I’m facing an issue integrating OpenAI’s API to generate embeddings with WeWeb.

### Context:

- I’m using OpenAI’s `"text-embedding-ada-002"` model.
- I want to dynamically send the value of a variable called “Last Question” as “input” in the API request.
- I have set up my API in WeWeb with a dynamic JSON body.

### Current Request:

In WeWeb, I have configured the request body as follows:

{  
“model”: “text-embedding-ada-002”,  
“input”: “@{variables[‘Last Question’]}”  
}

```auto

🔹Problem: The OpenAI API always returns the same embedding, regardless of the value of `Last Question`. It seems that the variable is not being correctly passed into the request body.

The variable Last Question variable is updating correctly (I displayed it on the page to verify).

How should I properly bind the `Last Question` variable to the JSON body in WeWeb so that its value is correctly passed to OpenAI? Is there an issue with the syntax, or how WeWeb handles variable injection in API requests?

Thanks in advance for your help!
```

---

<div class="post-metadata">

### Author: ![Kevin\_otto](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@Kevin\_otto](https://community.weweb.io/u/Kevin_otto)
#### Post date: [March 2, 2025, 7:52pm UTC](https://community.weweb.io/t/issue-with-openai-api-in-weweb-variable-not-updating-in-request-body/16859/2 "2025-03-02T19:52:09Z")

</div>

Someone to help me? Thanks 🙂

---

<div class="post-metadata">

### Author: ![raydeck](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raydeck/32/384_2.png) [@raydeck](https://community.weweb.io/u/raydeck)
#### Post date: [March 2, 2025, 9:56pm UTC](https://community.weweb.io/t/issue-with-openai-api-in-weweb-variable-not-updating-in-request-body/16859/3 "2025-03-02T21:56:43Z")

</div>

I take it you are running a REST API request from weweb? I don’t know where the “configure as follows” is getting set up. That’s not parallel to what the nocode setup looks like. If you share screenshots or a video, might be easier for you to get help from the very nice people on this forum.

---

<div class="post-metadata">

### Author: ![raelyn](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/raelyn/32/2803_2.png) [@raelyn](https://community.weweb.io/u/raelyn)
#### Post date: [March 3, 2025, 3:26am UTC](https://community.weweb.io/t/issue-with-openai-api-in-weweb-variable-not-updating-in-request-body/16859/4 "2025-03-03T03:26:22Z")

</div>

Sounds like something wrong with the way you are calling the open AI model rather than a problem with the input being passed to it…

---

<div class="post-metadata">

### Author: ![Kevin\_otto](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@Kevin\_otto](https://community.weweb.io/u/Kevin_otto)
#### Post date: [March 3, 2025, 9:44am UTC](https://community.weweb.io/t/issue-with-openai-api-in-weweb-variable-not-updating-in-request-body/16859/5 "2025-03-03T09:44:50Z")

</div>

Thank you for your feedback. To further explain my issue, here are some additional details.

I am working on creating a legal chatbot that uses RAG technology.  
I use Supabase to host my legal documentation and WeWeb for the user interface.

On WeWeb, I have a very simple front end with a question form that triggers a workflow when the user submits a question by clicking the validation button.

The first step of my workflow is saving the user’s question in a variable called _Last Question_.

The second step is making an API call to OpenAI via a REST API request. I want to retrieve the embedding vector of the user’s question. Here’s how I have configured my REST API request:

**Type** : REST API Request  
**Method** : POST  
**URL** : [https://api.openai.com/v1/embeddings](https://api.openai.com/v1/embeddings)

**Header** :

- **Key** : Authorization
- **Value** : Bearer my API key

**Content Type** : application/json

I clicked on _raw body_ and in the body, I have the following formula:

{  
“model”: “text-embedding-ada-002”,  
“input”: “@{variables[‘Last Question’]}”  
}

I think there is a problem with my formula because the API request always returns the same vector, regardless of the question asked.

In the video, I can see that my question is correctly saved in Supabase, and I do get an embedding vector, but it does not change when a user asks a new question.

[Watch the video](https://www.loom.com/share/016f5a479c834c1b9ed6b9aaeb895730?sid=f92625ab-c918-45b1-b869-77fc1d67671f)
