# OpenAI API for embeddings?

**URL:** https://community.thunkable.com/t/openai-api-for-embeddings/2270702
**Category:** Web API's
**Created:** [February 10, 2023, 5:05pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702 "2023-02-10T17:05:37Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![nathanburley21656](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nathanburley21656/32/150307_2.png) [@nathanburley21656](https://community.thunkable.com/u/nathanburley21656)
#### Post date: [February 10, 2023, 5:05pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702/1 "2023-02-10T17:05:37Z")

</div>

Does anyone know if it’s possible to use the OpenAI blocks to create an embedding from a string? Or would one use the standard API calls to do this?

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [February 10, 2023, 5:26pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702/2 "2023-02-10T17:26:32Z")

</div>

Can you say a bit more about what you mean by “an embedding from a string”?

---

<div class="post-metadata">

### Author: ![nathanburley21656](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nathanburley21656/32/150307_2.png) [@nathanburley21656](https://community.thunkable.com/u/nathanburley21656)
#### Post date: [February 10, 2023, 5:32pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702/3 "2023-02-10T17:32:50Z")

</div>

OpenAI has a function to create ‘embeddings’ from strings / chunks of text. Embeddings are 1536 dimensional vector representations of the text. They can be obtained by sending the string / entire dataset to an OpenAI endpoint, where it runs a model on the data and returns the vector representation of each string: [Embeddings - OpenAI API](https://platform.openai.com/docs/guides/embeddings/what-are-embeddings) at least that’s my noob understanding.

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [February 10, 2023, 5:37pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702/4 "2023-02-10T17:37:30Z")

</div>

Fascinating. I had no idea.

The built-in OpenAI block is fairly limited so you would need to configure the API manually for that.

---

<div class="post-metadata">

### Author: ![nathanburley21656](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nathanburley21656/32/150307_2.png) [@nathanburley21656](https://community.thunkable.com/u/nathanburley21656)
#### Post date: [February 11, 2023, 5:10pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702/5 "2023-02-11T17:10:33Z")

</div>

OK - that was surprisingly easy! I managed to get a vector embedding back from the OpenAI API. That means that _IF_ I can vectorise large datasets then I could, in theory:

- Ask a question (record this)
- Convert the sound file to text using WhisperAPI
- Convert the text string to an embedding / vector
- Compare that vector to other vectors in the database
- Return similar vectors \> the basis of sematic search

For reference: add the Auth (+API key) and Content-Type to the API configuration menu, along with the url. Then set the model and input as shown to get this to work:

 ![Thunk1](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/0/9/090aba51072fa318f983250e33ea9cb02d5f037a.jpeg)

---

<div class="post-metadata">

### Author: ![nathanburley21656](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/nathanburley21656/32/150307_2.png) [@nathanburley21656](https://community.thunkable.com/u/nathanburley21656)
#### Post date: [February 11, 2023, 7:01pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702/6 "2023-02-11T19:01:26Z")

</div>

Quick follow-up on this as I did try and integrate that into my previous code: be aware that the above only work because the “Retrieve a test embedding for this text” is in double quotes. Any string you’re using here needs to be in double quotes. My return variable from [WhisperAPI.com](http://WhisperAPI.com) was not, so I needed to add them in using a Join.

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 1:37pm UTC](https://community.thunkable.com/t/openai-api-for-embeddings/2270702/7 "2024-11-08T13:37:05Z")

</div>


