Skip to content

Conversation

ZahraDehghani99
Copy link
Contributor

@ZahraDehghani99 ZahraDehghani99 commented Sep 13, 2025

Title

docs(tei): fix OpenAI client usage example for embeddings


PR Description

This PR updates the documentation for using the OpenAI Python client with TEI’s OpenAI-compatible API.
The previous example incorrectly set the base_url to /v1/embeddings, which caused errors.
It also did not mention that the OpenAI client requires an api_key argument (even if unused by TEI).

Changes made:

  • Corrected the base_url to http://localhost:8080/v1
  • Added api_key="fake" to satisfy the OpenAI client requirements
  • Updated the example to print response.data[0].embedding for clarity

Motivation:
Improve usability of the TEI docs by providing a working out-of-the-box example for developers who want to use the OpenAI client with TEI.

Fixes:
N/A (documentation improvement)


Before submitting

  • This PR fixes a typo or improves the docs (you can dismiss the other checks if that's the case).
  • Did you read the contributor guideline?
  • Did you make sure to update the documentation with your changes?
  • Tests not applicable (docs-only change).

Who can review?

Tagging maintainer for review:
@Narsil

Copy link
Member

@alvarobartt alvarobartt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @ZahraDehghani99 thanks a lot for the PR! I've included some extra comments, but other than that LGTM 🤗

@ZahraDehghani99
Copy link
Contributor Author

Hey @ZahraDehghani99 thanks a lot for the PR! I've included some extra comments, but other than that LGTM 🤗

Thank you so much @alvarobartt for all your helpful suggestions! I’ve applied all of them and cleaned up the examples, including fixing the backticks and removing the accidentally added duplicate from GitHub UI. I also added the port number in the curl request so it works correctly. Please let me know if there’s anything else I should adjust 😊

@HuggingFaceDocBuilderDev

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@alvarobartt
Copy link
Member

Thanks @ZahraDehghani99, merging to main now 🔥

image

@alvarobartt alvarobartt merged commit ff3969a into huggingface:main Sep 16, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants