@bodhiapp/ts-client 0.1.31 → 0.1.32

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.
@@ -152,13 +152,14 @@ export type ApiAliasResponse = {
152
152
  forward_all_with_prefix: boolean;
153
153
  extra_headers?: unknown;
154
154
  extra_body?: unknown;
155
+ llm_liberty?: null | LlmLibertySummary;
155
156
  created_at: string;
156
157
  updated_at: string;
157
158
  };
158
159
  /**
159
160
  * API format/protocol specification
160
161
  */
161
- export type ApiFormat = 'openai' | 'openai_responses' | 'anthropic' | 'anthropic_oauth' | 'gemini';
162
+ export type ApiFormat = 'openai' | 'openai_responses' | 'anthropic' | 'anthropic_oauth' | 'gemini' | 'llm_liberty_oauth';
162
163
  /**
163
164
  * Response containing available API formats
164
165
  */
@@ -194,42 +195,22 @@ export type ApiModel = (Model & {
194
195
  });
195
196
  /**
196
197
  * Input request for creating or updating an API model configuration.
198
+ * Discriminated by `api_format` — `llm_liberty_oauth` uses `LlmLibertyApiModelRequest`,
199
+ * every other format uses `DefaultApiModelRequest`.
197
200
  */
198
- export type ApiModelRequest = {
199
- /**
200
- * API format/protocol (e.g., "openai")
201
- */
202
- api_format: ApiFormat;
203
- /**
204
- * API base URL
205
- */
206
- base_url: string;
207
- /**
208
- * API key update action (Keep/Set with Some or None)
209
- */
210
- api_key?: ApiKeyUpdate;
211
- /**
212
- * List of available models
213
- */
214
- models: Array<string>;
215
- /**
216
- * Optional prefix for model namespacing (e.g., "azure/" for "azure/gpt-4")
217
- */
218
- prefix?: string | null;
219
- /**
220
- * Whether to forward all requests with this prefix (true) or only selected models (false)
221
- */
222
- forward_all_with_prefix?: boolean;
223
- /**
224
- * Optional extra HTTP headers to send upstream. Cannot include `Authorization`
225
- * or `x-api-key` — those are owned by provider clients.
226
- */
227
- extra_headers?: unknown;
228
- /**
229
- * Optional extra fields to merge into the request body sent upstream
230
- */
231
- extra_body?: unknown;
232
- };
201
+ export type ApiModelRequest = (DefaultApiModelRequest & {
202
+ api_format: 'openai';
203
+ }) | (DefaultApiModelRequest & {
204
+ api_format: 'openai_responses';
205
+ }) | (DefaultApiModelRequest & {
206
+ api_format: 'anthropic';
207
+ }) | (DefaultApiModelRequest & {
208
+ api_format: 'anthropic_oauth';
209
+ }) | (DefaultApiModelRequest & {
210
+ api_format: 'gemini';
211
+ }) | (LlmLibertyApiModelRequest & {
212
+ api_format: 'llm_liberty_oauth';
213
+ });
233
214
  /**
234
215
  * DB-storable `Vec<ApiModel>` — stored as JSON binary in SeaORM columns.
235
216
  */
@@ -485,6 +466,91 @@ export type DashboardUser = {
485
466
  first_name?: string | null;
486
467
  last_name?: string | null;
487
468
  };
469
+ /**
470
+ * Inner request shape for the five non-llm-liberty `api_format` values.
471
+ * Shared across `openai`, `openai_responses`, `anthropic`, `anthropic_oauth`, `gemini`.
472
+ */
473
+ export type DefaultApiModelRequest = {
474
+ /**
475
+ * API base URL
476
+ */
477
+ base_url: string;
478
+ /**
479
+ * API key update action (Keep/Set with Some or None)
480
+ */
481
+ api_key?: ApiKeyUpdate;
482
+ /**
483
+ * List of available models
484
+ */
485
+ models: Array<string>;
486
+ /**
487
+ * Optional prefix for model namespacing (e.g., "azure/" for "azure/gpt-4")
488
+ */
489
+ prefix?: string | null;
490
+ /**
491
+ * Whether to forward all requests with this prefix (true) or only selected models (false)
492
+ */
493
+ forward_all_with_prefix?: boolean;
494
+ /**
495
+ * Optional extra HTTP headers to send upstream. Cannot include `Authorization`
496
+ * or `x-api-key` — those are owned by provider clients.
497
+ */
498
+ extra_headers?: unknown;
499
+ /**
500
+ * Optional extra fields to merge into the request body sent upstream
501
+ */
502
+ extra_body?: unknown;
503
+ };
504
+ /**
505
+ * Inner request for the five non-llm-liberty `api_format` values.
506
+ */
507
+ export type DefaultFetchModelsRequest = {
508
+ /**
509
+ * Credentials to use for fetching models
510
+ */
511
+ creds?: TestCreds;
512
+ /**
513
+ * API base URL (required - always needed to know where to fetch models from)
514
+ */
515
+ base_url: string;
516
+ /**
517
+ * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
518
+ */
519
+ extra_headers?: unknown;
520
+ /**
521
+ * Optional extra fields to merge into the request body
522
+ */
523
+ extra_body?: unknown;
524
+ };
525
+ /**
526
+ * Inner request for the five non-llm-liberty `api_format` values.
527
+ */
528
+ export type DefaultTestPromptRequest = {
529
+ /**
530
+ * Credentials to use for testing
531
+ */
532
+ creds?: TestCreds;
533
+ /**
534
+ * API base URL
535
+ */
536
+ base_url: string;
537
+ /**
538
+ * Model to use for testing
539
+ */
540
+ model: string;
541
+ /**
542
+ * Test prompt (max 30 characters for cost control)
543
+ */
544
+ prompt: string;
545
+ /**
546
+ * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
547
+ */
548
+ extra_headers?: unknown;
549
+ /**
550
+ * Optional extra fields to merge into the request body
551
+ */
552
+ extra_body?: unknown;
553
+ };
488
554
  export type DeploymentMode = 'standalone' | 'multi_tenant';
