Commit c57cb5e
Auto generated client (#3)
* Add generated control-plane client (preview)
Generated control-plane client (keys, users, budgets, pricing, usage) from
the otari gateway OpenAPI spec via OpenAPI Generator. Preview for review and
integration design; not yet wired into the public client.
Part of mozilla-ai/otari#96
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add control-plane integration tests (generated client)
Full CRUD lifecycle tests for every control-plane endpoint (keys, users,
budgets, pricing, usage) driving the generated client against a real gateway
started on SQLite with a master key (no provider creds needed). Verified
22 endpoint operations pass; documents the Bearer-auth requirement and the
per-language test pattern.
Part of mozilla-ai/otari#96
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Wire generated control-plane client into OtariClient
- Regenerate the control-plane client as a clean subpackage (otari._control_plane).
- Add OtariClient.control_plane: typed accessors (keys/users/budgets/pricing/usage)
sharing one client authed with Authorization: Bearer using an admin credential
(admin_key / GATEWAY_ADMIN_KEY / platform_token). Management endpoints require
Bearer, not the Otari-Key inference header.
- Add admin_key param + ControlPlane facade; export ControlPlane.
- Exclude the generated subpackage from ruff/mypy; add its runtime deps.
- Integration tests now drive the public control_plane surface end-to-end
(full CRUD per endpoint + admin-credential guard); 6 pass against a live
gateway on SQLite.
Part of mozilla-ai/otari#96
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add PR CI and make control-plane integration tests skip without a gateway
- Add .github/workflows/ci.yml: ruff + mypy + pytest on push/PR across
Python 3.11-3.13 (the repo previously only ran checks on release).
- Integration tests skip cleanly when no gateway is on PATH (set
OTARI_GATEWAY_CMD to run them), so CI is green without a gateway and
passes with one.
- Register the 'integration' marker; per-file-ignore the subprocess/URL
audit rules for the test harness.
Part of mozilla-ai/otari#96
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Option C: rebuild SDK as a thin shell over the generated typed core
Replace the OpenAI-SDK delegation with a hand-written shell over the
OpenAPI-generated core (otari._client), generated from the otari spec.
The gateway is only OpenAI-compatible and has endpoints (notably the
Anthropic-shaped /messages) the OpenAI SDK cannot represent; generating
from the otari spec models the real contract.
Core (unmodified generator output) replaces the old _control_plane
subpackage and covers every endpoint with typed request/response models.
Shell (the real work):
- Auth modes preserved: platform -> Authorization: Bearer <token>;
non-platform -> Otari-Key: Bearer <key>; control-plane -> Authorization:
Bearer <admin/master key>. Fed into the generated ApiClient default
headers and the streaming shim's httpx requests.
- Ergonomic methods keep the existing public names/signatures
(completion/response/embedding/moderation/rerank/list_models/batches)
and add message(...) for the previously-missing /messages endpoint.
control_plane accessor now backed by _client.
- SSE streaming shim (_streaming.py): the generated core buffers and
cannot stream, so stream=True does a raw httpx streaming POST, parses
text/event-stream framing, terminates on [DONE], and yields typed
ChatCompletionChunk (chat) / parsed JSON (responses, messages).
- Typed error mapping: generated ApiException (.status/.body) -> the
errors.py hierarchy (Authentication 401/403, InsufficientFunds 402,
ModelNotFound 404, BatchNotComplete 409, RateLimit 429, GatewayTimeout
504, UpstreamProvider 502/5xx, UnsupportedCapability cross-mode, generic
OtariError). The streaming path adapts failed responses through the same
mapper.
- Async client wraps the sync generated core via asyncio.to_thread and
streams natively over httpx.AsyncClient.
Drop the openai dependency from inference. Update ruff/mypy excludes to
src/otari/_client. Rewrite unit tests to mock the generated transport
(RESTClientObject.request) and respx for SSE; control-plane integration
tests updated to import from _client and verified green against a live
gateway.
Note: chat streaming cannot be live-verified in this sandbox (no provider
key on the gateway); the SSE shim is unit-tested over mocked chunk bytes.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* Add endpoint-coverage drift gate
Fail CI when the gateway OpenAPI spec exposes an endpoint the SDK's public
API does not account for. A checked-in manifest (sdk-endpoints.txt) pins the
covered and intentionally-excluded endpoint sets; a pytest test fetches the
canonical spec and asserts spec is a subset of (covered + excluded), naming
any unaccounted endpoint. Wired as a dedicated CI step.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 2a76998 commit c57cb5e
203 files changed
Lines changed: 36110 additions & 1984 deletions
File tree
- .github/workflows
- src/otari
- _client
- api
- models
- tests
- integration
- unit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
195 | 195 | | |
196 | 196 | | |
197 | 197 | | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
198 | 213 | | |
199 | 214 | | |
200 | 215 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
26 | 26 | | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
27 | 31 | | |
28 | 32 | | |
29 | 33 | | |
| |||
36 | 40 | | |
37 | 41 | | |
38 | 42 | | |
| 43 | + | |
39 | 44 | | |
40 | 45 | | |
41 | 46 | | |
| |||
46 | 51 | | |
47 | 52 | | |
48 | 53 | | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
49 | 57 | | |
50 | 58 | | |
51 | 59 | | |
52 | 60 | | |
| 61 | + | |
| 62 | + | |
53 | 63 | | |
54 | 64 | | |
55 | 65 | | |
56 | 66 | | |
57 | 67 | | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
58 | 73 | | |
59 | 74 | | |
60 | 75 | | |
| |||
63 | 78 | | |
64 | 79 | | |
65 | 80 | | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| 23 | + | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
35 | | - | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | 42 | | |
44 | 43 | | |
45 | | - | |
46 | 44 | | |
47 | | - | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | | - | |
| 49 | + | |
52 | 50 | | |
53 | 51 | | |
54 | 52 | | |
| |||
59 | 57 | | |
60 | 58 | | |
61 | 59 | | |
62 | | - | |
63 | 60 | | |
64 | 61 | | |
65 | 62 | | |
| |||
68 | 65 | | |
69 | 66 | | |
70 | 67 | | |
71 | | - | |
| 68 | + | |
72 | 69 | | |
73 | 70 | | |
74 | | - | |
75 | 71 | | |
76 | 72 | | |
77 | 73 | | |
78 | | - | |
| 74 | + | |
79 | 75 | | |
| 76 | + | |
| 77 | + | |
80 | 78 | | |
81 | 79 | | |
82 | 80 | | |
83 | 81 | | |
84 | | - | |
85 | | - | |
86 | | - | |
| 82 | + | |
87 | 83 | | |
88 | 84 | | |
89 | 85 | | |
0 commit comments