================
A system built to prevent people from using the Ollama API willy-nilly if you have it exposed to the interwebs. Requires API keys.
Ollama Proxy is a Node.js application that acts as a reverse proxy for the Ollama API. It provides an additional layer of security and authentication for API requests.
- API Key Authentication: Ollama Proxy requires API keys for authentication, ensuring that only authorized requests are forwarded to the Ollama API.
- Streaming Support: Ollama Proxy supports streaming responses from the Ollama API, allowing for efficient handling of large data transfers.
- Error Handling: Ollama Proxy catches and handles errors from the Ollama API, providing a more robust and reliable experience.
- Key Generation: Using CLI you can automatically generate new api keys. OLLAMA-UUID format.
- Node.js (version 14 or later)
- express
- fs
- path
- crypto
- Clone the repository:
git clone https://github.com/your-username/ollama-proxy.git
- Install dependencies:
npm install
- Create file authTokens.json
- Start the server:
node proxy.js
- Enter
generateAPIKey
to generate your first key
POST /v1/chat/completions
: Forward requests to the Ollama API for chat completions.
Authorization
: This is a required header, it should containBearer <API-KEY>
model
: The model to use for chat completions.messages
: The messages to complete.stream
: Optional flag to enable streaming responses.
200 OK
: Successful response from the Ollama API.401 Unauthorized
: Invalid API key or authentication error.500 Internal Server Error
: Error from the Ollama API.
- Allow streaming (will work with a streaming flag set, but will not actually stream yet)
Ollama Proxy uses API keys for authentication and ensures that only authorized requests are forwarded to the Ollama API.
Ollama Proxy is licensed under the MIT License.