outo-llms 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. outo_llms-0.1.0/.gitignore +14 -0
  2. outo_llms-0.1.0/LICENSE +201 -0
  3. outo_llms-0.1.0/PKG-INFO +146 -0
  4. outo_llms-0.1.0/README.md +116 -0
  5. outo_llms-0.1.0/docs/architecture.md +151 -0
  6. outo_llms-0.1.0/docs/cli.md +245 -0
  7. outo_llms-0.1.0/docs/configuration.md +122 -0
  8. outo_llms-0.1.0/docs/development.md +177 -0
  9. outo_llms-0.1.0/docs/engines.md +152 -0
  10. outo_llms-0.1.0/docs/index.md +37 -0
  11. outo_llms-0.1.0/docs/installation.md +62 -0
  12. outo_llms-0.1.0/docs/philosophy.md +48 -0
  13. outo_llms-0.1.0/docs/quickstart.md +153 -0
  14. outo_llms-0.1.0/docs/security.md +87 -0
  15. outo_llms-0.1.0/docs/server-api.md +417 -0
  16. outo_llms-0.1.0/docs/testing.md +106 -0
  17. outo_llms-0.1.0/pyproject.toml +47 -0
  18. outo_llms-0.1.0/src/outo_llms/__init__.py +4 -0
  19. outo_llms-0.1.0/src/outo_llms/__main__.py +6 -0
  20. outo_llms-0.1.0/src/outo_llms/cli/__init__.py +1 -0
  21. outo_llms-0.1.0/src/outo_llms/cli/app.py +34 -0
  22. outo_llms-0.1.0/src/outo_llms/cli/commands/__init__.py +1 -0
  23. outo_llms-0.1.0/src/outo_llms/cli/commands/engine.py +90 -0
  24. outo_llms-0.1.0/src/outo_llms/cli/commands/models.py +94 -0
  25. outo_llms-0.1.0/src/outo_llms/cli/commands/reset.py +37 -0
  26. outo_llms-0.1.0/src/outo_llms/cli/commands/restart.py +20 -0
  27. outo_llms-0.1.0/src/outo_llms/cli/commands/setup.py +209 -0
  28. outo_llms-0.1.0/src/outo_llms/cli/commands/start.py +20 -0
  29. outo_llms-0.1.0/src/outo_llms/cli/commands/status.py +60 -0
  30. outo_llms-0.1.0/src/outo_llms/cli/commands/stop.py +23 -0
  31. outo_llms-0.1.0/src/outo_llms/cli/commands/version.py +14 -0
  32. outo_llms-0.1.0/src/outo_llms/core/__init__.py +5 -0
  33. outo_llms-0.1.0/src/outo_llms/core/certs.py +69 -0
  34. outo_llms-0.1.0/src/outo_llms/core/config.py +59 -0
  35. outo_llms-0.1.0/src/outo_llms/core/consent.py +75 -0
  36. outo_llms-0.1.0/src/outo_llms/core/paths.py +72 -0
  37. outo_llms-0.1.0/src/outo_llms/core/process.py +149 -0
  38. outo_llms-0.1.0/src/outo_llms/engines/__init__.py +12 -0
  39. outo_llms-0.1.0/src/outo_llms/engines/base.py +66 -0
  40. outo_llms-0.1.0/src/outo_llms/engines/llamacpp.py +58 -0
  41. outo_llms-0.1.0/src/outo_llms/engines/manager.py +288 -0
  42. outo_llms-0.1.0/src/outo_llms/engines/vllm.py +44 -0
  43. outo_llms-0.1.0/src/outo_llms/server/__init__.py +1 -0
  44. outo_llms-0.1.0/src/outo_llms/server/__main__.py +33 -0
  45. outo_llms-0.1.0/src/outo_llms/server/accounts.py +188 -0
  46. outo_llms-0.1.0/src/outo_llms/server/app.py +108 -0
  47. outo_llms-0.1.0/src/outo_llms/server/db.py +71 -0
  48. outo_llms-0.1.0/src/outo_llms/server/deps.py +34 -0
  49. outo_llms-0.1.0/src/outo_llms/server/proxy.py +194 -0
  50. outo_llms-0.1.0/src/outo_llms/server/registry.py +64 -0
  51. outo_llms-0.1.0/src/outo_llms/server/routes/__init__.py +1 -0
  52. outo_llms-0.1.0/src/outo_llms/server/routes/account.py +31 -0
  53. outo_llms-0.1.0/src/outo_llms/server/routes/keys.py +59 -0
  54. outo_llms-0.1.0/src/outo_llms/server/routes/usage.py +17 -0
  55. outo_llms-0.1.0/src/outo_llms/server/routes/workspaces.py +34 -0
  56. outo_llms-0.1.0/src/outo_llms/server/schemas.py +58 -0
  57. outo_llms-0.1.0/src/outo_llms/server/usage.py +66 -0
