@bodhiapp/ts-client 0.1.30 → 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
  */
@@ -343,9 +324,15 @@ export type BodhiError = {
343
324
  /**
344
325
  * Additional error parameters as key-value pairs (for validation errors)
345
326
  */
346
- param?: {
327
+ params?: {
347
328
  [key: string]: string;
348
329
  } | null;
330
+ /**
331
+ * JSON-encoded form of `params`. Superset field so clients that speak the
332
+ * OpenAI `Error` shape (where `param` is a String) can still read it.
333
+ * Populated automatically from `params` by `BodhiError::new`.
334
+ */
335
+ param?: string | null;
349
336
  };
350
337
  export type BodhiErrorResponse = {
351
338
  /**
@@ -479,6 +466,91 @@ export type DashboardUser = {
479
466
  first_name?: string | null;
480
467
  last_name?: string | null;
481
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
+ };
482
554
  export type DeploymentMode = 'standalone' | 'multi_tenant';
483
555
  export type DownloadRequest = {
484
556
  id: string;
@@ -514,30 +586,21 @@ export type EffortCapability = {
514
586
  max: CapabilitySupport;
515
587
  };
516
588
  /**
517
- * Request to fetch available models from provider
589
+ * Request to fetch available models from provider. Discriminated on `api_format`.
518
590
  */
519
- export type FetchModelsRequest = {
520
- /**
521
- * Credentials to use for fetching models
522
- */
523
- creds?: TestCreds;
524
- /**
525
- * API base URL (required - always needed to know where to fetch models from)
526
- */
527
- base_url: string;
528
- /**
529
- * API format to use for fetching models (defaults to OpenAI Chat Completions)
530
- */
531
- api_format?: ApiFormat;
532
- /**
533
- * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
534
- */
535
- extra_headers?: unknown;
536
- /**
537
- * Optional extra fields to merge into the request body
538
- */
539
- extra_body?: unknown;
540
- };
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
+ });
541
604
  /**
542
605
  * Returns model IDs only (not full metadata) to minimize information exposure —
543
606
  * the endpoint accepts an API key parameter. Full metadata is stored on create/update.
@@ -578,6 +641,127 @@ export type ListUsersParams = {
578
641
  page?: number | null;
579
642
  page_size?: number | null;
580
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
+ };
581
765
  /**
582
766
  * Local model file response
583
767
  */
@@ -1197,38 +1381,21 @@ export type TestCreds = {
1197
1381
  type: 'api_key';
1198
1382
  };
1199
1383
  /**
1200
- * Request to test API connectivity with a prompt
1384
+ * Request to test API connectivity with a prompt. Discriminated on `api_format`.
1201
1385
  */
1202
- export type TestPromptRequest = {
1203
- /**
1204
- * Credentials to use for testing
1205
- */
1206
- creds?: TestCreds;
1207
- /**
1208
- * API base URL
1209
- */
1210
- base_url: string;
1211
- /**
1212
- * Model to use for testing
1213
- */
1214
- model: string;
1215
- /**
1216
- * Test prompt (max 30 characters for cost control)
1217
- */
1218
- prompt: string;
1219
- /**
1220
- * API format to use for the test request (defaults to OpenAI Chat Completions)
1221
- */
1222
- api_format?: ApiFormat;
1223
- /**
1224
- * Optional extra HTTP headers. `Authorization` / `x-api-key` are forbidden.
1225
- */
1226
- extra_headers?: unknown;
1227
- /**
1228
- * Optional extra fields to merge into the request body
1229
- */
1230
- extra_body?: unknown;
1231
- };
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
+ });
1232
1399
  /**
1233
1400
  * Response from testing API connectivity
1234
1401
  */