APIMyLlama V2
APIMyLlama is a server application that provides an interface to interact with the Ollama API, a powerful AI tool to run LLMs. It allows users to run this alongside Ollama to easily manage API keys.
Last updated
APIMyLlama is a server application that provides an interface to interact with the Ollama API, a powerful AI tool to run LLMs. It allows users to run this alongside Ollama to easily manage API keys.
Last updated
If you already have Ollama setup with the 'ollama serve' command and your desired model. You can skip this. If not i'll show you how to set it up. First install for your desired operating system. Once installed open a terminal instance and run the command below.
If done correctly you should now have the Meta's Llama3 LLM installed. You can use any model with the API but for this example we will use this model. Now you are gonna run this command after the install is complete.
Now you have an Ollama server setup. Time for the next step.
Install on your server. Then clone the git repository.
After cloning go into the APIMyLlama directory and install all the needed dependencies by running the 'npm install' command. Then run the APIMyLlama.js file. On startup it will ask what port you want to use.
Windows: For Windows you can set a System Environment Variable. The variable and the value are listed below.
Linux: For Linux you can edit the service file for Ollama. Open /etc/systemd/system/ollama.service and add the following line inside the [Service] section
On Linux you can also just run the command below to listen on all interfaces if that is easier for you. However you will need to run Ollama with this command everytime you start it up if you want to use APIMyLlama.
These are the commands you can use in the APIMyLlama application
This command will generate a key using Cryptography and save it to the local database.
This command will list all API Keys in the database.
This command will remove any key from the database.
You can add custom keys if wanted. (DO with CAUTION as it may be unsafe)
You can change the servers port in realtime without having to restart the application.
You can add webhooks for alerts when a new request is made. EX. Discord Webhook
This command will list all the webhooks you have attached to your system.
This command can be used to remove a webhook in your system. You can get the ID of the webhook using the 'listwebhooks' command.
This command allows you to change the ratelimit on a key. By default it is 10. The rate limit is by minute. So for example the default allows 10 requests to the API per minute.
Allows you to deactivate an API key. This will make the key useless untill it is activated.
Activates a API key that has been deactivated in the past.
This command lets you add a description to a key to help you decipher what key does what.
This command lists the description of that key if it has a description.
Quickly generate multiple new API keys.
Regenerate any specified API key without affecting other details.
Activate all your API keys with a single command.
Deactivate all your API keys with a single command.
Retrieve detailed information about a specific API key.
Easily list all active API keys.
Easily list all inactive API keys.
Install APIMyLlama packages with NPM (Node.JS), PIP (Python), Jitpack Repo+Gradle or Maven (Java), or from the Crates Repository (Rust)
NPM Install (Node.JS)
PIP Install (Python)
Jitpack+Gradle Repository <build.gradle> (Java IF YOUR USING GRADLE)
Jitpack+Gradle Dependency <build.gradle> (Java IF YOUR USING GRADLE)
Jitpack+Maven Repository <pom.xml> (Java IF YOUR USING MAVEN)
Jitpack+Maven Dependency <pom.xml> (Java IF YOUR USING MAVEN)
Crate Repository <Cargo.toml> (Rust)
Node.JS example:
Python example:
Java Example:
Rust Example:
The packages have built in health checking command (AS OF V2) If you already have the Node.js or Python packages installed then you can just copy and paste the code below to test.
Node.JS example:
Python example:
Java example:
Rust Example:
1. Why am I getting the module not found error?
You most likely forgot to run the 'npm install' command after cloning the repository.
2. Why can't I use the API outside my network?
You probably didn't port foward. And if you did your router may have not intialized the changes yet or applied them.
3. Ollama Serve command error "Error: listen tcp 127.0.0.1:11434: bind: Only one usage of each socket address (protocol/network address/port) is normally permitted."
If you get this error just close the Ollama app through the system tray on Windows. And if your on Linux just use systemctl to stop the Ollama process. Once done you can try running the ollama serve command again.
4. error: 'Error making request to Ollama API'
Enter the desired port you would like to use with the APIMyLlama server. This port can NOT be the same as Ollama or any other application running on your server. After you choose your port you will NEED to port foward this port if you are gonna use the API Key system OUTSIDE of your network. Then it will ask you to enter the URL for your Ollama server. This is the URL Ollama is running on. If you are running APIMyLlama on the same system as you are running Ollama on. You will put '' If you changed the port you can put your port instead of '11434'. If you are running Ollama on a different server/device (This also applies to virtualized machines). You will need to get the IP of the device and then put it like this 'http://<YOUR_SERVER_IP>:11434'. If you changed the port then you can put your port here instead of '11434'. This last thing applies to running Ollama and APIMyLlama on 2 different systems. If you are doing this. You will NEED to run Ollama to listen on ALL interfaces. You can do this on Windows or Linux like shown below.
You can change the Ollama Server url if you have a custom one set. By default it is "".
If there are any issues please make a Github Issue Report. To get quicker support join our discord server. - If there are any feature requests you may request them in the discord server. PLEASE NOTE this project is still in EARLY BETA.
We now have a open if you would like to help and donate to the project. We love to keep it free and open source when possible and donating helps a lot.
If you have a custom port set for your Ollama server this is a simple fix. Just run the 'changeollamaurl <YOUR_OLLAMA_SERVER_URL>' and change it to the url your Ollama server is running on. By default it is "" but if you changed it you will need to do this. You can also fix this problem through changing the port in the ollamaURL.conf file.