airmux 0.1.2__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 (175) hide show
  1. airmux-0.1.2/LICENSE +93 -0
  2. airmux-0.1.2/PKG-INFO +220 -0
  3. airmux-0.1.2/README.md +191 -0
  4. airmux-0.1.2/pyproject.toml +48 -0
  5. airmux-0.1.2/src/airmux_runtime/__init__.py +1 -0
  6. airmux-0.1.2/src/airmux_runtime/config.py +98 -0
  7. airmux-0.1.2/src/airmux_runtime/files.py +60 -0
  8. airmux-0.1.2/src/airmux_runtime/secrets/__init__.py +40 -0
  9. airmux-0.1.2/src/airmux_runtime/secrets/base.py +125 -0
  10. airmux-0.1.2/src/airmux_runtime/secrets/env.py +58 -0
  11. airmux-0.1.2/src/airmux_runtime/secrets/file.py +87 -0
  12. airmux-0.1.2/src/airmux_runtime/secrets/insecure_database.py +144 -0
  13. airmux-0.1.2/src/airmux_runtime/secrets/memory.py +31 -0
  14. airmux-0.1.2/src/airmux_runtime/taxonomy.py +71 -0
  15. airmux-0.1.2/src/api_models/__init__.py +2349 -0
  16. airmux-0.1.2/src/cli/__init__.py +1 -0
  17. airmux-0.1.2/src/cli/auth.py +471 -0
  18. airmux-0.1.2/src/cli/client.py +169 -0
  19. airmux-0.1.2/src/cli/commands.py +66 -0
  20. airmux-0.1.2/src/cli/common.py +97 -0
  21. airmux-0.1.2/src/cli/completion.py +20 -0
  22. airmux-0.1.2/src/cli/control_plane.py +151 -0
  23. airmux-0.1.2/src/cli/diagnostics.py +161 -0
  24. airmux-0.1.2/src/cli/gateway.py +119 -0
  25. airmux-0.1.2/src/cli/main.py +27 -0
  26. airmux-0.1.2/src/cli/output.py +81 -0
  27. airmux-0.1.2/src/cli/policies.py +71 -0
  28. airmux-0.1.2/src/cli/profiles.py +141 -0
  29. airmux-0.1.2/src/cli/resources.py +709 -0
  30. airmux-0.1.2/src/cli/runtime.py +56 -0
  31. airmux-0.1.2/src/contract/__init__.py +56 -0
  32. airmux-0.1.2/src/contract/bundle.py +118 -0
  33. airmux-0.1.2/src/contract/credentials.py +18 -0
  34. airmux-0.1.2/src/contract/events.py +101 -0
  35. airmux-0.1.2/src/contract/ids.py +17 -0
  36. airmux-0.1.2/src/contract/model_types.py +8 -0
  37. airmux-0.1.2/src/contract/money.py +73 -0
  38. airmux-0.1.2/src/contract/policies.py +173 -0
  39. airmux-0.1.2/src/contract/secrets/__init__.py +29 -0
  40. airmux-0.1.2/src/contract/taxonomy.py +100 -0
  41. airmux-0.1.2/src/control_plane/__init__.py +1 -0
  42. airmux-0.1.2/src/control_plane/app.py +210 -0
  43. airmux-0.1.2/src/control_plane/authority.py +221 -0
  44. airmux-0.1.2/src/control_plane/authz.py +298 -0
  45. airmux-0.1.2/src/control_plane/bootstrap.py +67 -0
  46. airmux-0.1.2/src/control_plane/compiler.py +138 -0
  47. airmux-0.1.2/src/control_plane/config.py +79 -0
  48. airmux-0.1.2/src/control_plane/db.py +62 -0
  49. airmux-0.1.2/src/control_plane/deps.py +260 -0
  50. airmux-0.1.2/src/control_plane/fixtures.py +526 -0
  51. airmux-0.1.2/src/control_plane/keys.py +163 -0
  52. airmux-0.1.2/src/control_plane/migrate.py +42 -0
  53. airmux-0.1.2/src/control_plane/migrations/env.py +42 -0
  54. airmux-0.1.2/src/control_plane/migrations/script.py.mako +25 -0
  55. airmux-0.1.2/src/control_plane/migrations/versions/.gitkeep +0 -0
  56. airmux-0.1.2/src/control_plane/migrations/versions/a9f3c6e1d8b4_initial_schema.py +649 -0
  57. airmux-0.1.2/src/control_plane/models/__init__.py +58 -0
  58. airmux-0.1.2/src/control_plane/models/audit.py +157 -0
  59. airmux-0.1.2/src/control_plane/models/auth_identity.py +55 -0
  60. airmux-0.1.2/src/control_plane/models/auth_session.py +29 -0
  61. airmux-0.1.2/src/control_plane/models/bundle.py +30 -0
  62. airmux-0.1.2/src/control_plane/models/bundle_input.py +87 -0
  63. airmux-0.1.2/src/control_plane/models/bundle_state.py +114 -0
  64. airmux-0.1.2/src/control_plane/models/cli_auth_request.py +84 -0
  65. airmux-0.1.2/src/control_plane/models/common/__init__.py +26 -0
  66. airmux-0.1.2/src/control_plane/models/common/base.py +81 -0
  67. airmux-0.1.2/src/control_plane/models/common/column_types.py +10 -0
  68. airmux-0.1.2/src/control_plane/models/common/identified.py +68 -0
  69. airmux-0.1.2/src/control_plane/models/common/org_owned.py +25 -0
  70. airmux-0.1.2/src/control_plane/models/common/pagination.py +74 -0
  71. airmux-0.1.2/src/control_plane/models/common/slugs.py +17 -0
  72. airmux-0.1.2/src/control_plane/models/common/tombstone.py +84 -0
  73. airmux-0.1.2/src/control_plane/models/common/wire.py +73 -0
  74. airmux-0.1.2/src/control_plane/models/data_plane_instance.py +54 -0
  75. airmux-0.1.2/src/control_plane/models/global_bundle_state.py +11 -0
  76. airmux-0.1.2/src/control_plane/models/inference_key.py +94 -0
  77. airmux-0.1.2/src/control_plane/models/insecure_vault_secret.py +14 -0
  78. airmux-0.1.2/src/control_plane/models/management_key.py +196 -0
  79. airmux-0.1.2/src/control_plane/models/model.py +59 -0
  80. airmux-0.1.2/src/control_plane/models/org.py +141 -0
  81. airmux-0.1.2/src/control_plane/models/org_invitation.py +300 -0
  82. airmux-0.1.2/src/control_plane/models/org_membership.py +91 -0
  83. airmux-0.1.2/src/control_plane/models/playground_session.py +82 -0
  84. airmux-0.1.2/src/control_plane/models/policy.py +212 -0
  85. airmux-0.1.2/src/control_plane/models/provider.py +45 -0
  86. airmux-0.1.2/src/control_plane/models/provider_credential.py +241 -0
  87. airmux-0.1.2/src/control_plane/models/usage_event.py +95 -0
  88. airmux-0.1.2/src/control_plane/models/user.py +255 -0
  89. airmux-0.1.2/src/control_plane/models/workspace.py +175 -0
  90. airmux-0.1.2/src/control_plane/models/workspace_membership.py +83 -0
  91. airmux-0.1.2/src/control_plane/openapi.py +335 -0
  92. airmux-0.1.2/src/control_plane/operations.py +165 -0
  93. airmux-0.1.2/src/control_plane/passwords.py +74 -0
  94. airmux-0.1.2/src/control_plane/publisher.py +52 -0
  95. airmux-0.1.2/src/control_plane/routes/__init__.py +1 -0
  96. airmux-0.1.2/src/control_plane/routes/auth.py +396 -0
  97. airmux-0.1.2/src/control_plane/routes/enroll.py +107 -0
  98. airmux-0.1.2/src/control_plane/routes/instance.py +35 -0
  99. airmux-0.1.2/src/control_plane/routes/invitations.py +104 -0
  100. airmux-0.1.2/src/control_plane/routes/management_keys.py +157 -0
  101. airmux-0.1.2/src/control_plane/routes/org.py +158 -0
  102. airmux-0.1.2/src/control_plane/routes/orgs.py +59 -0
  103. airmux-0.1.2/src/control_plane/routes/oss.py +21 -0
  104. airmux-0.1.2/src/control_plane/routes/policies.py +59 -0
  105. airmux-0.1.2/src/control_plane/routes/provider_credentials.py +195 -0
  106. airmux-0.1.2/src/control_plane/routes/sync.py +113 -0
  107. airmux-0.1.2/src/control_plane/routes/taxonomy.py +90 -0
  108. airmux-0.1.2/src/control_plane/routes/users.py +99 -0
  109. airmux-0.1.2/src/control_plane/routes/workspaces.py +270 -0
  110. airmux-0.1.2/src/control_plane/sessions.py +59 -0
  111. airmux-0.1.2/src/control_plane/taxonomy.py +177 -0
  112. airmux-0.1.2/src/control_plane/throttling.py +168 -0
  113. airmux-0.1.2/src/data_plane/__init__.py +1 -0
  114. airmux-0.1.2/src/data_plane/app.py +120 -0
  115. airmux-0.1.2/src/data_plane/auth.py +56 -0
  116. airmux-0.1.2/src/data_plane/bundle/__init__.py +29 -0
  117. airmux-0.1.2/src/data_plane/bundle/base.py +12 -0
  118. airmux-0.1.2/src/data_plane/bundle/config.py +34 -0
  119. airmux-0.1.2/src/data_plane/bundle/holder.py +160 -0
  120. airmux-0.1.2/src/data_plane/bundle/local.py +172 -0
  121. airmux-0.1.2/src/data_plane/bundle/remote.py +122 -0
  122. airmux-0.1.2/src/data_plane/cache.py +62 -0
  123. airmux-0.1.2/src/data_plane/canonical/__init__.py +79 -0
  124. airmux-0.1.2/src/data_plane/canonical/completion.py +343 -0
  125. airmux-0.1.2/src/data_plane/config.py +52 -0
  126. airmux-0.1.2/src/data_plane/control_plane_link.py +10 -0
  127. airmux-0.1.2/src/data_plane/credentials.py +143 -0
  128. airmux-0.1.2/src/data_plane/discovery.py +83 -0
  129. airmux-0.1.2/src/data_plane/egress/__init__.py +26 -0
  130. airmux-0.1.2/src/data_plane/egress/anthropic.py +259 -0
  131. airmux-0.1.2/src/data_plane/egress/base.py +219 -0
  132. airmux-0.1.2/src/data_plane/egress/openai_compatible.py +205 -0
  133. airmux-0.1.2/src/data_plane/egress/openai_responses.py +225 -0
  134. airmux-0.1.2/src/data_plane/errors.py +13 -0
  135. airmux-0.1.2/src/data_plane/formats/__init__.py +5 -0
  136. airmux-0.1.2/src/data_plane/formats/anthropic.py +756 -0
  137. airmux-0.1.2/src/data_plane/formats/openai.py +659 -0
  138. airmux-0.1.2/src/data_plane/formats/openai_responses.py +464 -0
  139. airmux-0.1.2/src/data_plane/heartbeat.py +58 -0
  140. airmux-0.1.2/src/data_plane/http.py +82 -0
  141. airmux-0.1.2/src/data_plane/ingress/__init__.py +33 -0
  142. airmux-0.1.2/src/data_plane/ingress/anthropic.py +183 -0
  143. airmux-0.1.2/src/data_plane/ingress/base.py +53 -0
  144. airmux-0.1.2/src/data_plane/ingress/openai_chat_completions.py +165 -0
  145. airmux-0.1.2/src/data_plane/ingress/openai_responses.py +296 -0
  146. airmux-0.1.2/src/data_plane/metering.py +179 -0
  147. airmux-0.1.2/src/data_plane/operations.py +29 -0
  148. airmux-0.1.2/src/data_plane/outbox/__init__.py +24 -0
  149. airmux-0.1.2/src/data_plane/outbox/base.py +95 -0
  150. airmux-0.1.2/src/data_plane/outbox/devnull.py +13 -0
  151. airmux-0.1.2/src/data_plane/outbox/file.py +31 -0
  152. airmux-0.1.2/src/data_plane/outbox/queued.py +213 -0
  153. airmux-0.1.2/src/data_plane/outbox/sqlite.py +164 -0
  154. airmux-0.1.2/src/data_plane/policies.py +102 -0
  155. airmux-0.1.2/src/data_plane/policy.py +127 -0
  156. airmux-0.1.2/src/data_plane/policy_actions/__init__.py +13 -0
  157. airmux-0.1.2/src/data_plane/policy_actions/allowed_models.py +11 -0
  158. airmux-0.1.2/src/data_plane/policy_actions/allowed_providers.py +11 -0
  159. airmux-0.1.2/src/data_plane/policy_actions/base.py +49 -0
  160. airmux-0.1.2/src/data_plane/policy_actions/credential_access.py +23 -0
  161. airmux-0.1.2/src/data_plane/policy_actions/deny.py +11 -0
  162. airmux-0.1.2/src/data_plane/policy_actions/fallback.py +11 -0
  163. airmux-0.1.2/src/data_plane/policy_actions/price_limit.py +16 -0
  164. airmux-0.1.2/src/data_plane/policy_actions/request_limits.py +14 -0
  165. airmux-0.1.2/src/data_plane/policy_actions/strict_parameters.py +15 -0
  166. airmux-0.1.2/src/data_plane/profiles.py +34 -0
  167. airmux-0.1.2/src/data_plane/proxy.py +266 -0
  168. airmux-0.1.2/src/data_plane/reconcile.py +92 -0
  169. airmux-0.1.2/src/data_plane/requirements.py +26 -0
  170. airmux-0.1.2/src/data_plane/resources/taxonomy.yml.gz +0 -0
  171. airmux-0.1.2/src/data_plane/routing.py +36 -0
  172. airmux-0.1.2/src/data_plane/runtime.py +24 -0
  173. airmux-0.1.2/src/data_plane/setup.py +106 -0
  174. airmux-0.1.2/src/data_plane/streaming.py +116 -0
  175. airmux-0.1.2/src/data_plane/tasks.py +20 -0
