Assessing models Method 2 Using OpenAI API

This page is to learn the 2nd way of accessing LLM on OpenWEB UI using OpenAI API. First way is here. Third way is here.

So how can we start playing with LLM using this setup? We will learn during this course three ways to access LLMs on OpenWeb UI. See Figure 1.

Method 1 is likely for LLMs that are smaller in size and your computer has adequate computing resources (e.g., GPU? Ram?) to handle the models. Way 2 will be for large models like Open AI models. Method 2 may costs $ to access because of API call rates. We talk about way 2 here.

Figure 1


For Method 1, we downloaded the models onto our laptops. But this can be problematic if our laptops are not as powerful and we can only then access smaller LLMs.


Method 2: Access LLMs using an API like OpenAI’s API

What if you want to access OpenAI’s models like those in ChatGPT? This can also work for other LLM models out there that have APIs to call on such as Gemini etc. We will use OpenAI as an example here. If you prefer to watch a video, see Video 1

Step 1: Log In to OpenWeb UI

Open up Ollama and Docker
  • Open up Ollama.
  • Open Docker which you should have already set up previously here.
  • Check it is square symbol and you can click on the numbers to open up OpenWEB UI in a local host 3000

The first person who registers will be the Admin. So make sure YOU are the admin person i.e. this is your laptop.

If this is the first time you are logging in, you are the administrator. Create your own password.

Step 2: Get to Admin -> Settings -> Connections to input API key

Click on your name on bottom left


Click on “Admin Panel”


Click on “Settings” on the top bar


Click on “Connections”


API URL will be “https://api.openai.com/v1”

Under “OpenAI API”, copy and paste your API key


In this course, I will provide you an API key: it will be send to your group page on CANVAS! Each group will have an API key with $10 credit which your group will share for your group assignment. This money is out of my own pocket for your learning purposes.

Caution

THIS IS VERY IMPORTANT: OpenAI’s API keys allow you to call on the OpenAI’s API. API key are like keys to your houses. You do not share them with anyone else outside your group. You certainly do NOT put them on any public-accessible pages or sociomedia posts.


You can actually create your own API key on your own account. Watch Video 1 at the 1-min point to see how to create one. You can use your money to fund your API key. Do note these few points if you are creating your own API key

  • Always look for the page on pricing: for e.g. for OpenAI it is here or here
  • Use the model that you can afford. At this point, use only models for “text tokens”.
    • Do not use any others model especially image generation, audio etc. These models can get very expensive.
    • For text tokens, use models like gpt-4o-mini or gpt-4o. These are still quite cheap, especially gpt-4o-mini.
    • If you are using your API key, set the budget alerts and disable auto-recharge.
    • Note that the prices are shown for 1 million token. If you choose cheap models like gpt-4o-mini, your usage each time should only cost you a few cents.. YES A FEW CENTS ONLY IF YOU CHOOSE THE CHEAP MODElS. See next point.
  • Always check your usage costs in your dashboard to see how much calls are costing you: usage


If you do not see https://api.openai.com/v1 like in the picture above, then click “+” to add a connection, paste https://api.openai.com/v1 in the URL box, and then paste the API key in the key box. Then finally click on the round-abot arrows. See image below

Click the round-about arrows to verify the connections

Step 3: Try the model by starting a new chat

  • Return back to main interface
  • Click “New chat”. Select a ChatGPT model like gpt-4o-mini.


If you prefer to watch a video to understand how to download and use a model, check this Youtube below:

Video 1