Repository navigation
Expand file tree
/
Copy pathopenapi.yaml
More file actions
3765 lines (3619 loc) · 150 KB
/
Copy pathopenapi.yaml
File metadata and controls
3765 lines (3619 loc) · 150 KB
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
openapi: 3.1.0
info:
title: Auto Router API
version: 0.10.0
summary: Jev-assisted large-language-model auto-router with provider configuration, named inference keys and usage metrics.
description: |
Auto Router is a Jev-assisted large-language-model automatic router and single-user model gateway
with provider-level upstream credentials, named client inference keys, and ordered fallback groups
(simple, medium and complex). The first owner password
is set once through the local setup endpoint; later access uses a password-backed browser session.
Management APIs use the `auto_router_admin_session` cookie. Inference calls use a named inference
key as `Authorization: Bearer <key>`. Provider secrets are write-only. Groups reference enabled
provider/model pairs, and each group's array order is the fallback order.
OpenAI-compatible ingress is available at `/v1/chat/completions` and `/v1/responses`; native
Anthropic ingress is available at `/v1/messages`, and native Gemini ingress at
`/v1beta/models/{model}:generateContent`. Native Anthropic and Gemini ingress requires the
matching upstream protocol. OpenAI Chat text-only requests can be translated to Anthropic or
Gemini for a limited supported subset; unsupported fields are rejected before upstream delivery.
`GET /admin/v1/logs/summary` reports final client request success rate, token observations and
60-second completed upstream output-token TPS. `GET /admin/v1/logs/stats` can aggregate actual
upstream attempts by model or configured group.
license:
name: MIT
identifier: MIT
servers:
- url: http://127.0.0.1:8080
description: The fixed loopback listener. TLS is expected to be terminated by a reverse proxy in front of it.
tags:
- name: Health
description: Unauthenticated liveness and readiness probes.
- name: Models
description: Read-only catalogue containing the virtual auto-routing model and routable logical models.
- name: Inference
description: OpenAI-compatible and native provider protocols.
- name: Debug
description: Opt-in, loopback-only offline tools. They never call a provider.
- name: Setup
description: First-run owner password setup.
- name: Admin
description: The authenticated management API.
- name: Dashboard
description: Browser page shells and static assets. They contain no deployment data.
security: []
paths:
/healthz:
get:
tags: [Health]
summary: Liveness probe
operationId: getHealthz
description: |
Reports that the process is running. It answers one word and carries no data, which is why
it is permanently unauthenticated.
The `GET` pattern also matches `HEAD`, which returns the same headers and no body.
security: []
responses:
'200':
description: The process is running.
headers:
Cache-Control:
description: Always `no-store`.
schema: {type: string}
content:
application/json:
schema: {$ref: '#/components/schemas/HealthStatus'}
examples:
alive:
value: {status: ok}
/readyz:
get:
tags: [Health]
summary: Readiness probe
operationId: getReadyz
description: |
Performs one bounded database ping. Failure is reported as `503` with `not_ready` and never
exposes a database path, driver error or configuration value.
The `GET` pattern also matches `HEAD`.
security: []
responses:
'200':
description: The database answered within the readiness timeout (default 2s).
headers:
Cache-Control:
description: Always `no-store`.
schema: {type: string}
content:
application/json:
schema: {$ref: '#/components/schemas/HealthStatus'}
examples:
ready:
value: {status: ready}
'503':
description: The database did not answer.
content:
application/json:
schema: {$ref: '#/components/schemas/HealthStatus'}
examples:
notReady:
value: {status: not_ready}
/v1/models:
get:
tags: [Models]
summary: List auto-routing and routable models
operationId: listModels
description: |
Always lists the virtual `auto` model first. It advertises `context_window: 1000000` and
`supports_tools`, `supports_vision` and `supports_reasoning` as true. These are the declared
capabilities of the virtual routing entry, not a guarantee that every configured upstream
has those capabilities or a one-million-token context window; the router still filters
actual candidates against the request and each candidate's declared capability/context.
After `auto`, the response lists enabled logical models that currently have at least one
routable binding, in registry order (model ID ascending).
A logical model without an enabled pair is not advertised. `created` is deliberately absent:
the registry has no creation timestamps and inventing one would be a fabricated fact. `data`
is always an array, so an empty registry still contains `auto` rather than a null catalogue.
security:
- inferenceKey: []
responses:
'200':
description: The current catalogue.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
Cache-Control:
description: Always `no-store`.
schema: {type: string}
content:
application/json:
schema: {$ref: '#/components/schemas/ModelList'}
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
head:
tags: [Models]
summary: Head-check the model catalogue
operationId: headModels
description: Identical status and headers to `GET /v1/models`, with no response body.
security:
- inferenceKey: []
responses:
'200':
description: The catalogue exists and is readable.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
/v1/chat/completions:
post:
tags: [Inference]
summary: Forward a Chat Completions request
operationId: postChatCompletions
description: |
Resolves the client's `model` to exactly one provider/model binding, replaces the top-level
`model` with that binding's provider-native `upstream_model_id`, and forwards the request to
the selected provider's `<base_url>/v1/chat/completions`. Nothing else in the body is
interpreted: prompt, tools, reasoning, usage and unknown fields are preserved.
Model resolution order is fixed and has no heuristics:
1. `auto` — automatic routing. The policy engine chooses the pair from the eligible
candidates; the analyzer and the configured Jev recommender contribute.
2. Anything else — a logical model ID, resolved to the first routable binding in the
documented ordering contract (`provider.priority`, `provider.key`, `model.id` ascending).
Responses are relayed transparently: the status line, end-to-end headers and body all come
from the provider, streamed in 16 KiB chunks with a flush after every write when the client
asked for `stream: true`. A provider error body is passed through byte-for-byte rather than
being reshaped into the envelope below; only failures generated by this process use it.
Check order is fixed: an unconfigured executor (`503`) precedes the body read, then media
type (`415`) and size (`413`), then model
parsing (`400`/`403`/`404`), then routing (`422`/`500`/`503` for `auto`), then upstream
failures (`502`/`504`).
security:
- inferenceKey: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ChatCompletionsRequest'}
responses:
'200':
$ref: '#/components/responses/UpstreamResponse'
'400':
$ref: '#/components/responses/OpenAIError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
$ref: '#/components/responses/OpenAIError'
'405':
$ref: '#/components/responses/MethodNotAllowed'
'413':
$ref: '#/components/responses/OpenAIError'
'415':
$ref: '#/components/responses/OpenAIError'
'422':
$ref: '#/components/responses/OpenAIError'
'500':
$ref: '#/components/responses/OpenAIError'
'502':
$ref: '#/components/responses/OpenAIError'
'503':
$ref: '#/components/responses/OpenAIError'
'504':
$ref: '#/components/responses/OpenAIError'
/v1/responses:
post:
tags: [Inference]
summary: Forward a Responses API request
operationId: postResponses
description: |
Uses the Responses protocol at the selected provider's `<base_url>/v1/responses`; the
request body is otherwise forwarded as received apart from the selected upstream model ID.
A `base_url` that already ends in `/v1` is not given a second `/v1` prefix.
security:
- inferenceKey: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ResponsesRequest'}
responses:
'200':
$ref: '#/components/responses/UpstreamResponse'
'400':
$ref: '#/components/responses/OpenAIError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
$ref: '#/components/responses/OpenAIError'
'405':
$ref: '#/components/responses/MethodNotAllowed'
'413':
$ref: '#/components/responses/OpenAIError'
'415':
$ref: '#/components/responses/OpenAIError'
'422':
$ref: '#/components/responses/OpenAIError'
'500':
$ref: '#/components/responses/OpenAIError'
'502':
$ref: '#/components/responses/OpenAIError'
'503':
$ref: '#/components/responses/OpenAIError'
'504':
$ref: '#/components/responses/OpenAIError'
/debug/analyze:
post:
tags: [Debug]
summary: Report the routing features of a request body
operationId: postDebugAnalyze
description: |
Runs the same analyzer the forwarding path uses over a caller-supplied body and returns the
extracted features. It performs exactly one analysis and zero upstream calls, and it never
touches the registry, the database or a provider executor.
It is mounted only when `routing.analyzer_debug_endpoint` is enabled **and** the listener is
loopback; otherwise the path answers `404`. It requires the owner management session.
The response never echoes the request body and never returns an inline payload: an image
reference is reported as the bounded `http(s)` URL it arrived with, or as `[redacted]` for
an inline base64 payload.
Unlike `POST /debug/route`, this handler does not reject unknown fields — a newer protocol
revision must remain analyzable.
security:
- adminSession: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/DebugAnalyzeRequest'}
responses:
'200':
description: The extracted features.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/DebugAnalyzeResponse'}
'400':
$ref: '#/components/responses/OpenAIError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
$ref: '#/components/responses/NotFound'
'405':
$ref: '#/components/responses/OpenAIError'
'413':
$ref: '#/components/responses/OpenAIError'
/debug/route:
post:
tags: [Debug]
summary: Dry-run automatic routing for a request body
operationId: postDebugRoute
description: |
Runs the production automatic router (`model: "auto"`) over the supplied request body and
reports where it would be forwarded, without calling any provider or writing the routing log:
* candidates come from the live registry and model groups, after the same hard filters;
* the task group is chosen exactly as in production. When Jev is enabled and more than one
group has eligible members, **a real Jev call is made** and the request is sent to Jev
under the configured `jev.input_mode`; otherwise the configured default group is used;
* the pair is the first eligible member of the selected group in configured order.
It is mounted only when `routing.policy_debug_endpoint` is enabled **and** the listener is
loopback; otherwise the path answers `404`. It requires the owner management session.
A refused decision (`422`) carries the same explanation shape a successful decision uses
(`decision.excluded`, `decision.excluded_count`, `decision.fallback.reason`). The request body
is never echoed.
security:
- adminSession: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/DebugRouteRequest'}
responses:
'200':
description: The target production would forward to first, the group decision and the features.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/DebugRouteResponse'}
'400':
$ref: '#/components/responses/OpenAIError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
$ref: '#/components/responses/NotFound'
'405':
$ref: '#/components/responses/OpenAIError'
'413':
$ref: '#/components/responses/OpenAIError'
'422':
description: |
The request was well formed but no candidate can serve it
(`no_eligible_candidate`, `truncated_evidence`). The OpenAI envelope carries the refusal,
and the top-level `decision` object repeats the exclusions.
content:
application/json:
schema: {$ref: '#/components/schemas/DebugRouteRefusal'}
'503':
description: Automatic routing is unavailable (`routing_unavailable`), for example no enabled provider/model pair.
content:
application/json:
schema: {$ref: '#/components/schemas/DebugRouteRefusal'}
/v1/messages:
post:
tags: [Inference]
summary: Create an Anthropic Messages response
operationId: createAnthropicMessage
description: Native Anthropic Messages ingress. The selected upstream must support the Anthropic Messages protocol.
security:
- inferenceKey: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [model, max_tokens, messages]
properties:
model: {type: string}
max_tokens: {type: integer, minimum: 1}
messages: {type: array, items: {type: object, additionalProperties: true}}
additionalProperties: true
responses:
'200':
description: Anthropic Messages response.
content:
application/json: {schema: {type: object, additionalProperties: true}}
'400': {$ref: '#/components/responses/OpenAIError'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/InsufficientScope'}
'404': {$ref: '#/components/responses/OpenAIError'}
'405': {$ref: '#/components/responses/MethodNotAllowed'}
'413': {$ref: '#/components/responses/OpenAIError'}
'415': {$ref: '#/components/responses/OpenAIError'}
'422': {$ref: '#/components/responses/OpenAIError'}
'500': {$ref: '#/components/responses/OpenAIError'}
'502': {$ref: '#/components/responses/UpstreamResponse'}
'503': {$ref: '#/components/responses/OpenAIError'}
'504': {$ref: '#/components/responses/OpenAIError'}
/v1beta/models/{model}:generateContent:
post:
tags: [Inference]
summary: Generate Gemini content
operationId: generateGeminiContent
description: Native Gemini ingress. The selected upstream must support the matching Gemini protocol.
security:
- inferenceKey: []
parameters:
- name: model
in: path
required: true
schema: {type: string}
requestBody:
required: true
content:
application/json:
schema: {type: object, additionalProperties: true}
responses:
'200':
description: Gemini content response.
content:
application/json: {schema: {type: object, additionalProperties: true}}
'400': {$ref: '#/components/responses/OpenAIError'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/InsufficientScope'}
'404': {$ref: '#/components/responses/OpenAIError'}
'405': {$ref: '#/components/responses/MethodNotAllowed'}
'413': {$ref: '#/components/responses/OpenAIError'}
'415': {$ref: '#/components/responses/OpenAIError'}
'422': {$ref: '#/components/responses/OpenAIError'}
'500': {$ref: '#/components/responses/OpenAIError'}
'502': {$ref: '#/components/responses/UpstreamResponse'}
'503': {$ref: '#/components/responses/OpenAIError'}
'504': {$ref: '#/components/responses/OpenAIError'}
/v1beta/models/{model}:streamGenerateContent:
post:
tags: [Inference]
summary: Stream Gemini content
operationId: streamGeminiContent
description: Native Gemini streaming ingress. The selected upstream must support the matching Gemini protocol.
security:
- inferenceKey: []
parameters:
- name: model
in: path
required: true
schema: {type: string}
- name: alt
in: query
required: false
schema: {type: string, enum: [sse]}
requestBody:
required: true
content:
application/json:
schema: {type: object, additionalProperties: true}
responses:
'200':
description: Gemini streaming response.
content:
text/event-stream: {schema: {type: string}}
'400': {$ref: '#/components/responses/OpenAIError'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/InsufficientScope'}
'404': {$ref: '#/components/responses/OpenAIError'}
'405': {$ref: '#/components/responses/MethodNotAllowed'}
'413': {$ref: '#/components/responses/OpenAIError'}
'415': {$ref: '#/components/responses/OpenAIError'}
'422': {$ref: '#/components/responses/OpenAIError'}
'500': {$ref: '#/components/responses/OpenAIError'}
'502': {$ref: '#/components/responses/UpstreamResponse'}
'503': {$ref: '#/components/responses/OpenAIError'}
'504': {$ref: '#/components/responses/OpenAIError'}
/admin/v1/setup/status:
get:
tags: [Setup]
summary: Check whether the owner password has been set
operationId: getSetupStatus
security: []
responses:
'200':
description: Setup status.
content:
application/json:
schema:
type: object
required: [password_set, bootstrap_token_required]
properties:
password_set: {type: boolean}
bootstrap_token_required:
type: boolean
description: True when the password is not set and this client is not local, so setup must present the one-time bootstrap token printed in the service log.
'503':
$ref: '#/components/responses/AdminError'
/admin/v1/setup/password:
post:
tags: [Setup]
summary: Set the initial owner password
operationId: setInitialPassword
description: Available only until the initial password is set. Browser requests must be same-origin; requests identified as cross-site are rejected. A client that is not on the local machine (a loopback peer without forwarding headers, or a loopback client reported by a trusted proxy) must also present the one-time bootstrap token printed in the service log at startup; it is invalidated by a successful setup. Password length is 12–1024 bytes.
security: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [password]
properties:
password: {type: string, minLength: 12, maxLength: 1024, writeOnly: true}
bootstrap_token: {type: string, writeOnly: true, description: Required from a non-local client.}
responses:
'201':
description: Initial password set.
content:
application/json:
schema:
type: object
required: [password_set]
properties:
password_set: {type: boolean, const: true}
'400': {$ref: '#/components/responses/AdminError'}
'403': {$ref: '#/components/responses/AdminError'}
'409': {$ref: '#/components/responses/AdminError'}
'429': {$ref: '#/components/responses/AdminError'}
'503': {$ref: '#/components/responses/AdminError'}
/admin/v1/password:
patch:
tags: [Admin]
summary: Change the owner password
operationId: changeOwnerPassword
security:
- adminSession: []
requestBody:
required: true
content:
application/json:
schema:
type: object
required: [current_password, password]
properties:
current_password: {type: string, writeOnly: true}
password: {type: string, minLength: 12, maxLength: 1024, writeOnly: true}
responses:
'200':
description: Password changed; existing browser sessions are revoked.
content:
application/json:
schema:
type: object
required: [changed]
properties:
changed: {type: boolean, const: true}
'400': {$ref: '#/components/responses/AdminError'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/InsufficientScope'}
/admin/v1/dashboard:
get:
tags: [Admin]
summary: Read dashboard usage metrics
operationId: getAdminDashboard
security:
- adminSession: []
parameters:
- name: window
in: query
required: false
description: Reporting period, defaulting to 24h.
schema: {type: string, enum: [1h, 24h, 7d, 30d], default: 24h}
responses:
'200':
description: Final client success rate, model and group upstream attempt usage, and output TPS.
content:
application/json:
schema:
type: object
required: [window, success_rate, models, groups, output_tps_60s]
properties:
window:
type: object
required: [key, from, to]
properties:
key: {type: string, enum: [1h, 24h, 7d, 30d]}
from: {type: string, format: date-time}
to: {type: string, format: date-time}
success_rate: {$ref: '#/components/schemas/DashboardMetric'}
models:
type: array
items: {$ref: '#/components/schemas/DashboardCountRow'}
groups:
type: array
items: {$ref: '#/components/schemas/DashboardCountRow'}
output_tps_60s: {type: [number, 'null'], format: double}
'400': {$ref: '#/components/responses/AdminError'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/InsufficientScope'}
'500': {$ref: '#/components/responses/AdminError'}
/admin/v1/groups:
get:
tags: [Admin]
summary: Read the fixed routing model groups
operationId: getModelGroups
security:
- adminSession: []
responses:
'200':
description: Three ordered provider/model fallback lists.
content:
application/json:
schema: {$ref: '#/components/schemas/ModelGroups'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/InsufficientScope'}
put:
tags: [Admin]
summary: Replace all routing model groups
operationId: putModelGroups
description: All three groups are required. Array order is fallback order; each group accepts up to eight distinct enabled provider/model pairs.
security:
- adminSession: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ModelGroups'}
responses:
'200':
description: The saved ordered groups.
content:
application/json:
schema: {$ref: '#/components/schemas/ModelGroups'}
'400': {$ref: '#/components/responses/AdminError'}
'401': {$ref: '#/components/responses/Unauthorized'}
'403': {$ref: '#/components/responses/InsufficientScope'}
/admin/v1/health:
get:
tags: [Admin]
summary: Management health report
operationId: getAdminHealth
description: |
A management-scoped counterpart of `/readyz`. It is **always `200`**: readiness is a field
(`status`, and `storage`) rather than a status code, because an administrator asking "why is
the service not ready" needs the answer to arrive with the diagnosis.
The report also carries the published catalogue's generation and row counts, the routing
log writer's queue state and counters, the settings version and overlay flag, and the live
browser session count. It never reports a token, a key name or a key value.
security:
- adminSession: []
responses:
'200':
description: The health report.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/AdminHealth'}
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
/admin/v1/models:
get:
tags: [Admin]
summary: List logical models
operationId: listAdminModels
description: |
Returns logical models from the database (the authority the published snapshot is built
from) in contract order: ID ascending. `next_cursor` is an opaque
position key rather than an offset, so a concurrent write cannot make a row appear twice or
disappear.
security:
- adminSession: []
parameters:
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/Cursor'
- $ref: '#/components/parameters/Search'
- name: enabled
in: query
required: false
description: Filter by the row's enabled flag. Anything other than a boolean is `400 invalid_filter`.
schema: {type: boolean}
- name: source
in: query
required: false
description: Filter by where the row came from. `local` is an administrator-owned row; `modelsdev` came from a models.dev synchronization.
schema:
type: string
enum: [local, modelsdev]
responses:
'200':
description: One page of models.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema:
$ref: '#/components/schemas/ModelPage'
'400':
$ref: '#/components/responses/AdminError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'500':
$ref: '#/components/responses/AdminError'
post:
tags: [Admin]
summary: Create a logical model
operationId: createAdminModel
description: |
Inserts an administrator-owned local model. The `auto` identifier and the reserved
`provider:` prefix are rejected, so no registry entry can shadow either request syntax.
Explicit creation clears a prior logical-model deletion exclusion. Previously deleted
provider/model bindings stay excluded until explicitly rebound. Historical log snapshots
are retained independently of the current registry.
security:
- adminSession: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ModelCreate'}
responses:
'201':
description: The created model, as it will be reported from now on.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/Model'}
'400':
$ref: '#/components/responses/AdminError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'409':
description: A model with this ID already exists (`model_exists`).
content:
application/json:
schema: {$ref: '#/components/schemas/AdminError'}
'413':
$ref: '#/components/responses/AdminError'
'500':
$ref: '#/components/responses/AdminError'
/admin/v1/models/{id}:
parameters:
- $ref: '#/components/parameters/ModelId'
get:
tags: [Admin]
summary: Read one logical model with its bindings
operationId: getAdminModel
description: |
Returns the model together with every binding that references it, so an operator can see
what disabling it would affect without a second request. The binding list is bounded by
`admin.max_page_size` and carries no cursor or truncation indicator.
security:
- adminSession: []
responses:
'200':
description: The model and its bindings.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/ModelDetail'}
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
description: No such model (`unknown_model`).
content:
application/json:
schema: {$ref: '#/components/schemas/AdminError'}
'500':
$ref: '#/components/responses/AdminError'
patch:
tags: [Admin]
summary: Update a logical model
operationId: patchAdminModel
description: |
A partial update. At least one field must be present, and `display_name`, `enabled` and
`priority` cannot be explicitly `null`; a body that carries none of them is
`400 invalid_request`. A successful write marks the row administrator-owned and republishes
the routing snapshot.
security:
- adminSession: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ModelPatch'}
responses:
'200':
description: The updated model.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/Model'}
'400':
$ref: '#/components/responses/AdminError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
description: No such model (`unknown_model`).
content:
application/json:
schema: {$ref: '#/components/schemas/AdminError'}
'413':
$ref: '#/components/responses/AdminError'
'500':
$ref: '#/components/responses/AdminError'
delete:
tags: [Admin]
summary: Permanently delete a logical model and all its bindings
operationId: deleteAdminModel
description: |
Deletes a logical model of any source, its provider/model bindings and all matching
routing-group members atomically. Surviving group members keep their order with compacted
positions. Providers, other models and historical routing logs/attempts are retained.
Persistent exclusions prevent local imports and models.dev synchronization from recreating
the model or its bindings, including bindings from newly discovered providers.
Explicit model creation or provider model selection clears the model exclusion; previously
deleted bindings stay excluded unless explicitly rebound.
The running groups and catalog are republished after commit. A 500
snapshot_publish_failed means deletion was committed but runtime refresh failed;
restarting loads the committed registry.
security:
- adminSession: []
responses:
'200':
description: The model and its bindings were deleted.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema:
type: object
required: [id, deleted]
properties:
id: {type: string}
deleted: {type: boolean, enum: [true]}
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
description: No such model (unknown_model).
content:
application/json:
schema: {$ref: '#/components/schemas/AdminError'}
'500':
$ref: '#/components/responses/AdminError'
/admin/v1/providers:
get:
tags: [Admin]
summary: List providers
operationId: listAdminProviders
description: |
Returns providers in contract order (priority ascending, then key ascending). A provider's
credential is never returned, not even masked: the row reports `api_key_set` only.
security:
- adminSession: []
parameters:
- $ref: '#/components/parameters/Limit'
- $ref: '#/components/parameters/Cursor'
- $ref: '#/components/parameters/Search'
- name: enabled
in: query
required: false
description: Filter by the row's enabled flag.
schema: {type: boolean}
responses:
'200':
description: One page of providers.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema:
$ref: '#/components/schemas/ProviderPage'
'400':
$ref: '#/components/responses/AdminError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'500':
$ref: '#/components/responses/AdminError'
post:
tags: [Admin]
summary: Create a provider
operationId: createAdminProvider
description: |
Creates an administrator-owned local provider. An empty `display_name` defaults to the key.
`base_url` is optional only while the provider is disabled; enabling a provider without one
is refused, because such a row could never serve a request. `api_key` is write-only.
security:
- adminSession: []
requestBody:
required: true
content:
application/json:
schema: {$ref: '#/components/schemas/ProviderCreate'}
responses:
'201':
description: The created provider.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/Provider'}
'400':
$ref: '#/components/responses/AdminError'
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'409':
description: A provider with this key already exists (`provider_exists`).
content:
application/json:
schema: {$ref: '#/components/schemas/AdminError'}
'413':
$ref: '#/components/responses/AdminError'
'500':
$ref: '#/components/responses/AdminError'
/admin/v1/providers/{key}:
parameters:
- $ref: '#/components/parameters/ProviderKey'
get:
tags: [Admin]
summary: Read one provider with its bindings
operationId: getAdminProvider
description: Returns the provider together with every binding it serves.
security:
- adminSession: []
responses:
'200':
description: The provider and its bindings.
headers:
X-Request-Id: {$ref: '#/components/headers/XRequestId'}
content:
application/json:
schema: {$ref: '#/components/schemas/ProviderDetail'}
'401':
$ref: '#/components/responses/Unauthorized'
'403':
$ref: '#/components/responses/InsufficientScope'
'404':
description: No such provider (`unknown_provider`).
content:
application/json:
schema: {$ref: '#/components/schemas/AdminError'}
'500':
$ref: '#/components/responses/AdminError'
patch:
tags: [Admin]
summary: Update a provider
operationId: patchAdminProvider
description: |
A partial update. At least one field must be present. `display_name`, `enabled` and
`priority` cannot be explicitly `null`; an explicit `null` for `gateway_provider`,
`base_url` or `api_key` clears that column (a cleared mapping is stored as SQL NULL).
The merged row is validated before it is written, so a patch cannot leave an enabled
provider without an executable endpoint. Rotating `api_key` rebuilds that provider's
executor atomically: requests already holding the old connection finish, new requests use
the new credential.
security:
- adminSession: []