@@ -0,0 +1,14 @@
1
+ __pycache__/
2
+ *.py[cod]
3
+ *.egg-info/
4
+ .eggs/
5
+ build/
6
+ dist/
7
+ .venv/
8
+ .venv*/
9
+ .env
10
+ .pytest_cache/
11
+ .mypy_cache/
12
+ .ruff_cache/
13
+ .DS_Store
14
+ .omo/
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 outo-llms contributors
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
@@ -0,0 +1,146 @@
1
+ Metadata-Version: 2.4
2
+ Name: outo-llms
3
+ Version: 0.1.0
4
+ Summary: Deploy local LLMs behind your own managed API server - vLLM or llama.cpp in isolated environments, with API keys, workspaces, and usage tracking.
5
+ Project-URL: Homepage, https://github.com/llaa33219/outo-llms
6
+ Project-URL: Repository, https://github.com/llaa33219/outo-llms
7
+ Project-URL: Issues, https://github.com/llaa33219/outo-llms/issues
8
+ Author: outo-llms contributors
9
+ License: Apache-2.0
10
+ License-File: LICENSE
11
+ Keywords: api-server,inference,llama.cpp,llm,self-hosted,vllm
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: Apache Software License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
20
+ Requires-Python: >=3.10
21
+ Requires-Dist: cryptography>=42
22
+ Requires-Dist: fastapi>=0.110
23
+ Requires-Dist: httpx>=0.27
24
+ Requires-Dist: platformdirs>=4
25
+ Requires-Dist: pydantic>=2
26
+ Requires-Dist: rich>=13
27
+ Requires-Dist: typer>=0.12
28
+ Requires-Dist: uvicorn[standard]>=0.29
29
+ Description-Content-Type: text/markdown
30
+
31
+ # outo-llms
32
+
33
+ Deploy local LLMs behind your own managed, OpenAI-compatible API server.
34
+
35
+ vLLM or llama.cpp runs in an **isolated environment** managed by outo-llms,
36
+ kept apart from the Python environments you already have. Users sign up,
37
+ receive API keys, organize work into workspaces, and every request is
38
+ metered per workspace. Open the dashboard, point your OpenAI SDK at the
39
+ URL, and the rest is just an HTTP call.
40
+
41
+ Full documentation lives in [`docs/`](docs/index.md).
42
+
43
+ ## Principles
44
+
45
+ 1. **Fragmentation** - small, single-purpose modules.
46
+ 2. **Fluidity** - features can be added or removed as needs change.
47
+ 3. **Simplicity** - a handful of commands and a small API cover the common workflow.
48
+ 4. **Automation** - one guided command gets you a working deployment.
49
+ 5. **Explicitness** - every automated action is announced and logged; the
50
+ system is never touched without your knowledge.
51
+
52
+ ## Features
53
+
54
+ - **Isolated engine virtualenvs.** vLLM and llama.cpp install into their
55
+ own virtual environments, never into the system interpreter.
56
+ - **Choice of engines.** Bring Hugging Face models through vLLM, or GGUF
57
+ models through llama.cpp, and switch between them with one command.
58
+ - **Account, keys, and workspaces.** Open signup issues an `outo_sk_` API
59
+ key, creates a `default` workspace, and lets each user create more.
60
+ - **Per-workspace usage metering.** Token usage is recorded by workspace
61
+ and surfaced at `GET /v1/usage`.
62
+ - **OpenAI-compatible proxy.** `POST /v1/chat/completions`,
63
+ `POST /v1/completions`, and `GET /v1/models` speak the same shapes
64
+ clients already know.
65
+ - **Optional HTTPS.** A self-signed certificate is generated under
66
+ `data/certs/` when you ask for it.
67
+ - **Explicit automation with an action log.** Every setup step is
68
+ announced, confirmed when destructive, and appended to `actions.log`.
69
+ - **Dashboard and Swagger UI.** Visit the root URL for a tiny status
70
+ page, or `/docs` for the full OpenAPI explorer.
71
+
72
+ ## Install
73
+
74
+ ```bash
75
+ pip install outo-llms
76
+ ```
77
+
78
+ Prefer an isolated install? `pipx install outo-llms` works too.
79
+
80
+ ## Quickstart
81
+
82
+ ```bash
83
+ outo-llms setup # interactive, fully explicit setup
84
+ curl -s -X POST http://127.0.0.1:8611/v1/account/signup \
85
+ -H 'Content-Type: application/json' \
86
+ -d '{"username": "me"}' # returns an api_key + default workspace
87
+ outo-llms models add tinyllama # register a Hugging Face model
88
+ curl -s http://127.0.0.1:8611/v1/chat/completions \
89
+ -H "Authorization: Bearer outo_sk_..." \
90
+ -H 'Content-Type: application/json' \
91
+ -d '{"model": "tinyllama", "messages": [{"role": "user", "content": "hi"}]}'
92
+ curl -s http://127.0.0.1:8611/v1/usage \
93
+ -H "Authorization: Bearer outo_sk_..." # per-workspace token accounting
94
+ ```
95
+
96
+ The setup wizard prints the exact base URL it configured (HTTP or HTTPS),
97
+ along with the path to the action log, and writes a short summary you can
98
+ copy into your shell history.
99
+
100
+ ## Commands
101
+
102
+ | Command | Purpose |
103
+ | --- | --- |
104
+ | `outo-llms setup` | Automated, explicit server setup (engine, HTTPS, firewall, launch) |
105
+ | `outo-llms models add <name>` | Register a model in the registry |
106
+ | `outo-llms models list` | Show every registered model |
107
+ | `outo-llms models remove <name>` | Unregister a model (asks first) |
108
+ | `outo-llms engine list` | List known engines and their installed state |
109
+ | `outo-llms engine use <name>` | Switch the active engine (llamacpp or vllm) |
110
+ | `outo-llms engine install [name]` | Install an engine into its isolated virtualenv |
111
+ | `outo-llms engine status` | Show the active engine's runtime status |
112
+ | `outo-llms start` | Start the API server in the background |
113
+ | `outo-llms stop` | Stop the background API server |
114
+ | `outo-llms restart` | Restart the API server |
115
+ | `outo-llms status` | Show server, engine, and path status |
116
+ | `outo-llms reset` | Wipe everything back to factory state (asks twice) |
117
+ | `outo-llms version` | Print the version |
118
+
119
+ ## How it works
120
+
121
+ The outo-llms server (`python -m outo_llms.server`) binds `127.0.0.1:8611`
122
+ by default and exposes an OpenAI-compatible HTTP API. Engines are
123
+ internal services that bind their own loopback ports (llama.cpp on 8612,
124
+ vLLM on 8613); clients never reach them directly.
125
+
126
+ When a request hits `POST /v1/chat/completions` or `POST /v1/completions`,
127
+ the server looks up the requested model in the registry, asks the engine
128
+ manager to ensure the right engine is running with that model, then
129
+ forwards the request. The active engine streams or returns its response
130
+ unchanged, and the server records prompt and completion tokens against
131
+ the calling workspace.
132
+
133
+ Every state change, install step, and external command goes through
134
+ `outo_llms.core.consent`, which announces what is about to happen, asks
135
+ for confirmation on destructive actions, and writes a timestamped line to
136
+ `logs/actions.log`. The dashboard at the root URL and Swagger UI at
137
+ `/docs` round out the picture.
138
+
139
+ ## Documentation
140
+
141
+ - [`docs/index.md`](docs/index.md) — entry point for installation, API,
142
+ configuration, operations, and testing guides.
143
+
144
+ ## License
145
+
146
+ Apache License 2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,116 @@
1
+ # outo-llms
2
+
3
+ Deploy local LLMs behind your own managed, OpenAI-compatible API server.
4
+
5
+ vLLM or llama.cpp runs in an **isolated environment** managed by outo-llms,
6
+ kept apart from the Python environments you already have. Users sign up,
7
+ receive API keys, organize work into workspaces, and every request is
8
+ metered per workspace. Open the dashboard, point your OpenAI SDK at the
9
+ URL, and the rest is just an HTTP call.
10
+
11
+ Full documentation lives in [`docs/`](docs/index.md).
12
+
13
+ ## Principles
14
+
15
+ 1. **Fragmentation** - small, single-purpose modules.
16
+ 2. **Fluidity** - features can be added or removed as needs change.
17
+ 3. **Simplicity** - a handful of commands and a small API cover the common workflow.
18
+ 4. **Automation** - one guided command gets you a working deployment.
19
+ 5. **Explicitness** - every automated action is announced and logged; the
20
+ system is never touched without your knowledge.
21
+
22
+ ## Features
23
+
24
+ - **Isolated engine virtualenvs.** vLLM and llama.cpp install into their
25
+ own virtual environments, never into the system interpreter.
26
+ - **Choice of engines.** Bring Hugging Face models through vLLM, or GGUF
27
+ models through llama.cpp, and switch between them with one command.
28
+ - **Account, keys, and workspaces.** Open signup issues an `outo_sk_` API
29
+ key, creates a `default` workspace, and lets each user create more.
30
+ - **Per-workspace usage metering.** Token usage is recorded by workspace
31
+ and surfaced at `GET /v1/usage`.
32
+ - **OpenAI-compatible proxy.** `POST /v1/chat/completions`,
33
+ `POST /v1/completions`, and `GET /v1/models` speak the same shapes
34
+ clients already know.
35
+ - **Optional HTTPS.** A self-signed certificate is generated under
36
+ `data/certs/` when you ask for it.
37
+ - **Explicit automation with an action log.** Every setup step is
38
+ announced, confirmed when destructive, and appended to `actions.log`.
39
+ - **Dashboard and Swagger UI.** Visit the root URL for a tiny status
40
+ page, or `/docs` for the full OpenAPI explorer.
41
+
42
+ ## Install
43
+
44
+ ```bash
45
+ pip install outo-llms
46
+ ```
47
+
48
+ Prefer an isolated install? `pipx install outo-llms` works too.
49
+
50
+ ## Quickstart
51
+
52
+ ```bash
53
+ outo-llms setup # interactive, fully explicit setup
54
+ curl -s -X POST http://127.0.0.1:8611/v1/account/signup \
55
+ -H 'Content-Type: application/json' \
56
+ -d '{"username": "me"}' # returns an api_key + default workspace
57
+ outo-llms models add tinyllama # register a Hugging Face model
58
+ curl -s http://127.0.0.1:8611/v1/chat/completions \
59
+ -H "Authorization: Bearer outo_sk_..." \
60
+ -H 'Content-Type: application/json' \
61
+ -d '{"model": "tinyllama", "messages": [{"role": "user", "content": "hi"}]}'
62
+ curl -s http://127.0.0.1:8611/v1/usage \
63
+ -H "Authorization: Bearer outo_sk_..." # per-workspace token accounting
64
+ ```
65
+
66
+ The setup wizard prints the exact base URL it configured (HTTP or HTTPS),
67
+ along with the path to the action log, and writes a short summary you can
68
+ copy into your shell history.
69
+
70
+ ## Commands
71
+
72
+ | Command | Purpose |
73
+ | --- | --- |
74
+ | `outo-llms setup` | Automated, explicit server setup (engine, HTTPS, firewall, launch) |
75
+ | `outo-llms models add <name>` | Register a model in the registry |
76
+ | `outo-llms models list` | Show every registered model |
77
+ | `outo-llms models remove <name>` | Unregister a model (asks first) |
78
+ | `outo-llms engine list` | List known engines and their installed state |
79
+ | `outo-llms engine use <name>` | Switch the active engine (llamacpp or vllm) |
80
+ | `outo-llms engine install [name]` | Install an engine into its isolated virtualenv |
81
+ | `outo-llms engine status` | Show the active engine's runtime status |
82
+ | `outo-llms start` | Start the API server in the background |
83
+ | `outo-llms stop` | Stop the background API server |
84
+ | `outo-llms restart` | Restart the API server |
85
+ | `outo-llms status` | Show server, engine, and path status |
86
+ | `outo-llms reset` | Wipe everything back to factory state (asks twice) |
87
+ | `outo-llms version` | Print the version |
88
+
89
+ ## How it works
90
+
91
+ The outo-llms server (`python -m outo_llms.server`) binds `127.0.0.1:8611`
92
+ by default and exposes an OpenAI-compatible HTTP API. Engines are
93
+ internal services that bind their own loopback ports (llama.cpp on 8612,
94
+ vLLM on 8613); clients never reach them directly.
95
+
96
+ When a request hits `POST /v1/chat/completions` or `POST /v1/completions`,
97
+ the server looks up the requested model in the registry, asks the engine
98
+ manager to ensure the right engine is running with that model, then
99
+ forwards the request. The active engine streams or returns its response
100
+ unchanged, and the server records prompt and completion tokens against
101
+ the calling workspace.
102
+
103
+ Every state change, install step, and external command goes through
104
+ `outo_llms.core.consent`, which announces what is about to happen, asks
105
+ for confirmation on destructive actions, and writes a timestamped line to
106
+ `logs/actions.log`. The dashboard at the root URL and Swagger UI at
107
+ `/docs` round out the picture.
108
+
109
+ ## Documentation
110
+
111
+ - [`docs/index.md`](docs/index.md) — entry point for installation, API,
112
+ configuration, operations, and testing guides.
113
+
114
+ ## License
115
+
116
+ Apache License 2.0. See [`LICENSE`](LICENSE).
@@ -0,0 +1,151 @@
1
+ # Architecture
2
+
3
+ This page describes the module boundaries, the request flow, and the extension points. The implementation is deliberately small. Each concern lives in one module.
4
+
5
+ ## Module map
6
+
7
+ ```text
8
+ src/outo_llms/
9
+ ├── __init__.py package metadata and version
10
+ ├── __main__.py `python -m outo_llms` placeholder
11
+ ├── core/
12
+ │ ├── paths.py XDG-style paths and directory creation
13
+ │ ├── config.py JSON-backed server and engine configuration
14
+ │ ├── consent.py announce, confirm, confirm_twice, log_action, run_system
15
+ │ ├── process.py server start, stop, restart, pid helpers, port polling
16
+ │ └── certs.py self-signed certificate generation for HTTPS
17
+ ├── engines/
18
+ │ ├── base.py EngineAdapter contract, ModelRef, adapter registry
19
+ │ ├── llamacpp.py llama.cpp adapter and serve argv
20
+ │ ├── vllm.py vLLM adapter and serve argv
21
+ │ └── manager.py EngineManager: install, use, ensure_running, stop
22
+ ├── server/
23
+ │ ├── __main__.py uvicorn entry point: `python -m outo_llms.server`
24
+ │ ├── app.py FastAPI factory, lifespan, /healthz, /
25
+ │ ├── db.py SQLite connection, schema, init_db, utcnow
26
+ │ ├── accounts.py users, workspaces, key issue/revoke/verify
27
+ │ ├── registry.py model registry CRUD
28
+ │ ├── usage.py usage record and aggregate summary
29
+ │ ├── schemas.py Pydantic v2 request and response models
30
+ │ ├── deps.py OpenAI-style error helper, WorkspaceDep auth dependency
31
+ │ ├── proxy.py OpenAI-compatible proxy with usage accounting
32
+ │ └── routes/
33
+ │ ├── account.py POST /v1/account/signup, GET /v1/account/me
34
+ │ ├── workspaces.py POST /v1/workspaces, GET /v1/workspaces
35
+ │ ├── keys.py POST/GET /v1/workspaces/{name}/keys, DELETE /v1/keys/{key_id}
36
+ │ └── usage.py GET /v1/usage
37
+ └── cli/
38
+ ├── app.py Typer application, command registration
39
+ └── commands/
40
+ ├── setup.py outo-llms setup
41
+ ├── start.py outo-llms start
42
+ ├── stop.py outo-llms stop
43
+ ├── restart.py outo-llms restart
44
+ ├── status.py outo-llms status
45
+ ├── reset.py outo-llms reset
46
+ ├── version.py outo-llms version
47
+ ├── models.py outo-llms models add/list/remove
48
+ └── engine.py outo-llms engine list/use/install/status
49
+ ```
50
+
51
+ ## Layered responsibilities
52
+
53
+ The implementation is layered:
54
+
55
+ * `core/` is shared infrastructure. It has no knowledge of engine adapters, accounts, or HTTP routes.
56
+ * `engines/` knows about adapters and how to run them. It calls `core/` for paths, consent, configuration, and process control.
57
+ * `server/` knows about HTTP, persistence, accounts, the proxy, and the OpenAI-compatible surface. It calls `engines/` lazily for inference and `core/` for shared helpers.
58
+ * `cli/` knows about the user command surface. It calls into the same modules as the server.
59
+
60
+ The boundaries mean a change to a CLI command does not change the server, and a change to an engine adapter does not change accounts or the CLI.
61
+
62
+ ## Request flow
63
+
64
+ ```text
65
+ client outo-llms API server EngineManager engine subprocess
66
+ │ │ │ │
67
+ │ HTTP /v1/chat/... │ │ │
68
+ │ (Bearer outo_sk_...) │ │ │
69
+ │ ────────────────────────▶ │ │
70
+ │ │ require_workspace(): │ │
71
+ │ │ parse header, verify key │ │
72
+ │ │ → WorkspaceContext │ │
73
+ │ │ resolve model in registry │ │
74
+ │ │ ensure_running(model_ref) ─────▶│ │
75
+ │ │ │ start / reuse │
76
+ │ │ │ engine process ───▶│
77
+ │ │ │ poll /v1/models │
78
+ │ │ │ until 200 │
79
+ │ │ ensure_running returns base_url │ │
80
+ │ │ proxy.forward → upstream URL │ │
81
+ │ │ ────────────────────────────────▶ ──────────────────▶│
82
+ │ │ │ │ run inference
83
+ │ │ ◀──────────────────────────────── ───────────────────│
84
+ │ │ record usage (non-stream or │ │
85
+ │ │ final SSE event with usage) │ │
86
+ │ ◀──────────────────────── │ │
87
+ │ OpenAI-style response or SSE stream │ │
88
+ ```
89
+
90
+ For `chat/completions` and `completions`, the proxy does the following:
91
+
92
+ 1. Parse and validate the JSON body.
93
+ 2. Resolve the `model` field against the registry. Missing `model` is HTTP `400`. Unknown model is HTTP `404` with `code: "model_not_found"`.
94
+ 3. Call `EngineManager.ensure_running(model_ref)` to start or reuse the engine. A missing engine installation or an unsupported kind is HTTP `502`.
95
+ 4. Forward the request to the upstream OpenAI-compatible URL on `127.0.0.1:<engine-port>`.
96
+ 5. For non-streaming responses, parse JSON, read `usage.prompt_tokens` and `usage.completion_tokens`, and record a usage row.
97
+ 6. For streaming responses, set `stream_options.include_usage: true`, stream SSE bytes, then inspect the assembled text for a usage-bearing event and record usage best effort.
98
+
99
+ The same dependency authenticates every authenticated route. Errors return through the OpenAI-style error helper in `server/deps.py`.
100
+
101
+ ## Process model
102
+
103
+ ```text
104
+ shell
105
+ └── outo-llms start (this process exits after subprocess.Popen + PID write)
106
+ └── python -m outo_llms.server (API server, detached via start_new_session=True)
107
+ ├── uvicorn loop
108
+ │ ├── /healthz, /, /docs
109
+ │ ├── /v1/account/signup, /v1/account/me
110
+ │ ├── /v1/workspaces, /v1/workspaces/{name}/keys
111
+ │ ├── /v1/keys/{key_id}
112
+ │ ├── /v1/usage
113
+ │ └── /v1/models, /v1/chat/completions, /v1/completions
114
+ └── EngineManager.ensure_running on demand
115
+ └── python -m llama_cpp.server (or vllm.entrypoints.openai.api_server)
116
+ ```
117
+
118
+ The API server is a detached process with output redirected to `data/logs/server.log`. Its PID is stored in `data/server.pid`. `outo-llms stop` reads the PID file, sends SIGTERM, waits for the process to exit, and sends SIGKILL if needed.
119
+
120
+ Engine processes follow the same pattern with PID, port, and model name written directly under `data/engines/`. `EngineManager` reuses a running engine when the same model is requested, and it stops and restarts the engine when a different model is requested or when a stale PID is detected.
121
+
122
+ The `__main__.py` for `outo_llms.server` calls `uvicorn.run(...)` with the configured host and port. If HTTPS is enabled, it asks `core/certs.py` for a self-signed pair and passes them to Uvicorn.
123
+
124
+ ## How fragmentation and fluidity show up
125
+
126
+ * **Adding an engine.** Create a new module under `src/outo_llms/engines/` with a class that extends `EngineAdapter`. Add its name to `adapter_names()` and the lookup in `get_adapter()`. The manager, server, and CLI pick it up automatically.
127
+ * **Adding a CLI command.** Create a new module under `src/outo_llms/cli/commands/` with a Typer function. Register it in `src/outo_llms/cli/app.py`. For a command group, create a Typer app and use `app.add_typer`.
128
+ * **Adding an HTTP route.** Create a new module under `src/outo_llms/server/routes/` with a router. Include it in `src/outo_llms/server/app.py`. Use the `WorkspaceDep` dependency for authenticated routes and the `openai_error` helper for OpenAI-style error responses.
129
+ * **Adding configuration.** Extend a dataclass in `src/outo_llms/core/config.py`. The loader falls back to defaults for missing keys, so older `config.json` files still work.
130
+
131
+ The [development guide](development.md) walks through each extension in detail.
132
+
133
+ ## Data and persistence
134
+
135
+ SQLite is the only database. The schema covers five tables: `users`, `workspaces`, `api_keys`, `models`, and `usage`. The schema is created by `db.init_db()` from a single `CREATE TABLE IF NOT EXISTS` script. All timestamps are UTC ISO-8601 strings. Foreign keys are enabled per connection. Queries use parameter binding.
136
+
137
+ The `EngineManager` keeps no in-memory state between calls. All state lives on disk: `config.json`, engine marker files, engine PID, port, model files, the database, the action log, and engine and server logs.
138
+
139
+ ## What does not change
140
+
141
+ These are stable contracts documented for users and contributors:
142
+
143
+ * The `EngineManager` API in `engines/manager.py`.
144
+ * The registry functions `add_model`, `get_model`, `list_models`, and `remove_model` in `server/registry.py`.
145
+ * `db.init_db` in `server/db.py`.
146
+ * The process helpers `start_server`, `stop_server`, and `restart_server` in `core/process.py`.
147
+ * The console entry point `outo_llms.cli.app:main`, exposed as `outo-llms`.
148
+ * The module entry point `python -m outo_llms.server`.
149
+ * The OpenAI-style error shape.
150
+
151
+ Changes to those contracts require updates to every caller and to the documentation.