Skip to content

Commit ff3969a

Browse files
Fix OpenAI client usage example for embeddings (#720)
Co-authored-by: Alvaro Bartolome <36760800+alvarobartt@users.noreply.github.com>
1 parent ebb63df commit ff3969a

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

docs/source/en/quick_tour.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,21 +77,31 @@ print(len(embedding[0]))
7777
```
7878

7979
#### OpenAI
80-
81-
You can install it via pip as `pip install --upgrade openai`, and then run:
80+
To send requests to the [OpenAI Embeddings API](https://platform.openai.com/docs/api-reference/embeddings/create) exposed on Text Embeddings Inference (TEI) with the OpenAI Python SDK, you can install it as `pip install --upgrade openai`, and then run the following snippet:
8281

8382
```python
8483
import os
8584
from openai import OpenAI
8685

87-
client = OpenAI(base_url="http://localhost:8080/v1/embeddings")
86+
client = OpenAI(base_url="http://localhost:8080/v1", api_key= "-")
8887

8988
response = client.embeddings.create(
90-
model="tei",
91-
input="What is deep learning?"
89+
model="text-embeddings-inference",
90+
input="What is Deep Learning?",
9291
)
9392

94-
print(response)
93+
print(response.data[0].embedding)
94+
```
95+
96+
Alternatively, you can also send the request with cURL as follows:
97+
```bash
98+
curl http://localhost:8080/v1/embeddings \
99+
-H "Content-Type: application/json" \
100+
-d '{
101+
"input": "What is Deep Learning?",
102+
"model": "text-embeddings-inference",
103+
"encoding_format": "float"
104+
}'
95105
```
96106

97107
## Re-rankers and sequence classification

0 commit comments

Comments
 (0)