All examples in this page assume environment variables are available. For convenience, create a .env file in the repository root (you can copy from .env.example) with:
Set TUDELFT_TULIP_BASE_URL to host root only (for example https://api.tulip.tudelft.nl). The Python helper normalizes it to a capability-specific /v1 endpoint automatically.
What these examples assume
The Python snippets on this page assume a local helper file common.py that loads environment variables and exports shared constants.
If you cloned this repository, examples/common.py is already present and the scripts run as shown below.
If you have not cloned the repo and are working with Python, expand the helper snippet below and place common.py next to the example you want to run.
Python run commands use pixi run python ...; dependencies come from pixi.toml.
Bash examples pretty-print JSON using jq, so you may need to install it.
TUDELFT_TULIP_CAPABILITY chooses the path segment (embed).
TUDELFT_TULIP_MODEL_ALIAS chooses the deployed model alias.
If you have not cloned the repo and are working with Python, create common.py next to the example
importosfromdotenvimportload_dotenvload_dotenv()# loads .env if presentTUDELFT_TULIP_BASE_URL=os.getenv("TUDELFT_TULIP_BASE_URL","https://api.tulip.tudelft.nl")TUDELFT_TULIP_CAPABILITY=os.getenv("TUDELFT_TULIP_CAPABILITY","chat")TUDELFT_TULIP_API_KEY=os.getenv("TUDELFT_TULIP_API_KEY","DUMMY_KEY")TUDELFT_TULIP_MODEL_ALIAS=os.getenv("TUDELFT_TULIP_MODEL_ALIAS","chat")# Normalize TUDELFT_TULIP_BASE_URL to capability/v1. Docs recommend host root only,# but we also accept URLs that already include capability or capability/v1._base_url=TUDELFT_TULIP_BASE_URL.rstrip("/")if_base_url.endswith("/v1"):TUDELFT_TULIP_BASE_URL=_base_urlelif_base_url.endswith(f"/{TUDELFT_TULIP_CAPABILITY}"):TUDELFT_TULIP_BASE_URL=f"{_base_url}/v1"else:TUDELFT_TULIP_BASE_URL=f"{_base_url}/{TUDELFT_TULIP_CAPABILITY}/v1"
importsysfromcommonimport(TUDELFT_TULIP_API_KEY,TUDELFT_TULIP_BASE_URL,TUDELFT_TULIP_MODEL_ALIAS,)fromopenaiimportOpenAIprint(f"Using base URL: {TUDELFT_TULIP_BASE_URL}",file=sys.stderr)print(f"Using model alias: {TUDELFT_TULIP_MODEL_ALIAS}",file=sys.stderr)client=OpenAI(base_url=TUDELFT_TULIP_BASE_URL,api_key=TUDELFT_TULIP_API_KEY)print("\n********** Check embeddings works (dimension check) *****************",file=sys.stderr,)response=client.embeddings.create(model=TUDELFT_TULIP_MODEL_ALIAS,input=["Hello from tulip","this rocks!"],encoding_format="float",)print(f"Number of embeddings: {len(response.data)}")print(f"Embedding dimension: {len(response.data[0].embedding)}")print("\n*** Check embeddings works (different strings -> different vectors) ***",file=sys.stderr,)response=client.embeddings.create(model=TUDELFT_TULIP_MODEL_ALIAS,input=["cat","quantum entanglement"],encoding_format="float",)foriteminresponse.data:print(f"Index {item.index}: {item.embedding[0:5]}")
Run:
pixirunpythonexamples/python_embedding.py
Success looks like
You receive embedding vectors for both input strings.
Reported embedding dimensions are consistent (e.g., 4096).
The two sample outputs are different vectors (first elements are not identical).