489
555
  export type DownloadRequest = {
490
556
  id: string;
@@ -520,30 +586,21 @@ export type EffortCapability = {
520
586
  max: CapabilitySupport;
521
587
  };
522
588
  /**
523
- * Request to fetch available models from provider
589
+ * Request to fetch available models from provider. Discriminated on `api_format`.
524
590
  */
525
- export type FetchModelsRequest = {
526
- /**
527
- * Credentials to use for fetching models
528
- */
529
- creds?: TestCreds;
530
- /**
531
- * API base URL (required - always needed to know where to fetch models from)
532
- */
533
- base_url: string;
534
- /**
535
- * API format to use for fetching models (defaults to OpenAI Chat Completions)
536
- */
537
- api_format?: ApiFormat;
538
- /**
539
- * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
540
- */
541
- extra_headers?: unknown;
542
- /**
543
- * Optional extra fields to merge into the request body
544
- */
545
- extra_body?: unknown;
546
- };
591
+ export type FetchModelsRequest = (DefaultFetchModelsRequest & {
592
+ api_format: 'openai';
593
+ }) | (DefaultFetchModelsRequest & {
594
+ api_format: 'openai_responses';
595
+ }) | (DefaultFetchModelsRequest & {
596
+ api_format: 'anthropic';
597
+ }) | (DefaultFetchModelsRequest & {
598
+ api_format: 'anthropic_oauth';
599
+ }) | (DefaultFetchModelsRequest & {
600
+ api_format: 'gemini';
601
+ }) | (LlmLibertyFetchModelsRequest & {
602
+ api_format: 'llm_liberty_oauth';
603
+ });
547
604
  /**
548
605
  * Returns model IDs only (not full metadata) to minimize information exposure —
549
606
  * the endpoint accepts an API key parameter. Full metadata is stored on create/update.
@@ -584,6 +641,127 @@ export type ListUsersParams = {
584
641
  page?: number | null;
585
642
  page_size?: number | null;
586
643
  };
644
+ export type LlmLibertyApiEndpoints = {
645
+ base_url: string;
646
+ chat_url: string;
647
+ models_url?: string | null;
648
+ };
649
+ /**
650
+ * Request shape for `api_format == "llm_liberty_oauth"`. Carries the full envelope
651
+ * (or `Keep` to leave existing credentials untouched on update).
652
+ */
653
+ export type LlmLibertyApiModelRequest = {
654
+ /**
655
+ * Envelope update action — Keep (update only) or Set (create/replace credentials).
656
+ */
657
+ envelope?: LlmLibertyEnvelopeUpdate;
658
+ /**
659
+ * List of available models
660
+ */
661
+ models?: Array<string>;
662
+ /**
663
+ * Optional prefix for model namespacing
664
+ */
665
+ prefix?: string | null;
666
+ /**
667
+ * Whether to forward all requests with this prefix
668
+ */
669
+ forward_all_with_prefix?: boolean;
670
+ };
671
+ export type LlmLibertyAuthSpec = {
672
+ in: string;
673
+ key: string;
674
+ scheme: string;
675
+ };
676
+ /**
677
+ * The JSON blob emitted by `npx @bodhiapp/llm-liberty@latest login`.
678
+ *
679
+ * Version field allows BodhiApp to detect breaking changes in the envelope
680
+ * schema (major-version bump = breaking). Currently only `"1.0.0"` is accepted.
681
+ */
682
+ export type LlmLibertyEnvelope = {
683
+ /**
684
+ * Envelope schema version — must be "1.0.0".
685
+ */
686
+ version: string;
687
+ /**
688
+ * Provider identifier, e.g. "anthropic" or "openai-codex".
689
+ */
690
+ provider: string;
691
+ access_token: string;
692
+ refresh_token: string;
693
+ /**
694
+ * Unix epoch seconds when the access token expires.
695
+ */
696
+ expires_at: number;
697
+ auth: LlmLibertyAuthSpec;
698
+ oauth: LlmLibertyOauthEndpoints;
699
+ api: LlmLibertyApiEndpoints;
700
+ headers?: unknown;
701
+ body?: unknown;
702
+ extra?: unknown;
703
+ };
704
+ /**
705
+ * Tagged envelope update action — either keep the existing credentials or replace them.
706
+ */
707
+ export type LlmLibertyEnvelopeUpdate = {
708
+ action: 'keep';
709
+ } | {
710
+ /**
711
+ * Replace with a new envelope (atomic re-paste).
712
+ */
713
+ value: LlmLibertyEnvelope;
714
+ action: 'set';
715
+ };
716
+ /**
717
+ * Inner request for `api_format == "llm_liberty_oauth"`. Either `id` (use stored creds)
718
+ * or `envelope` (use the provided envelope directly) must be set, never both.
719
+ */
720
+ export type LlmLibertyFetchModelsRequest = {
721
+ /**
722
+ * Edit mode: alias id whose stored credentials should be used.
723
+ */
724
+ id?: string | null;
725
+ envelope?: null | LlmLibertyEnvelope;
726
+ };
727
+ export type LlmLibertyOauthEndpoints = {
728
+ authorize_url: string;
729
+ token_url: string;
730
+ revoke_url?: string | null;
731
+ client_id: string;
732
+ client_secret?: string | null;
733
+ };
734
+ /**
735
+ * Non-secret summary of stored LLM Liberty OAuth credentials for API responses.
736
+ */
737
+ export type LlmLibertySummary = {
738
+ provider: string;
739
+ envelope_version: string;
740
+ /**
741
+ * Unix epoch seconds — when the stored access token expires.
742
+ */
743
+ expires_at: number;
744
+ has_refresh_token: boolean;
745
+ };
746
+ /**
747
+ * Inner request for `api_format == "llm_liberty_oauth"`. Either `id` (use stored creds)
748
+ * or `envelope` (use the provided envelope directly) must be set, never both.
749
+ */
750
+ export type LlmLibertyTestPromptRequest = {
751
+ /**
752
+ * Edit mode: alias id whose stored credentials should be used.
753
+ */
754
+ id?: string | null;
755
+ envelope?: null | LlmLibertyEnvelope;
756
+ /**
757
+ * Model to use for testing
758
+ */
759
+ model: string;
760
+ /**
761
+ * Test prompt (max 30 characters for cost control)
762
+ */
763
+ prompt: string;
764
+ };
587
765
  /**
588
766
  * Local model file response
589
767
  */
@@ -1203,38 +1381,21 @@ export type TestCreds = {
1203
1381
  type: 'api_key';
1204
1382
  };
1205
1383
  /**
1206
- * Request to test API connectivity with a prompt
1384
+ * Request to test API connectivity with a prompt. Discriminated on `api_format`.
1207
1385
  */
1208
- export type TestPromptRequest = {
1209
- /**
1210
- * Credentials to use for testing
1211
- */
1212
- creds?: TestCreds;
1213
- /**
1214
- * API base URL
1215
- */
1216
- base_url: string;
1217
- /**
1218
- * Model to use for testing
1219
- */
1220
- model: string;
1221
- /**
1222
- * Test prompt (max 30 characters for cost control)
1223
- */
1224
- prompt: string;
1225
- /**
1226
- * API format to use for the test request (defaults to OpenAI Chat Completions)
1227
- */
1228
- api_format?: ApiFormat;
1229
- /**
1230
- * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
1231
- */
1232
- extra_headers?: unknown;
1233
- /**
1234
- * Optional extra fields to merge into the request body
1235
- */
1236
- extra_body?: unknown;
1237
- };
1386
+ export type TestPromptRequest = (DefaultTestPromptRequest & {
1387
+ api_format: 'openai';
1388
+ }) | (DefaultTestPromptRequest & {
1389
+ api_format: 'openai_responses';
1390
+ }) | (DefaultTestPromptRequest & {
1391
+ api_format: 'anthropic';
1392
+ }) | (DefaultTestPromptRequest & {
1393
+ api_format: 'anthropic_oauth';
1394
+ }) | (DefaultTestPromptRequest & {
1395
+ api_format: 'gemini';
1396
+ }) | (LlmLibertyTestPromptRequest & {
1397
+ api_format: 'llm_liberty_oauth';
1398
+ });
1238
1399
  /**
1239
1400
  * Response from testing API connectivity
1240
1401
  */