airmux-0.1.2/LICENSE ADDED
@@ -0,0 +1,93 @@
1
+ Elastic License 2.0
2
+
3
+ URL: https://www.elastic.co/licensing/elastic-license
4
+
5
+ ## Acceptance
6
+
7
+ By using the software, you agree to all of the terms and conditions below.
8
+
9
+ ## Copyright License
10
+
11
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
12
+ non-sublicensable, non-transferable license to use, copy, distribute, make
13
+ available, and prepare derivative works of the software, in each case subject to
14
+ the limitations and conditions below.
15
+
16
+ ## Limitations
17
+
18
+ You may not provide the software to third parties as a hosted or managed
19
+ service, where the service provides users with access to any substantial set of
20
+ the features or functionality of the software.
21
+
22
+ You may not move, change, disable, or circumvent the license key functionality
23
+ in the software, and you may not remove or obscure any functionality in the
24
+ software that is protected by the license key.
25
+
26
+ You may not alter, remove, or obscure any licensing, copyright, or other notices
27
+ of the licensor in the software. Any use of the licensor’s trademarks is subject
28
+ to applicable law.
29
+
30
+ ## Patents
31
+
32
+ The licensor grants you a license, under any patent claims the licensor can
33
+ license, or becomes able to license, to make, have made, use, sell, offer for
34
+ sale, import and have imported the software, in each case subject to the
35
+ limitations and conditions in this license. This license does not cover any
36
+ patent claims that you cause to be infringed by modifications or additions to
37
+ the software. If you or your company make any written claim that the software
38
+ infringes or contributes to infringement of any patent, your patent license for
39
+ the software granted under these terms ends immediately. If your company makes
40
+ such a claim, your patent license ends immediately for work on behalf of your
41
+ company.
42
+
43
+ ## Notices
44
+
45
+ You must ensure that anyone who gets a copy of any part of the software from you
46
+ also gets a copy of these terms.
47
+
48
+ If you modify the software, you must include in any modified copies of the
49
+ software prominent notices stating that you have modified the software.
50
+
51
+ ## No Other Rights
52
+
53
+ These terms do not imply any licenses other than those expressly granted in
54
+ these terms.
55
+
56
+ ## Termination
57
+
58
+ If you use the software in violation of these terms, such use is not licensed,
59
+ and your licenses will automatically terminate. If the licensor provides you
60
+ with a notice of your violation, and you cease all violation of this license no
61
+ later than 30 days after you receive that notice, your licenses will be
62
+ reinstated retroactively. However, if you violate these terms after such
63
+ reinstatement, any additional violation of these terms will cause your licenses
64
+ to terminate automatically and permanently.
65
+
66
+ ## No Liability
67
+
68
+ *As far as the law allows, the software comes as is, without any warranty or
69
+ condition, and the licensor will not be liable to you for any damages arising
70
+ out of these terms or the use or nature of the software, under any kind of
71
+ legal claim.*
72
+
73
+ ## Definitions
74
+
75
+ The **licensor** is the entity offering these terms, and the **software** is the
76
+ software the licensor makes available under these terms, including any portion
77
+ of it.
78
+
79
+ **you** refers to the individual or entity agreeing to these terms.
80
+
81
+ **your company** is any legal entity, sole proprietorship, or other kind of
82
+ organization that you work for, plus all organizations that have control over,
83
+ are under the control of, or are under common control with that
84
+ organization. **control** means ownership of substantially all the assets of an
85
+ entity, or the power to direct its management and policies by vote, contract, or
86
+ otherwise. Control can be direct or indirect.
87
+
88
+ **your licenses** are all the licenses granted to you for the software under
89
+ these terms.
90
+
91
+ **use** means anything you do with the software requiring one of your licenses.
92
+
93
+ **trademark** means trademarks, service marks, and similar rights.
airmux-0.1.2/PKG-INFO ADDED
@@ -0,0 +1,220 @@
1
+ Metadata-Version: 2.5
2
+ Name: airmux
3
+ Version: 0.1.2
4
+ Summary: Self-hosted LLM gateway and management CLI
5
+ Project-URL: Documentation, https://github.com/michel-tricot/airmux/tree/main/docs
6
+ Project-URL: Repository, https://github.com/michel-tricot/airmux
7
+ Project-URL: Issues, https://github.com/michel-tricot/airmux/issues
8
+ License-Expression: Elastic-2.0
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.13
11
+ Requires-Dist: alembic
12
+ Requires-Dist: anyio
13
+ Requires-Dist: argon2-cffi>=23.1
14
+ Requires-Dist: asyncpg
15
+ Requires-Dist: fastapi
16
+ Requires-Dist: httpx[http2]
17
+ Requires-Dist: pydantic>=2
18
+ Requires-Dist: python-dotenv
19
+ Requires-Dist: pyyaml
20
+ Requires-Dist: rich
21
+ Requires-Dist: sqlalchemy[asyncio]>=2
22
+ Requires-Dist: sqlmodel
23
+ Requires-Dist: starlette
24
+ Requires-Dist: tiktoken
25
+ Requires-Dist: tomli-w>=1.2.0
26
+ Requires-Dist: typer
27
+ Requires-Dist: uvicorn[standard]
28
+ Description-Content-Type: text/markdown
29
+
30
+ <div align="center">
31
+ <h1>airmux</h1>
32
+ <p><strong>One self-hosted LLM gateway. Any compatible client. Multiple providers.</strong></p>
33
+ <p>
34
+ Connect through a supported inference API while airmux centralizes provider translation, routing, policy,
35
+ credentials, failover, and usage accounting behind one endpoint.
36
+ </p>
37
+ <p>
38
+ <a href="https://github.com/michel-tricot/airmux/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/michel-tricot/airmux/actions/workflows/ci.yml/badge.svg"></a>
39
+ <a href="https://pypi.org/project/airmux/"><img alt="PyPI" src="https://img.shields.io/pypi/v/airmux?logo=pypi&logoColor=white"></a>
40
+ <a href="https://www.python.org/downloads/"><img alt="Python 3.13+" src="https://img.shields.io/badge/python-3.13%2B-3776AB?logo=python&logoColor=white"></a>
41
+ <a href="LICENSE"><img alt="Elastic License 2.0" src="https://img.shields.io/badge/license-Elastic--2.0-4C1?logo=elastic&logoColor=white"></a>
42
+ </p>
43
+ <p>
44
+ <a href="#quickstart">Quickstart</a> ·
45
+ <a href="docs/index.mdx">Documentation</a> ·
46
+ <a href="CONTRIBUTING.md">Contributing</a> ·
47
+ <a href="https://github.com/michel-tricot/airmux/issues/new">Report a bug</a>
48
+ </p>
49
+ </div>
50
+
51
+ airmux gives applications, agents, CLIs, and services one self-hosted origin for calling multiple provider families.
52
+ Clients can send Chat Completions, Responses, or Messages requests through any SDK or integration that can
53
+ target the corresponding HTTP API. airmux authenticates the workspace, applies policy, selects a model and scoped
54
+ provider credential, translates the request, and records the result.
55
+
56
+ > [!NOTE]
57
+ > airmux is pre-1.0. Configuration, APIs, and migrations may change before the first stable release.
58
+
59
+ ## Quickstart
60
+
61
+ Run a local gateway with no Docker, Postgres, or control plane. You need Python 3.13+, [uv](https://docs.astral.sh/uv/),
62
+ and an OpenAI API key.
63
+
64
+ ### 1. Install and start the gateway
65
+
66
+ ```bash
67
+ uv tool install airmux
68
+ mkdir airmux-demo
69
+ cd airmux-demo
70
+ export OPENAI_API_KEY='your-provider-key'
71
+ airmux gateway init
72
+ airmux gateway serve
73
+ ```
74
+
75
+ `init` creates a local configuration, a model taxonomy, and a private inference key under `.airmux/`. The gateway
76
+ reads provider credentials from the environment and reloads taxonomy edits while it runs.
77
+
78
+ ### 2. Make a real model request
79
+
80
+ In another terminal:
81
+
82
+ ```bash
83
+ cd airmux-demo
84
+ export AIRMUX_INFERENCE_KEY="$(cat .airmux/inference.key)"
85
+ curl --fail-with-body http://127.0.0.1:8080/inf/v1/chat/completions \
86
+ -H "Authorization: Bearer $AIRMUX_INFERENCE_KEY" \
87
+ -H 'Content-Type: application/json' \
88
+ -d '{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Say hello in one word."}],"max_completion_tokens":16}'
89
+ ```
90
+
91
+ The same gateway accepts streaming requests, tool calls, structured output, reasoning, images, and PDF inputs when the
92
+ selected model supports them. Continue with the [gateway-only guide](docs/deployment/gateway.mdx) for configuration and
93
+ operation.
94
+
95
+ ## Use your existing client
96
+
97
+ Any client that can target one of airmux's exposed HTTP APIs and send an inference key through
98
+ `Authorization: Bearer` or `x-api-key` can connect. That includes SDKs,
99
+ agent frameworks, CLIs, services, and raw HTTP integrations.
100
+
101
+ | API | Endpoint |
102
+ | --- | --- |
103
+ | Chat Completions | `POST /inf/v1/chat/completions` |
104
+ | Responses | `POST /inf/v1/responses` |
105
+ | Messages | `POST /inf/v1/messages` |
106
+ | Model discovery | `GET /inf/v1/models` and `GET /inf/v1/models/{model_id}` |
107
+
108
+ The OpenAI SDK is one example. Point it at `/inf/v1` and replace the upstream key with an airmux inference key:
109
+
110
+ ```python
111
+ import os
112
+
113
+ from openai import OpenAI
114
+
115
+ client = OpenAI(
116
+ base_url="http://127.0.0.1:8080/inf/v1",
117
+ api_key=os.environ["AIRMUX_INFERENCE_KEY"],
118
+ )
119
+
120
+ response = client.chat.completions.create(
121
+ model="openai/gpt-4o-mini",
122
+ messages=[{"role": "user", "content": "Why use an LLM gateway?"}],
123
+ )
124
+
125
+ print(response.choices[0].message.content)
126
+ ```
127
+
128
+ The client protocol does not constrain the provider route. A Messages request can target an OpenAI-compatible model,
129
+ and a Chat Completions request can target an Anthropic model. airmux translates the request and returns the response
130
+ and errors in the caller's dialect. See the [OpenAI SDK](docs/guides/openai-sdk.mdx) and
131
+ [Anthropic SDK](docs/guides/anthropic-sdk.mdx) guides for complete examples, including streaming.
132
+
133
+ ## Why airmux
134
+
135
+ - **Protocol-first clients:** connect any SDK, agent framework, CLI, service, or raw HTTP integration that speaks an exposed API
136
+ - **Policy at the gateway:** compose model and provider allowlists, price ceilings, request limits, credential rules, denials, strict parameters, and fallbacks
137
+ - **Scoped provider secrets:** separate instance, organization, and workspace credentials without exposing secret values to configuration bundles
138
+ - **Predictable failover:** retry eligible credentials and route to bounded backup models without escaping workspace policy
139
+ - **Complete request records:** capture tokens, cost, latency, status, credential scope, configuration version, and every fallback attempt
140
+ - **A resilient request path:** gateways evaluate immutable local bundles and can keep serving through a control-plane outage
141
+
142
+ The shipped catalog includes Anthropic, Cerebras, DeepSeek, Fireworks, Groq, Mistral, OpenAI, Together, and xAI. Model
143
+ IDs, prices, context windows, modalities, capabilities, and parameter support are explicit, inspectable data in the
144
+ [taxonomy](taxonomy/taxonomy.yml).
145
+
146
+ ## Full-platform quickstart
147
+
148
+ Use the complete stack when you want the web console, organizations and workspaces, managed credentials, live policy,
149
+ usage history, and audit activity. You need Docker with Compose 2.24.4+, Python 3.13+, uv, and at least one provider API
150
+ key.
151
+
152
+ ```bash
153
+ git clone https://github.com/michel-tricot/airmux.git
154
+ cd airmux
155
+ cp .env.example .env
156
+ ```
157
+
158
+ Add a provider key such as `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` to `.env`, then run:
159
+
160
+ ```bash
161
+ uv tool install airmux
162
+ docker compose up -d --build --wait
163
+ airmux quickstart --url http://localhost:8080
164
+ ```
165
+
166
+ `quickstart` creates or resumes the owner account, organization, and workspace; imports missing provider credentials;
167
+ mints an inference key; and proves the installation with a real model request. Open
168
+ [localhost:8080](http://localhost:8080) for the console.
169
+
170
+ | Goal | Command |
171
+ | --- | --- |
172
+ | List catalog models | `airmux models list` |
173
+ | Inspect the installation | `airmux doctor` |
174
+ | Follow gateway activity | `airmux events tail --interval 2 --keep 30` |
175
+ | Follow service logs | `docker compose logs -f airmux` |
176
+ | Stop while preserving state | `docker compose down` |
177
+
178
+ ## Architecture
179
+
180
+ airmux separates mutable management work from the inference request path.
181
+
182
+ ```mermaid
183
+ flowchart LR
184
+ A[Application] -->|Inference key| G[Data plane]
185
+ U[Operator] --> C[Console or CLI]
186
+ C --> M[Control plane]
187
+ M --> P[(Postgres)]
188
+ M --> S[(Secret store)]
189
+ M -->|Versioned bundles| G
190
+ G -->|Cold secret resolution| S
191
+ G -->|Provider request| L[LLM provider]
192
+ G -->|Usage and health| M
193
+ ```
194
+
195
+ Caller dialects and provider protocols cross through one canonical model. Adding a caller dialect requires one ingress
196
+ adapter; adding a provider family requires one egress adapter. Policy, routing, streaming, and metering stay
197
+ provider-neutral instead of multiplying into a translator for every caller and provider pair.
198
+
199
+ The control plane compiles complete, versioned organization bundles. Data-plane workers validate them, build immutable
200
+ indexes, and atomically adopt them. Inference therefore avoids management database reads and an in-flight request never
201
+ observes partially updated policy. Cold provider-secret resolution is the only database-capable exception, and secret
202
+ values never enter a bundle.
203
+
204
+ Read the [architecture guide](docs/concepts/architecture.mdx) for the full data flow, failure boundaries, and deployment
205
+ shapes.
206
+
207
+ ## Documentation
208
+
209
+ | I want to... | Start here |
210
+ | --- | --- |
211
+ | Try the complete stack | [Quickstart](docs/quickstart.mdx) |
212
+ | Connect an application | [OpenAI SDK](docs/guides/openai-sdk.mdx) or [Anthropic SDK](docs/guides/anthropic-sdk.mdx) |
213
+ | Add routing and access rules | [Policy workflow](docs/guides/policy-workflow.mdx) |
214
+ | Understand supported inference shapes | [Inference reference](docs/reference/inference.mdx) |
215
+ | Deploy airmux | [Deployment overview](docs/deployment/index.mdx) |
216
+ | Upgrade or roll back a deployment | [Upgrade and rollback](docs/deployment/upgrades.mdx) |
217
+ | Call the management API | [Management API](docs/reference/management-api.mdx) |
218
+ | Work on the project | [Contributing](CONTRIBUTING.md) and [Development guide](docs/development.mdx) |
219
+
220
+ The complete management API is generated from [`lib/api-spec/openapi.yaml`](lib/api-spec/openapi.yaml).
airmux-0.1.2/README.md ADDED
@@ -0,0 +1,191 @@
1
+ <div align="center">
2
+ <h1>airmux</h1>
3
+ <p><strong>One self-hosted LLM gateway. Any compatible client. Multiple providers.</strong></p>
4
+ <p>
5
+ Connect through a supported inference API while airmux centralizes provider translation, routing, policy,
6
+ credentials, failover, and usage accounting behind one endpoint.
7
+ </p>
8
+ <p>
9
+ <a href="https://github.com/michel-tricot/airmux/actions/workflows/ci.yml"><img alt="CI" src="https://github.com/michel-tricot/airmux/actions/workflows/ci.yml/badge.svg"></a>
10
+ <a href="https://pypi.org/project/airmux/"><img alt="PyPI" src="https://img.shields.io/pypi/v/airmux?logo=pypi&logoColor=white"></a>
11
+ <a href="https://www.python.org/downloads/"><img alt="Python 3.13+" src="https://img.shields.io/badge/python-3.13%2B-3776AB?logo=python&logoColor=white"></a>
12
+ <a href="LICENSE"><img alt="Elastic License 2.0" src="https://img.shields.io/badge/license-Elastic--2.0-4C1?logo=elastic&logoColor=white"></a>
13
+ </p>
14
+ <p>
15
+ <a href="#quickstart">Quickstart</a> ·
16
+ <a href="docs/index.mdx">Documentation</a> ·
17
+ <a href="CONTRIBUTING.md">Contributing</a> ·
18
+ <a href="https://github.com/michel-tricot/airmux/issues/new">Report a bug</a>
19
+ </p>
20
+ </div>
21
+
22
+ airmux gives applications, agents, CLIs, and services one self-hosted origin for calling multiple provider families.
23
+ Clients can send Chat Completions, Responses, or Messages requests through any SDK or integration that can
24
+ target the corresponding HTTP API. airmux authenticates the workspace, applies policy, selects a model and scoped
25
+ provider credential, translates the request, and records the result.
26
+
27
+ > [!NOTE]
28
+ > airmux is pre-1.0. Configuration, APIs, and migrations may change before the first stable release.
29
+
30
+ ## Quickstart
31
+
32
+ Run a local gateway with no Docker, Postgres, or control plane. You need Python 3.13+, [uv](https://docs.astral.sh/uv/),
33
+ and an OpenAI API key.
34
+
35
+ ### 1. Install and start the gateway
36
+
37
+ ```bash
38
+ uv tool install airmux
39
+ mkdir airmux-demo
40
+ cd airmux-demo
41
+ export OPENAI_API_KEY='your-provider-key'
42
+ airmux gateway init
43
+ airmux gateway serve
44
+ ```
45
+
46
+ `init` creates a local configuration, a model taxonomy, and a private inference key under `.airmux/`. The gateway
47
+ reads provider credentials from the environment and reloads taxonomy edits while it runs.
48
+
49
+ ### 2. Make a real model request
50
+
51
+ In another terminal:
52
+
53
+ ```bash
54
+ cd airmux-demo
55
+ export AIRMUX_INFERENCE_KEY="$(cat .airmux/inference.key)"
56
+ curl --fail-with-body http://127.0.0.1:8080/inf/v1/chat/completions \
57
+ -H "Authorization: Bearer $AIRMUX_INFERENCE_KEY" \
58
+ -H 'Content-Type: application/json' \
59
+ -d '{"model":"openai/gpt-4o-mini","messages":[{"role":"user","content":"Say hello in one word."}],"max_completion_tokens":16}'
60
+ ```
61
+
62
+ The same gateway accepts streaming requests, tool calls, structured output, reasoning, images, and PDF inputs when the
63
+ selected model supports them. Continue with the [gateway-only guide](docs/deployment/gateway.mdx) for configuration and
64
+ operation.
65
+
66
+ ## Use your existing client
67
+
68
+ Any client that can target one of airmux's exposed HTTP APIs and send an inference key through
69
+ `Authorization: Bearer` or `x-api-key` can connect. That includes SDKs,
70
+ agent frameworks, CLIs, services, and raw HTTP integrations.
71
+
72
+ | API | Endpoint |
73
+ | --- | --- |
74
+ | Chat Completions | `POST /inf/v1/chat/completions` |
75
+ | Responses | `POST /inf/v1/responses` |
76
+ | Messages | `POST /inf/v1/messages` |
77
+ | Model discovery | `GET /inf/v1/models` and `GET /inf/v1/models/{model_id}` |
78
+
79
+ The OpenAI SDK is one example. Point it at `/inf/v1` and replace the upstream key with an airmux inference key:
80
+
81
+ ```python
82
+ import os
83
+
84
+ from openai import OpenAI
85
+
86
+ client = OpenAI(
87
+ base_url="http://127.0.0.1:8080/inf/v1",
88
+ api_key=os.environ["AIRMUX_INFERENCE_KEY"],
89
+ )
90
+
91
+ response = client.chat.completions.create(
92
+ model="openai/gpt-4o-mini",
93
+ messages=[{"role": "user", "content": "Why use an LLM gateway?"}],
94
+ )
95
+
96
+ print(response.choices[0].message.content)
97
+ ```
98
+
99
+ The client protocol does not constrain the provider route. A Messages request can target an OpenAI-compatible model,
100
+ and a Chat Completions request can target an Anthropic model. airmux translates the request and returns the response
101
+ and errors in the caller's dialect. See the [OpenAI SDK](docs/guides/openai-sdk.mdx) and
102
+ [Anthropic SDK](docs/guides/anthropic-sdk.mdx) guides for complete examples, including streaming.
103
+
104
+ ## Why airmux
105
+
106
+ - **Protocol-first clients:** connect any SDK, agent framework, CLI, service, or raw HTTP integration that speaks an exposed API
107
+ - **Policy at the gateway:** compose model and provider allowlists, price ceilings, request limits, credential rules, denials, strict parameters, and fallbacks
108
+ - **Scoped provider secrets:** separate instance, organization, and workspace credentials without exposing secret values to configuration bundles
109
+ - **Predictable failover:** retry eligible credentials and route to bounded backup models without escaping workspace policy
110
+ - **Complete request records:** capture tokens, cost, latency, status, credential scope, configuration version, and every fallback attempt
111
+ - **A resilient request path:** gateways evaluate immutable local bundles and can keep serving through a control-plane outage
112
+
113
+ The shipped catalog includes Anthropic, Cerebras, DeepSeek, Fireworks, Groq, Mistral, OpenAI, Together, and xAI. Model
114
+ IDs, prices, context windows, modalities, capabilities, and parameter support are explicit, inspectable data in the
115
+ [taxonomy](taxonomy/taxonomy.yml).
116
+
117
+ ## Full-platform quickstart
118
+
119
+ Use the complete stack when you want the web console, organizations and workspaces, managed credentials, live policy,
120
+ usage history, and audit activity. You need Docker with Compose 2.24.4+, Python 3.13+, uv, and at least one provider API
121
+ key.
122
+
123
+ ```bash
124
+ git clone https://github.com/michel-tricot/airmux.git
125
+ cd airmux
126
+ cp .env.example .env
127
+ ```
128
+
129
+ Add a provider key such as `OPENAI_API_KEY` or `ANTHROPIC_API_KEY` to `.env`, then run:
130
+
131
+ ```bash
132
+ uv tool install airmux
133
+ docker compose up -d --build --wait
134
+ airmux quickstart --url http://localhost:8080
135
+ ```
136
+
137
+ `quickstart` creates or resumes the owner account, organization, and workspace; imports missing provider credentials;
138
+ mints an inference key; and proves the installation with a real model request. Open
139
+ [localhost:8080](http://localhost:8080) for the console.
140
+
141
+ | Goal | Command |
142
+ | --- | --- |
143
+ | List catalog models | `airmux models list` |
144
+ | Inspect the installation | `airmux doctor` |
145
+ | Follow gateway activity | `airmux events tail --interval 2 --keep 30` |
146
+ | Follow service logs | `docker compose logs -f airmux` |
147
+ | Stop while preserving state | `docker compose down` |
148
+
149
+ ## Architecture
150
+
151
+ airmux separates mutable management work from the inference request path.
152
+
153
+ ```mermaid
154
+ flowchart LR
155
+ A[Application] -->|Inference key| G[Data plane]
156
+ U[Operator] --> C[Console or CLI]
157
+ C --> M[Control plane]
158
+ M --> P[(Postgres)]
159
+ M --> S[(Secret store)]
160
+ M -->|Versioned bundles| G
161
+ G -->|Cold secret resolution| S
162
+ G -->|Provider request| L[LLM provider]
163
+ G -->|Usage and health| M
164
+ ```
165
+
166
+ Caller dialects and provider protocols cross through one canonical model. Adding a caller dialect requires one ingress
167
+ adapter; adding a provider family requires one egress adapter. Policy, routing, streaming, and metering stay
168
+ provider-neutral instead of multiplying into a translator for every caller and provider pair.
169
+
170
+ The control plane compiles complete, versioned organization bundles. Data-plane workers validate them, build immutable
171
+ indexes, and atomically adopt them. Inference therefore avoids management database reads and an in-flight request never
172
+ observes partially updated policy. Cold provider-secret resolution is the only database-capable exception, and secret
173
+ values never enter a bundle.
174
+
175
+ Read the [architecture guide](docs/concepts/architecture.mdx) for the full data flow, failure boundaries, and deployment
176
+ shapes.
177
+
178
+ ## Documentation
179
+
180
+ | I want to... | Start here |
181
+ | --- | --- |
182
+ | Try the complete stack | [Quickstart](docs/quickstart.mdx) |
183
+ | Connect an application | [OpenAI SDK](docs/guides/openai-sdk.mdx) or [Anthropic SDK](docs/guides/anthropic-sdk.mdx) |
184
+ | Add routing and access rules | [Policy workflow](docs/guides/policy-workflow.mdx) |
185
+ | Understand supported inference shapes | [Inference reference](docs/reference/inference.mdx) |
186
+ | Deploy airmux | [Deployment overview](docs/deployment/index.mdx) |
187
+ | Upgrade or roll back a deployment | [Upgrade and rollback](docs/deployment/upgrades.mdx) |
188
+ | Call the management API | [Management API](docs/reference/management-api.mdx) |
189
+ | Work on the project | [Contributing](CONTRIBUTING.md) and [Development guide](docs/development.mdx) |
190
+
191
+ The complete management API is generated from [`lib/api-spec/openapi.yaml`](lib/api-spec/openapi.yaml).
@@ -0,0 +1,48 @@
1
+ [project]
2
+ name = "airmux"
3
+ version = "0.1.2"
4
+ description = "Self-hosted LLM gateway and management CLI"
5
+ readme = "README.md"
6
+ license = "Elastic-2.0"
7
+ requires-python = ">=3.13"
8
+ dependencies = [
9
+ "alembic",
10
+ "anyio",
11
+ "argon2-cffi>=23.1",
12
+ "asyncpg",
13
+ "fastapi",
14
+ "httpx[http2]",
15
+ "pydantic>=2",
16
+ "python-dotenv",
17
+ "pyyaml",
18
+ "rich",
19
+ "sqlalchemy[asyncio]>=2",
20
+ "sqlmodel",
21
+ "starlette",
22
+ "tiktoken",
23
+ "tomli-w>=1.2.0",
24
+ "typer",
25
+ "uvicorn[standard]",
26
+ ]
27
+
28
+ [project.urls]
29
+ Documentation = "https://github.com/michel-tricot/airmux/tree/main/docs"
30
+ Repository = "https://github.com/michel-tricot/airmux"
31
+ Issues = "https://github.com/michel-tricot/airmux/issues"
32
+
33
+ [project.scripts]
34
+ airmux = "cli.main:main"
35
+
36
+ [build-system]
37
+ requires = ["hatchling"]
38
+ build-backend = "hatchling.build"
39
+
40
+ [tool.hatch.build.targets.wheel]
41
+ packages = [
42
+ "src/api_models",
43
+ "src/airmux_runtime",
44
+ "src/cli",
45
+ "src/contract",
46
+ "src/control_plane",
47
+ "src/data_plane",
48
+ ]
@@ -0,0 +1 @@
1
+ from __future__ import annotations
@@ -0,0 +1,98 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import re
5
+ from dataclasses import dataclass
6
+ from pathlib import Path
7
+ from typing import Annotated
8
+
9
+ import yaml
10
+ from pydantic import AfterValidator, Field, ValidationInfo
11
+
12
+ _REFERENCE = re.compile(r"^\$\{(env|file):(.+)\}$")
13
+ _DEFAULT_SEPARATOR = ":-"
14
+
15
+
16
+ class UnsupportedRefSchemeError(ValueError):
17
+ def __init__(self, scheme: str) -> None:
18
+ super().__init__(f"unsupported configuration reference scheme: {scheme}")
19
+
20
+
21
+ class MissingConfigReferenceError(ValueError):
22
+ def __init__(self, scheme: str, target: str) -> None:
23
+ super().__init__(f"configuration references missing {scheme} value: {target}")
24
+
25
+
26
+ class InvalidConfigReferenceError(ValueError):
27
+ def __init__(self) -> None:
28
+ super().__init__("configuration references must occupy the whole YAML value and use the env or file scheme")
29
+
30
+
31
+ @dataclass(frozen=True)
32
+ class ConfigContext:
33
+ base_dir: Path
34
+
35
+
36
+ def _resolve_path(path: Path, info: ValidationInfo) -> Path:
37
+ if isinstance(info.context, ConfigContext):
38
+ return info.context.base_dir / path
39
+ return path
40
+
41
+
42
+ ConfigPath = Annotated[Path, AfterValidator(_resolve_path), Field(validate_default=True)]
43
+
44
+
45
+ def load_yaml(path: Path) -> object:
46
+ return yaml.safe_load(path.read_text(encoding="utf-8")) or {}
47
+
48
+
49
+ def _split_default(value: str) -> tuple[str, str | None]:
50
+ target, separator, fallback = value.partition(_DEFAULT_SEPARATOR)
51
+ return (target, fallback) if separator else (target, None)
52
+
53
+
54
+ def resolve_ref(ref: str, *, base_dir: Path = Path()) -> str:
55
+ scheme, separator, value = ref.partition(":")
56
+ if not separator or scheme not in {"env", "file"}:
57
+ raise UnsupportedRefSchemeError(scheme)
58
+ target, fallback = _split_default(value)
59
+ if scheme == "env":
60
+ resolved = os.environ.get(target, fallback)
61
+ else:
62
+ source = base_dir / target
63
+ resolved = source.read_text(encoding="utf-8").strip() if source.is_file() else fallback
64
+ if resolved is None:
65
+ raise MissingConfigReferenceError(scheme, target)
66
+ return resolved
67
+
68
+
69
+ def resolve_refs(node: object, *, base_dir: Path = Path()) -> object:
70
+ if isinstance(node, dict):
71
+ return {key: resolve_refs(value, base_dir=base_dir) for key, value in node.items()}
72
+ if isinstance(node, list):
73
+ return [resolve_refs(value, base_dir=base_dir) for value in node]
74
+ if isinstance(node, str):
75
+ if match := _REFERENCE.fullmatch(node):
76
+ return resolve_ref(f"{match.group(1)}:{match.group(2)}", base_dir=base_dir)
77
+ if "${" in node:
78
+ raise InvalidConfigReferenceError
79
+ return node
80
+
81
+
82
+ def load_config_section(name: str, config_path: str | Path) -> dict[str, object]:
83
+ path = Path(config_path)
84
+ if not path.is_file():
85
+ raise FileNotFoundError(path)
86
+ document = load_yaml(path)
87
+ if not isinstance(document, dict):
88
+ message = f"{path} must contain a {name} section"
89
+ raise TypeError(message)
90
+ declared = document.get(name)
91
+ if not isinstance(declared, dict):
92
+ message = f"{path} must contain a {name} section"
93
+ raise TypeError(message)
94
+ section = resolve_refs(declared, base_dir=path.parent)
95
+ if not isinstance(section, dict):
96
+ message = f"{path} must contain a {name} mapping"
97
+ raise TypeError(message)
98
+ return {str(key): value for key, value in section.items()}