|
| 1 | +> Handle: `boost`<br/> |
| 2 | +> URL: [http://localhost:34131/](http://localhost:34131/) |
| 3 | +
|
| 4 | + |
| 5 | + |
| 6 | +`boost` is an optimising LLM proxy with OpenAI-compatible API. |
| 7 | + |
| 8 | +### Documentation |
| 9 | + |
| 10 | +- [Features](#features) |
| 11 | +- [Starting](#starting) |
| 12 | +- [Configuration](#configuration) |
| 13 | +- [API](#api) |
| 14 | +- [Environment Variables Reference](../docs/5.2.2-Harbor-Boost-Configuration) |
| 15 | +- [Built-in Modules Reference](../docs/5.2.3-Harbor-Boost-Modules) |
| 16 | +- [Custom Modules Guide](../docs/5.2.1.-Harbor-Boost-Custom-Modules) |
| 17 | +- [Standalone Usage Guide](#standalone-usage) |
| 18 | +- [Boost Starter repo](https://github.com/av/boost-starter) |
| 19 | + |
| 20 | +*** |
| 21 | + |
| 22 | +### Features |
| 23 | + |
| 24 | +#### OpenAI-compatible API |
| 25 | + |
| 26 | +Acts as a drop-in proxy for OpenAI APIs, compatible with most LLM providers and clients. Boost can be used as a "plain" proxy to combine multiple LLM backends behind a single endpoint with a single API key. |
| 27 | + |
| 28 | + |
| 29 | + |
| 30 | +```bash |
| 31 | +POST http://localhost:34131/v1/chat/completions |
| 32 | + |
| 33 | +{ |
| 34 | + "model": "llama3.1", |
| 35 | + "messages": [{ "role": "user", "content": "Tell me about LLMs" }] |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +#### Modules |
| 40 | + |
| 41 | +Run custom code inside or instead of a chat completion, to fetch external data, improve reasoning, perform trace inference, and more. |
| 42 | + |
| 43 | +```bash |
| 44 | +POST http://localhost:34131/v1/chat/completions |
| 45 | + |
| 46 | +{ |
| 47 | + "model": "klmbr-llama3.1", |
| 48 | + "messages": [{ "role": "user", "content": "Suggest me a random color" }] |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +Boost comes with [a lot of built-in modules](../docs/5.2.3-Harbor-Boost-Modules) with various functions. You can use them directly or as a base for your own creations. |
| 53 | + |
| 54 | +| [`markov`](../docs/5.2.3-Harbor-Boost-Modules#markov) | [`concept`](../docs/5.2.3-Harbor-Boost-Modules#concept) | |
| 55 | +|-|-| |
| 56 | +|  |  | |
| 57 | + |
| 58 | +| [`nbs`](../docs/5.2.3-Harbor-Boost-Modules#nbs) | |
| 59 | +|-| |
| 60 | +|  | |
| 61 | + |
| 62 | +| [`dnd`](../docs/5.2.3-Harbor-Boost-Modules#dnd) | [`promx`](../docs/5.2.3-Harbor-Boost-Modules#promx) | |
| 63 | +|-|-| |
| 64 | +|  |  | |
| 65 | + |
| 66 | +| [`dot`](../docs/5.2.3-Harbor-Boost-Modules#dot) | [`klmbr`](../docs/5.2.3-Harbor-Boost-Modules#klmbr) | [`r0`](../docs/5.2.3-Harbor-Boost-Modules#r0) | |
| 67 | +|-|-|-| |
| 68 | +|  |  |  | |
| 69 | + |
| 70 | +#### Scripting |
| 71 | + |
| 72 | +Creating custom modules is a first-class feature and one of the main use-cases for Harbor Boost. |
| 73 | + |
| 74 | +```python |
| 75 | +# Simplest echo module replies back |
| 76 | +# with the last message from the input |
| 77 | +def apply(llm, chat): |
| 78 | + await llm.emit_message(prompt=chat.tail.content) |
| 79 | +``` |
| 80 | + |
| 81 | +See the [Custom Modules](../docs/5.2.1.-Harbor-Boost-Custom-Modules) guide for more information on how to create your own modules and overview of available interfaces. |
| 82 | + |
| 83 | +### Starting |
| 84 | + |
| 85 | +#### Start with Harbor |
| 86 | + |
| 87 | +```bash |
| 88 | +# [Optional] pre-build the image |
| 89 | +harbor build boost |
| 90 | + |
| 91 | +# Start the service |
| 92 | +harbor up boost |
| 93 | +``` |
| 94 | + |
| 95 | +- Harbor connects `boost` with: |
| 96 | + - to all included LLM backends (`ollama`, `llamacpp`, `vllm`, etc.) |
| 97 | + - [`optillm`](../docs/2.3.33-Satellite\&colon-OptiLLM) as a backend |
| 98 | + - `webui` and `dify` frontends |
| 99 | + |
| 100 | +```bash |
| 101 | +# Get the URL for the boost service |
| 102 | +harbor url boost |
| 103 | + |
| 104 | +# Open default boost endpoint in the browser |
| 105 | +harbor open boost |
| 106 | +``` |
| 107 | + |
| 108 | +#### Start standalone |
| 109 | + |
| 110 | +```bash |
| 111 | +docker run \ |
| 112 | + -e "HARBOR_BOOST_OPENAI_URLS=http://172.17.0.1:11434/v1" \ |
| 113 | + -e "HARBOR_BOOST_OPENAI_KEYS=sk-ollama" \ |
| 114 | + -e "HARBOR_BOOST_MODULES=dot;klmbr;promx;autotemp;markov;" \ |
| 115 | + -e "HARBOR_BOOST_BASE_MODELS=true" \ |
| 116 | + -e "HARBOR_BOOST_API_KEY=sk-boost" \ |
| 117 | + -p 34131:8000 \ |
| 118 | + ghcr.io/av/harbor-boost:latest |
| 119 | +``` |
| 120 | + |
| 121 | +See [standalone usage](#standalone-usage) guide below. |
| 122 | + |
| 123 | +### Configuration |
| 124 | + |
| 125 | +[Configuration](1.-Harbor-User-Guide#configuring-services) can be performed via Harbor CLI, [`harbor config`](../docs/3.-Harbor-CLI-Reference#harbor-config), [`harbor env`](../docs/3.-Harbor-CLI-Reference#harbor-env) or the `.env` file. |
| 126 | + |
| 127 | +All of the above ways are interchangeable and result in setting environment variables for the service. |
| 128 | + |
| 129 | +#### Harbor CLI |
| 130 | + |
| 131 | +Specific options can be set using `harbor` CLI: |
| 132 | + |
| 133 | +```bash |
| 134 | +# Enable/Disable a module |
| 135 | +harbor boost modules add <module> |
| 136 | +harbor boost modules rm <module> |
| 137 | + |
| 138 | +# Set a parameter |
| 139 | +harbor boost <module> <parameter> |
| 140 | +harbor boost <module> <parameter> <value> |
| 141 | + |
| 142 | +# See boost/module help entries |
| 143 | +# for more info |
| 144 | +harbor boost --help |
| 145 | +harbor boost klmbr --help |
| 146 | +harbor boost rcn --help |
| 147 | +harbor boost g1 --help |
| 148 | + |
| 149 | +# Additional OpenAI-compatible APIs to boost |
| 150 | +harbor boost urls add http://localhost:11434/v1 |
| 151 | +harbor boost urls rm http://localhost:11434/v1 |
| 152 | +harbor boost urls rm 0 # by index |
| 153 | +harobr boost urls ls |
| 154 | + |
| 155 | +# Keys for the OpenAI-compatible APIs to boost. Semicolon-separated list. |
| 156 | +# ⚠️ These are index-matched with the URLs. Even if the API doesn't require a key, |
| 157 | +# you still need to provide a placeholder for it. |
| 158 | +harbor boost keys add sk-ollama |
| 159 | +harbor boost keys rm sk-ollama |
| 160 | +harbor boost keys rm 0 # by index |
| 161 | +harbor boost keys ls |
| 162 | +``` |
| 163 | + |
| 164 | +#### Harbor Config |
| 165 | + |
| 166 | +More options are available via [`harbor config`](../docs/3.-Harbor-CLI-Reference#harbor-config). |
| 167 | + |
| 168 | +```bash |
| 169 | +# See all available options |
| 170 | +harbor config ls boost |
| 171 | + |
| 172 | +# Some of the available options |
| 173 | +harbor config set boost.host.port 34131 |
| 174 | +harbor config set boost.api.key sk-boost |
| 175 | +harbor config set boost.api.keys sk-user1;sk-user2;sk-user3 |
| 176 | +``` |
| 177 | + |
| 178 | +Below are additional configuration options that do not have an alias in the Harbor CLI (so you need to use [`harbor config`](../docs/3.-Harbor-CLI-Reference#harbor-config) directly). For example `harbor config set boost.intermediate_output true`. |
| 179 | + |
| 180 | +#### Environment Variables |
| 181 | + |
| 182 | +Most comprehensive way to configure `boost` is to use environment variables. You can set them in the `.env` file or via [`harbor env`](../docs/3.-Harbor-CLI-Reference#harbor-env). |
| 183 | + |
| 184 | +```bash |
| 185 | +# Using harbor env |
| 186 | +harbor env boost HARBOR_BOOST_API_KEY_MISTRAL sk-mistral |
| 187 | + |
| 188 | +# Or open one of these in your text editor |
| 189 | +open $(harbor home)/.env |
| 190 | +open $(harbor home)/services/boost/override.env |
| 191 | +``` |
| 192 | + |
| 193 | +See all supported environment variables in the [Environment Variables Reference](../docs/5.2.2-Harbor-Boost-Configuration). |
| 194 | + |
| 195 | +There's no configuration for this module yet. |
| 196 | + |
| 197 | +### API |
| 198 | + |
| 199 | +`boost` works as an OpenAI-compatible API proxy. It'll query configured downstream services for which models they serve and provide "boosted" wrappers in its own API. |
| 200 | + |
| 201 | +See the [http catalog](https://github.com/av/harbor/blob/main/http-catalog/boost.http) entry for some sample requests. |
| 202 | + |
| 203 | +**Authorization** |
| 204 | + |
| 205 | +When [configured](#boost-configuration) to require an API key, you can provide the API key in the `Authorization` header. |
| 206 | + |
| 207 | +```http |
| 208 | +<!-- All three versions are accepted --> |
| 209 | +Authorization: sk-boost |
| 210 | +Authorization: bearer sk-boost |
| 211 | +Authorization: Bearer sk-boost |
| 212 | +``` |
| 213 | + |
| 214 | +**`GET /v1/models`** |
| 215 | + |
| 216 | +List boosted models. `boost` will serve additional models as per enabled modules. For example: |
| 217 | + |
| 218 | +```jsonc |
| 219 | +[ |
| 220 | + { |
| 221 | + // Original, unmodified model proxy |
| 222 | + "id": "llama3.1:8b" |
| 223 | + // ... |
| 224 | + }, |
| 225 | + { |
| 226 | + // LLM with klmbr technique applied |
| 227 | + "id": "klmbr-llama3.1:8b" |
| 228 | + // ... |
| 229 | + }, |
| 230 | + { |
| 231 | + // LLM with rcn technique applied |
| 232 | + "id": "rcn-llama3.1:8b" |
| 233 | + // ... |
| 234 | + } |
| 235 | +] |
| 236 | +``` |
| 237 | + |
| 238 | +**`POST /v1/chat/completions`** |
| 239 | + |
| 240 | +Chat completions endpoint. |
| 241 | + |
| 242 | +- Proxies all parameters to the downstream API, so custom payloads are supported out of the box, for example `json` format for Ollama |
| 243 | +- Supports streaming completions and tool calls |
| 244 | + |
| 245 | +```bash |
| 246 | +POST http://localhost:34131/v1/chat/completions |
| 247 | + |
| 248 | +{ |
| 249 | + "model": "llama3.1:8b", |
| 250 | + "messages": [ |
| 251 | + { "role": "user", "content": "Suggest me a random color" } |
| 252 | + ], |
| 253 | + "stream": true |
| 254 | +} |
| 255 | +``` |
| 256 | +
|
| 257 | +**`GET /events/:stream_id`** |
| 258 | +
|
| 259 | +Listen to a specific stream of events (associated with a single completion workflow). The stream ID is a unique identifier of the LLM instance processing the request (you may decide to advertise/pass it to the client in the workflow's code). |
| 260 | +
|
| 261 | +**`GET /health`** |
| 262 | +
|
| 263 | +Health check endpoint. Returns `{ status: 'ok' }` if the service is running. |
| 264 | +
|
| 265 | +### Standalone usage |
| 266 | +
|
| 267 | +You can run boost as a standalone Docker container. See [harbor-boost](https://github.com/av/harbor/pkgs/container/harbor-boost) package in GitHub Container Registry. |
| 268 | +
|
| 269 | +```bash |
| 270 | +# [Optional] pre-pull the image |
| 271 | +docker pull ghcr.io/av/harbor-boost:latest |
| 272 | +
|
| 273 | +# Start the container |
| 274 | +docker run \ |
| 275 | + # 172.17.0.1 is the default IP of the host, when running on Linux |
| 276 | + # So, the example below is for local ollama |
| 277 | + -e "HARBOR_BOOST_OPENAI_URLS=http://172.17.0.1:11434/v1" \ |
| 278 | + -e "HARBOR_BOOST_OPENAI_KEYS=sk-ollama" \ |
| 279 | + # Configuration for the boost modules |
| 280 | + -e "HARBOR_BOOST_MODULES=klmbr;rcn;g1" \ |
| 281 | + -e "HARBOR_BOOST_KLMBR_PERCENTAGE=60" \ |
| 282 | + # [Optional] mount folder with custom modules |
| 283 | + -v /path/to/custom_modules/folder:/app/custom_modules \ |
| 284 | + -p 8004:8000 \ |
| 285 | + ghcr.io/av/harbor-boost:latest |
| 286 | +
|
| 287 | +# In the separate terminal (or detach the container) |
| 288 | +curl http://localhost:8004/health |
| 289 | +curl http://localhost:8004/v1/models |
| 290 | +``` |
| 291 | +
|
| 292 | +You can take a look at a [`boost-starter`](https://github.com/av/boost-starter) repo for a minimal example repository to get started. |
| 293 | +
|
| 294 | +**Configuration** |
| 295 | +
|
| 296 | +See [Environment Variables Reference](../docs/5.2.2-Harbor-Boost-Configuration). |
0 commit comments