Where can I find 'DLAI_TOGETHER_API_BASE'

Hi Everyone
I see that a specific environment variable is required in the utils.py helper file

url = f"{os.getenv(‘DLAI_TOGETHER_API_BASE’, ‘https://api.together.xyz’)}/inference"

Where can I find the variable DLAI_TOGETHER_API_BASE?

Thanks in advance
Fabio

I’m going to guess that’s in the dotenv resource, which is not publicly available.

1 Like

Hi @TMosh
I have just realized that the os.getenv function takes two arguments: the name of the environment variable and a default value. If the environment variable DLAI_TOGETHER_API_BASE is set, os.getenv will return its value. If it’s not set, os.getenv will return the default value, which is 'https://api.together.xyz' in this case.

In the ‘utils.py’ file there is another environment variable called ‘TOGETHER_API_KEY’.

headers = {
“Authorization”: f"Bearer {os.getenv(‘TOGETHER_API_KEY’)}",
“Content-Type”: “application/json”
}

This variable should be created from ’ TOGETHER’ .
Now I can run locally the Jupyter Notebook.
Hope this can help anyone else.

1 Like

Thanks for your report.

I think is some coder that need to complicate the life of the rest of people ;(, would be easier to simply write a constant at the begining of utils.py:

url = ‘https://api.together.xyz/inference

as same kind of constant, and if in a future this url changes, only have to change it once in the definition.

And as pointed out is different the TOGETHER_API_KEY, obtained from the web together.ai, when you register…and the base url of the API Together.

How to set ‘DLAI_TOGETHER_API_BASE’ in .env file. I am getting an error, if I run the code. I already set TOGETHER_API_KEY.

Do we need to set DLAI_TOGETHER_API_BASE to base url? What will is the base Url then?

I changed my url to url = “https://api.together.xyz/v1/chat/completions” instead of using ‘DLAI_TOGETHER_API_BASE’. I think it should work but still I am getting “Invalid API key provided” error.

Hi Wasim
HAve you created your API Key under the together.ai website?
https://api.together.ai/

Yes, I created it. The issue is resolved now. I was following a tutorial and it was actually not retrieving the API key from .env. I checked another tutorial and corrected it.

:ok_hand: well done