https://github.com/neuralweights/llama-server-authkeys
Authorization tokens to access llama.cpp server (LM Studio, Ollama, Msty, GPT4All, Jan)
https://github.com/neuralweights/llama-server-authkeys
authorization authorization-server gpt4all gpt4all-api jan llama lmstudio msty ollama ollama-api ollama-app token-based-authentication
Last synced: about 2 months ago
JSON representation
Authorization tokens to access llama.cpp server (LM Studio, Ollama, Msty, GPT4All, Jan)
- Host: GitHub
- URL: https://github.com/neuralweights/llama-server-authkeys
- Owner: NeuralWeights
- License: apache-2.0
- Created: 2025-03-04T11:15:31.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-04T11:24:09.000Z (over 1 year ago)
- Last Synced: 2025-03-04T12:27:56.974Z (over 1 year ago)
- Topics: authorization, authorization-server, gpt4all, gpt4all-api, jan, llama, lmstudio, msty, ollama, ollama-api, ollama-app, token-based-authentication
- Language: Python
- Homepage:
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Llama Server AuthKeys
## Overview
Llama AuthKeys is a lightweight authentication service built with Flask. It provides token management capabilities, including creating, listing, and revoking tokens. The service also proxies requests to an external API while ensuring proper authorization based on token scopes.
## Features
- **Token Management**: Create, list, and revoke tokens.
- **Scope-based Authorization**: Tokens have associated scopes that determine access levels.
- **Request Logging**: Logs all incoming requests for auditing purposes.
- **Proxy Requests**: Forwards requests to an external API with proper authentication.
## Requirements
- Python 3+
- Flask
- [SQLite3](https://www.sqlite.org/download.html)
## Installation
1. Clone the repository:
```bash
git clone https://github.com/NeuralWeights/llama-server-authkeys.git
cd llama-server-authkeys
```
2. Install dependencies:
```bash
pip install flask
```
## Configuration
Align the `config.ini` file to your needs if needed.
```ini
[APP]
host=127.0.0.1
port=5001
[DB]
db_name=authwall.db
root_token=root
[INFER]
completions=http://localhost:1234/v1/chat/completions
v1=http://localhost:1234/v1
```
## Running the Application
1. Start the application:
```bash
python app.py
```
2. Access the service at `http://localhost:5001`.
## Usage (CURL)
### List Tokens
`curl -X GET http://localhost:5001/list_tokens -H "Content-Type: application/json" -d "{\"token\": \"root\"}"`
### Create Token
`curl -X POST http://localhost:5001/create_token -H "Content-Type: application/json" -d "{\"token\": \"root\", \"scope\": \"infer:write\", \"expired_at\": 1756800000}"`
### Revoke Token
`curl -X POST http://localhost:5001/revoke_token -H "Content-Type: application/json" -d "{\"token\": \"root\", \"token_to_revoke\": \"the_token_to_revoke\"}"`
### Completions API (Default payload)
`curl -X POST http://localhost:5001/v1/chat/completions -H "Content-Type: application/json" -d "{\"token\": \"your_new_token\", \"model\": \"Llama-3.3-70B-instruct\", \"messages\": [{\"role\": \"system\", \"content\": \"You are a helpful assistant\"}, {\"role\": \"user\", \"content\": \"Hello\"}], \"temperature\": 0.7}"`
### Embeddings API (Default payload)
`curl http://127.0.0.1:5001/v1/embeddings -H "Content-Type: application/json" -d "{ \"model\": \"text-embedding-nomic-embed-text-v1.5\", \"input\": \"Some text to embed\", \"token\": \"root\" }"`