@mistralai/mistralai 2.0.0-alpha.1 → 2.0.0

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 (127) hide show
  1. package/README.md +8 -6
  2. package/esm/extra/structChat.d.ts.map +1 -1
  3. package/esm/extra/structChat.js +71 -4
  4. package/esm/extra/structChat.js.map +1 -1
  5. package/esm/funcs/betaConnectorsGetAuthUrl.d.ts +19 -0
  6. package/esm/funcs/betaConnectorsGetAuthUrl.d.ts.map +1 -0
  7. package/esm/funcs/betaConnectorsGetAuthUrl.js +90 -0
  8. package/esm/funcs/betaConnectorsGetAuthUrl.js.map +1 -0
  9. package/esm/funcs/betaObservabilityJudgesJudgeConversation.d.ts +16 -0
  10. package/esm/funcs/betaObservabilityJudgesJudgeConversation.d.ts.map +1 -0
  11. package/esm/funcs/betaObservabilityJudgesJudgeConversation.js +91 -0
  12. package/esm/funcs/betaObservabilityJudgesJudgeConversation.js.map +1 -0
  13. package/esm/lib/config.d.ts +2 -2
  14. package/esm/lib/config.js +2 -2
  15. package/esm/lib/config.js.map +1 -1
  16. package/esm/models/components/agentscompletionrequest.d.ts +6 -0
  17. package/esm/models/components/agentscompletionrequest.d.ts.map +1 -1
  18. package/esm/models/components/agentscompletionrequest.js +5 -0
  19. package/esm/models/components/agentscompletionrequest.js.map +1 -1
  20. package/esm/models/components/agentscompletionstreamrequest.d.ts +6 -0
  21. package/esm/models/components/agentscompletionstreamrequest.d.ts.map +1 -1
  22. package/esm/models/components/agentscompletionstreamrequest.js +5 -0
  23. package/esm/models/components/agentscompletionstreamrequest.js.map +1 -1
  24. package/esm/models/components/authurlresponse.d.ts +11 -0
  25. package/esm/models/components/authurlresponse.d.ts.map +1 -0
  26. package/esm/models/components/authurlresponse.js +20 -0
  27. package/esm/models/components/authurlresponse.js.map +1 -0
  28. package/esm/models/components/basemodelcard.d.ts +6 -0
  29. package/esm/models/components/basemodelcard.d.ts.map +1 -1
  30. package/esm/models/components/basemodelcard.js.map +1 -1
  31. package/esm/models/components/chatcompletionrequest.d.ts +6 -0
  32. package/esm/models/components/chatcompletionrequest.d.ts.map +1 -1
  33. package/esm/models/components/chatcompletionrequest.js +5 -0
  34. package/esm/models/components/chatcompletionrequest.js.map +1 -1
  35. package/esm/models/components/chatcompletionstreamrequest.d.ts +6 -0
  36. package/esm/models/components/chatcompletionstreamrequest.d.ts.map +1 -1
  37. package/esm/models/components/chatcompletionstreamrequest.js +5 -0
  38. package/esm/models/components/chatcompletionstreamrequest.js.map +1 -1
  39. package/esm/models/components/conversationresponse.d.ts +3 -5
  40. package/esm/models/components/conversationresponse.d.ts.map +1 -1
  41. package/esm/models/components/conversationresponse.js +1 -7
  42. package/esm/models/components/conversationresponse.js.map +1 -1
  43. package/esm/models/components/ftmodelcard.d.ts +6 -0
  44. package/esm/models/components/ftmodelcard.d.ts.map +1 -1
  45. package/esm/models/components/ftmodelcard.js.map +1 -1
  46. package/esm/models/components/imageurlchunk.d.ts +1 -1
  47. package/esm/models/components/index.d.ts +3 -0
  48. package/esm/models/components/index.d.ts.map +1 -1
  49. package/esm/models/components/index.js +3 -0
  50. package/esm/models/components/index.js.map +1 -1
  51. package/esm/models/components/instructrequest.d.ts +3 -0
  52. package/esm/models/components/instructrequest.d.ts.map +1 -1
  53. package/esm/models/components/instructrequest.js.map +1 -1
  54. package/esm/models/components/judgeconversationrequest.d.ts +22 -0
  55. package/esm/models/components/judgeconversationrequest.d.ts.map +1 -0
  56. package/esm/models/components/judgeconversationrequest.js +14 -0
  57. package/esm/models/components/judgeconversationrequest.js.map +1 -0
  58. package/esm/models/components/modelcapabilities.d.ts +8 -0
  59. package/esm/models/components/modelcapabilities.d.ts.map +1 -1
  60. package/esm/models/components/modelcapabilities.js +4 -0
  61. package/esm/models/components/modelcapabilities.js.map +1 -1
  62. package/esm/models/components/reasoningeffort.d.ts +10 -0
  63. package/esm/models/components/reasoningeffort.d.ts.map +1 -0
  64. package/esm/models/components/reasoningeffort.js +12 -0
  65. package/esm/models/components/reasoningeffort.js.map +1 -0
  66. package/esm/models/components/referencechunk.d.ts +11 -2
  67. package/esm/models/components/referencechunk.d.ts.map +1 -1
  68. package/esm/models/components/referencechunk.js +13 -2
  69. package/esm/models/components/referencechunk.js.map +1 -1
  70. package/esm/models/operations/connectorgetauthurlv1.d.ts +14 -0
  71. package/esm/models/operations/connectorgetauthurlv1.d.ts.map +1 -0
  72. package/esm/models/operations/connectorgetauthurlv1.js +20 -0
  73. package/esm/models/operations/connectorgetauthurlv1.js.map +1 -0
  74. package/esm/models/operations/index.d.ts +2 -0
  75. package/esm/models/operations/index.d.ts.map +1 -1
  76. package/esm/models/operations/index.js +2 -0
  77. package/esm/models/operations/index.js.map +1 -1
  78. package/esm/models/operations/judgeconversationv1observabilityjudgesjudgeidlivejudgingpost.d.ts +15 -0
  79. package/esm/models/operations/judgeconversationv1observabilityjudgesjudgeidlivejudgingpost.d.ts.map +1 -0
  80. package/esm/models/operations/judgeconversationv1observabilityjudgesjudgeidlivejudgingpost.js +22 -0
  81. package/esm/models/operations/judgeconversationv1observabilityjudgesjudgeidlivejudgingpost.js.map +1 -0
  82. package/esm/sdk/connectors.d.ts +7 -0
  83. package/esm/sdk/connectors.d.ts.map +1 -1
  84. package/esm/sdk/connectors.js +10 -0
  85. package/esm/sdk/connectors.js.map +1 -1
  86. package/esm/sdk/judges.d.ts +4 -0
  87. package/esm/sdk/judges.d.ts.map +1 -1
  88. package/esm/sdk/judges.js +7 -0
  89. package/esm/sdk/judges.js.map +1 -1
  90. package/examples/src/gcp/async_chat_no_streaming.ts +2 -2
  91. package/jsr.json +1 -1
  92. package/package.json +8 -3
  93. package/packages/mistralai-gcp/examples/chatComplete.example.ts +3 -3
  94. package/packages/mistralai-gcp/src/core.ts +1 -1
  95. package/packages/mistralai-gcp/src/funcs/chatComplete.ts +7 -7
  96. package/packages/mistralai-gcp/src/funcs/chatStream.ts +7 -7
  97. package/packages/mistralai-gcp/src/funcs/fimComplete.ts +7 -7
  98. package/packages/mistralai-gcp/src/funcs/fimStream.ts +7 -7
  99. package/packages/mistralai-gcp/src/models/errors/httpvalidationerror.ts +2 -2
  100. package/packages/mistralai-gcp/src/models/errors/mistralgoogleclouderror.ts +2 -2
  101. package/packages/mistralai-gcp/src/models/errors/responsevalidationerror.ts +2 -2
  102. package/packages/mistralai-gcp/src/models/errors/sdkerror.ts +2 -2
  103. package/packages/mistralai-gcp/src/sdk/sdk.ts +6 -5
  104. package/src/extra/structChat.ts +69 -3
  105. package/src/funcs/betaConnectorsGetAuthUrl.ts +186 -0
  106. package/src/funcs/betaObservabilityJudgesJudgeConversation.ts +188 -0
  107. package/src/lib/config.ts +2 -2
  108. package/src/models/components/agentscompletionrequest.ts +16 -0
  109. package/src/models/components/agentscompletionstreamrequest.ts +16 -0
  110. package/src/models/components/authurlresponse.ts +38 -0
  111. package/src/models/components/basemodelcard.ts +6 -0
  112. package/src/models/components/chatcompletionrequest.ts +16 -0
  113. package/src/models/components/chatcompletionstreamrequest.ts +16 -0
  114. package/src/models/components/conversationresponse.ts +2 -20
  115. package/src/models/components/ftmodelcard.ts +6 -0
  116. package/src/models/components/imageurlchunk.ts +1 -1
  117. package/src/models/components/index.ts +3 -0
  118. package/src/models/components/instructrequest.ts +3 -0
  119. package/src/models/components/judgeconversationrequest.ts +34 -0
  120. package/src/models/components/modelcapabilities.ts +12 -0
  121. package/src/models/components/reasoningeffort.ts +17 -0
  122. package/src/models/components/referencechunk.ts +32 -4
  123. package/src/models/operations/connectorgetauthurlv1.ts +42 -0
  124. package/src/models/operations/index.ts +2 -0
  125. package/src/models/operations/judgeconversationv1observabilityjudgesjudgeidlivejudgingpost.ts +49 -0
  126. package/src/sdk/connectors.ts +18 -0
  127. package/src/sdk/judges.ts +16 -0
@@ -3,7 +3,7 @@
3
3
  * @generated-id: 28f4bdac1bad
4
4
  */
5
5
 
6
- import { MistralGoogleCloudCore } from "../core.js";
6
+ import { MistralGCPCore } from "../core.js";
7
7
  import { encodeJSON } from "../lib/encodings.js";
8
8
  import * as M from "../lib/matchers.js";
9
9
  import { compactMap } from "../lib/primitives.js";
@@ -20,7 +20,7 @@ import {
20
20
  UnexpectedClientError,
21
21
  } from "../models/errors/httpclienterrors.js";
22
22
  import * as errors from "../models/errors/index.js";
23
- import { MistralGoogleCloudError } from "../models/errors/mistralgoogleclouderror.js";
23
+ import { MistralGCPError } from "../models/errors/mistralgoogleclouderror.js";
24
24
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
25
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
26
  import { APICall, APIPromise } from "../types/async.js";
@@ -30,14 +30,14 @@ import { Result } from "../types/fp.js";
30
30
  * Chat Completion
31
31
  */
32
32
  export function chatComplete(
33
- client: MistralGoogleCloudCore,
33
+ client: MistralGCPCore,
34
34
  request: components.ChatCompletionRequest,
35
35
  options?: RequestOptions,
36
36
  ): APIPromise<
37
37
  Result<
38
38
  components.ChatCompletionResponse,
39
39
  | errors.HTTPValidationError
40
- | MistralGoogleCloudError
40
+ | MistralGCPError
41
41
  | ResponseValidationError
42
42
  | ConnectionError
43
43
  | RequestAbortedError
@@ -55,7 +55,7 @@ export function chatComplete(
55
55
  }
56
56
 
57
57
  async function $do(
58
- client: MistralGoogleCloudCore,
58
+ client: MistralGCPCore,
59
59
  request: components.ChatCompletionRequest,
60
60
  options?: RequestOptions,
61
61
  ): Promise<
@@ -63,7 +63,7 @@ async function $do(
63
63
  Result<
64
64
  components.ChatCompletionResponse,
65
65
  | errors.HTTPValidationError
66
- | MistralGoogleCloudError
66
+ | MistralGCPError
67
67
  | ResponseValidationError
68
68
  | ConnectionError
69
69
  | RequestAbortedError
@@ -145,7 +145,7 @@ async function $do(
145
145
  const [result] = await M.match<
146
146
  components.ChatCompletionResponse,
147
147
  | errors.HTTPValidationError
148
- | MistralGoogleCloudError
148
+ | MistralGCPError
149
149
  | ResponseValidationError
150
150
  | ConnectionError
151
151
  | RequestAbortedError
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import * as z from "zod/v4";
7
- import { MistralGoogleCloudCore } from "../core.js";
7
+ import { MistralGCPCore } from "../core.js";
8
8
  import { encodeJSON } from "../lib/encodings.js";
9
9
  import { EventStream } from "../lib/event-streams.js";
10
10
  import * as M from "../lib/matchers.js";
@@ -22,7 +22,7 @@ import {
22
22
  UnexpectedClientError,
23
23
  } from "../models/errors/httpclienterrors.js";
24
24
  import * as errors from "../models/errors/index.js";
25
- import { MistralGoogleCloudError } from "../models/errors/mistralgoogleclouderror.js";
25
+ import { MistralGCPError } from "../models/errors/mistralgoogleclouderror.js";
26
26
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
27
27
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
28
28
  import { APICall, APIPromise } from "../types/async.js";
@@ -35,14 +35,14 @@ import { Result } from "../types/fp.js";
35
35
  * Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
36
36
  */
37
37
  export function chatStream(
38
- client: MistralGoogleCloudCore,
38
+ client: MistralGCPCore,
39
39
  request: components.ChatCompletionStreamRequest,
40
40
  options?: RequestOptions,
41
41
  ): APIPromise<
42
42
  Result<
43
43
  EventStream<components.CompletionEvent>,
44
44
  | errors.HTTPValidationError
45
- | MistralGoogleCloudError
45
+ | MistralGCPError
46
46
  | ResponseValidationError
47
47
  | ConnectionError
48
48
  | RequestAbortedError
@@ -60,7 +60,7 @@ export function chatStream(
60
60
  }
61
61
 
62
62
  async function $do(
63
- client: MistralGoogleCloudCore,
63
+ client: MistralGCPCore,
64
64
  request: components.ChatCompletionStreamRequest,
65
65
  options?: RequestOptions,
66
66
  ): Promise<
@@ -68,7 +68,7 @@ async function $do(
68
68
  Result<
69
69
  EventStream<components.CompletionEvent>,
70
70
  | errors.HTTPValidationError
71
- | MistralGoogleCloudError
71
+ | MistralGCPError
72
72
  | ResponseValidationError
73
73
  | ConnectionError
74
74
  | RequestAbortedError
@@ -151,7 +151,7 @@ async function $do(
151
151
  const [result] = await M.match<
152
152
  EventStream<components.CompletionEvent>,
153
153
  | errors.HTTPValidationError
154
- | MistralGoogleCloudError
154
+ | MistralGCPError
155
155
  | ResponseValidationError
156
156
  | ConnectionError
157
157
  | RequestAbortedError
@@ -3,7 +3,7 @@
3
3
  * @generated-id: d9b14c7344f1
4
4
  */
5
5
 
6
- import { MistralGoogleCloudCore } from "../core.js";
6
+ import { MistralGCPCore } from "../core.js";
7
7
  import { encodeJSON } from "../lib/encodings.js";
8
8
  import * as M from "../lib/matchers.js";
9
9
  import { compactMap } from "../lib/primitives.js";
@@ -20,7 +20,7 @@ import {
20
20
  UnexpectedClientError,
21
21
  } from "../models/errors/httpclienterrors.js";
22
22
  import * as errors from "../models/errors/index.js";
23
- import { MistralGoogleCloudError } from "../models/errors/mistralgoogleclouderror.js";
23
+ import { MistralGCPError } from "../models/errors/mistralgoogleclouderror.js";
24
24
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
25
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
26
  import { APICall, APIPromise } from "../types/async.js";
@@ -33,14 +33,14 @@ import { Result } from "../types/fp.js";
33
33
  * FIM completion.
34
34
  */
35
35
  export function fimComplete(
36
- client: MistralGoogleCloudCore,
36
+ client: MistralGCPCore,
37
37
  request: components.FIMCompletionRequest,
38
38
  options?: RequestOptions,
39
39
  ): APIPromise<
40
40
  Result<
41
41
  components.FIMCompletionResponse,
42
42
  | errors.HTTPValidationError
43
- | MistralGoogleCloudError
43
+ | MistralGCPError
44
44
  | ResponseValidationError
45
45
  | ConnectionError
46
46
  | RequestAbortedError
@@ -58,7 +58,7 @@ export function fimComplete(
58
58
  }
59
59
 
60
60
  async function $do(
61
- client: MistralGoogleCloudCore,
61
+ client: MistralGCPCore,
62
62
  request: components.FIMCompletionRequest,
63
63
  options?: RequestOptions,
64
64
  ): Promise<
@@ -66,7 +66,7 @@ async function $do(
66
66
  Result<
67
67
  components.FIMCompletionResponse,
68
68
  | errors.HTTPValidationError
69
- | MistralGoogleCloudError
69
+ | MistralGCPError
70
70
  | ResponseValidationError
71
71
  | ConnectionError
72
72
  | RequestAbortedError
@@ -148,7 +148,7 @@ async function $do(
148
148
  const [result] = await M.match<
149
149
  components.FIMCompletionResponse,
150
150
  | errors.HTTPValidationError
151
- | MistralGoogleCloudError
151
+ | MistralGCPError
152
152
  | ResponseValidationError
153
153
  | ConnectionError
154
154
  | RequestAbortedError
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import * as z from "zod/v4";
7
- import { MistralGoogleCloudCore } from "../core.js";
7
+ import { MistralGCPCore } from "../core.js";
8
8
  import { encodeJSON } from "../lib/encodings.js";
9
9
  import { EventStream } from "../lib/event-streams.js";
10
10
  import * as M from "../lib/matchers.js";
@@ -22,7 +22,7 @@ import {
22
22
  UnexpectedClientError,
23
23
  } from "../models/errors/httpclienterrors.js";
24
24
  import * as errors from "../models/errors/index.js";
25
- import { MistralGoogleCloudError } from "../models/errors/mistralgoogleclouderror.js";
25
+ import { MistralGCPError } from "../models/errors/mistralgoogleclouderror.js";
26
26
  import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
27
27
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
28
28
  import { APICall, APIPromise } from "../types/async.js";
@@ -35,14 +35,14 @@ import { Result } from "../types/fp.js";
35
35
  * Mistral AI provides the ability to stream responses back to a client in order to allow partial results for certain requests. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. Otherwise, the server will hold the request open until the timeout or until completion, with the response containing the full result as JSON.
36
36
  */
37
37
  export function fimStream(
38
- client: MistralGoogleCloudCore,
38
+ client: MistralGCPCore,
39
39
  request: components.FIMCompletionStreamRequest,
40
40
  options?: RequestOptions,
41
41
  ): APIPromise<
42
42
  Result<
43
43
  EventStream<components.CompletionEvent>,
44
44
  | errors.HTTPValidationError
45
- | MistralGoogleCloudError
45
+ | MistralGCPError
46
46
  | ResponseValidationError
47
47
  | ConnectionError
48
48
  | RequestAbortedError
@@ -60,7 +60,7 @@ export function fimStream(
60
60
  }
61
61
 
62
62
  async function $do(
63
- client: MistralGoogleCloudCore,
63
+ client: MistralGCPCore,
64
64
  request: components.FIMCompletionStreamRequest,
65
65
  options?: RequestOptions,
66
66
  ): Promise<
@@ -68,7 +68,7 @@ async function $do(
68
68
  Result<
69
69
  EventStream<components.CompletionEvent>,
70
70
  | errors.HTTPValidationError
71
- | MistralGoogleCloudError
71
+ | MistralGCPError
72
72
  | ResponseValidationError
73
73
  | ConnectionError
74
74
  | RequestAbortedError
@@ -151,7 +151,7 @@ async function $do(
151
151
  const [result] = await M.match<
152
152
  EventStream<components.CompletionEvent>,
153
153
  | errors.HTTPValidationError
154
- | MistralGoogleCloudError
154
+ | MistralGCPError
155
155
  | ResponseValidationError
156
156
  | ConnectionError
157
157
  | RequestAbortedError
@@ -5,13 +5,13 @@
5
5
 
6
6
  import * as z from "zod/v4";
7
7
  import * as components from "../components/index.js";
8
- import { MistralGoogleCloudError } from "./mistralgoogleclouderror.js";
8
+ import { MistralGCPError } from "./mistralgoogleclouderror.js";
9
9
 
10
10
  export type HTTPValidationErrorData = {
11
11
  detail?: Array<components.ValidationError> | undefined;
12
12
  };
13
13
 
14
- export class HTTPValidationError extends MistralGoogleCloudError {
14
+ export class HTTPValidationError extends MistralGCPError {
15
15
  detail?: Array<components.ValidationError> | undefined;
16
16
 
17
17
  /** The original data that was passed to this error instance. */
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  /** The base class for all HTTP error responses */
7
- export class MistralGoogleCloudError extends Error {
7
+ export class MistralGCPError extends Error {
8
8
  /** HTTP status code */
9
9
  public readonly statusCode: number;
10
10
  /** HTTP body */
@@ -31,6 +31,6 @@ export class MistralGoogleCloudError extends Error {
31
31
  this.contentType = httpMeta.response.headers.get("content-type") || "";
32
32
  this.rawResponse = httpMeta.response;
33
33
 
34
- this.name = "MistralGoogleCloudError";
34
+ this.name = "MistralGCPError";
35
35
  }
36
36
  }
@@ -4,10 +4,10 @@
4
4
  */
5
5
 
6
6
  import * as z from "zod/v4/core";
7
- import { MistralGoogleCloudError } from "./mistralgoogleclouderror.js";
7
+ import { MistralGCPError } from "./mistralgoogleclouderror.js";
8
8
  import { formatZodError } from "./sdkvalidationerror.js";
9
9
 
10
- export class ResponseValidationError extends MistralGoogleCloudError {
10
+ export class ResponseValidationError extends MistralGCPError {
11
11
  /**
12
12
  * The raw value that failed validation.
13
13
  */
@@ -3,10 +3,10 @@
3
3
  * @generated-id: 8e644875c472
4
4
  */
5
5
 
6
- import { MistralGoogleCloudError } from "./mistralgoogleclouderror.js";
6
+ import { MistralGCPError } from "./mistralgoogleclouderror.js";
7
7
 
8
8
  /** The fallback error class if no more specific error class is matched */
9
- export class SDKError extends MistralGoogleCloudError {
9
+ export class SDKError extends MistralGCPError {
10
10
  constructor(
11
11
  message: string,
12
12
  httpMeta: {
@@ -31,7 +31,7 @@ function getModelInfo(model: string): [string, string] {
31
31
  return [model, modelId];
32
32
  }
33
33
 
34
- export class MistralGoogleCloud extends ClientSDK {
34
+ export class MistralGCP extends ClientSDK {
35
35
  constructor(options: SDKOptions & GoogleCloudOptions = {}) {
36
36
  let projectId = options.projectId ?? "";
37
37
  options.region = options.region ?? "europe-west4";
@@ -47,18 +47,19 @@ export class MistralGoogleCloud extends ClientSDK {
47
47
  options.apiKey = async () => {
48
48
  const authClient = await auth.getClient();
49
49
  const authHeaders = await authClient.getRequestHeaders();
50
- const token = authHeaders["Authorization"];
50
+ const token = authHeaders.get("Authorization");
51
51
  if (!token) {
52
52
  throw new Error("failed to get Google Cloud API key from the default authorization provider, check you are authenticated");
53
53
  }
54
54
 
55
55
  if (!options.projectId) {
56
- if (!authHeaders["x-goog-user-project"]) {
56
+ const userProject = authHeaders.get("x-goog-user-project");
57
+ if (!userProject) {
57
58
  throw new Error(
58
- "no project id available in default google credentials. Please provide a project id in the input arguments to MistralGoogleCloud."
59
+ "no project id available in default google credentials. Please provide a project id in the input arguments to MistralGCP."
59
60
  );
60
61
  }
61
- projectId = authHeaders["x-goog-user-project"];
62
+ projectId = userProject;
62
63
  }
63
64
  return token;
64
65
  }
@@ -1,13 +1,79 @@
1
1
  import { z } from 'zod';
2
+ import { z as zv4 } from 'zod/v4';
2
3
  import { zodToJsonSchema } from "zod-to-json-schema";
3
4
  import { ResponseFormat } from "../models/components/responseformat.js";
4
5
  import * as components from "../models/components/index.js";
5
6
 
7
+ /**
8
+ * Recursively makes a JSON schema strict-mode compatible:
9
+ * - Sets additionalProperties: false on all objects
10
+ * - Makes optional properties required with nullable type
11
+ * Mirrors Python SDK's rec_strict_json_schema + optional handling.
12
+ */
13
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- operating on raw JSON schema objects
14
+ function makeStrictJsonSchema(node: any): any {
15
+ if (typeof node !== 'object' || node === null) return node;
16
+ const result = { ...node };
17
+
18
+ if (result.type === 'object' && result.properties && typeof result.properties === 'object') {
19
+ const required = new Set<string>(Array.isArray(result.required) ? result.required : []);
20
+ const props: Record<string, any> = {};
21
+
22
+ for (const [key, value] of Object.entries(result.properties)) {
23
+ const processed = makeStrictJsonSchema(value);
24
+ if (!required.has(key)) {
25
+ required.add(key);
26
+ if (Array.isArray(processed.type)) {
27
+ if (!processed.type.includes('null')) props[key] = { ...processed, type: [...processed.type, 'null'] };
28
+ else props[key] = processed;
29
+ } else if (Array.isArray(processed.anyOf)) {
30
+ if (!processed.anyOf.some((s: any) => s.type === 'null'))
31
+ props[key] = { ...processed, anyOf: [...processed.anyOf, { type: 'null' }] };
32
+ else props[key] = processed;
33
+ } else if (processed.type) {
34
+ props[key] = { ...processed, type: [processed.type, 'null'] };
35
+ } else {
36
+ props[key] = processed;
37
+ }
38
+ } else {
39
+ props[key] = processed;
40
+ }
41
+ }
42
+
43
+ result.properties = props;
44
+ result.required = [...required];
45
+ result.additionalProperties = false;
46
+ }
47
+
48
+ if (result.items) result.items = makeStrictJsonSchema(result.items);
49
+ for (const key of ['anyOf', 'oneOf', 'allOf']) {
50
+ if (Array.isArray(result[key]))
51
+ result[key] = result[key].map(makeStrictJsonSchema);
52
+ }
53
+ for (const key of ['$defs', 'definitions']) {
54
+ if (result[key] && typeof result[key] === 'object') {
55
+ const defs: Record<string, any> = {};
56
+ for (const [k, v] of Object.entries(result[key]))
57
+ defs[k] = makeStrictJsonSchema(v);
58
+ result[key] = defs;
59
+ }
60
+ }
61
+
62
+ return result;
63
+ }
64
+
6
65
  function toJsonSchema(schema: z.ZodTypeAny): Record<string, unknown> {
7
- if ('toJSONSchema' in z && typeof z.toJSONSchema === 'function') {
8
- return z.toJSONSchema(schema) as Record<string, unknown>;
66
+ let jsonSchema: Record<string, unknown>;
67
+
68
+ // Detect Zod v4 schemas by checking for _zod property (v3 schemas have _def only)
69
+ if ('_zod' in schema) {
70
+ jsonSchema = zv4.toJSONSchema(schema as any) as Record<string, unknown>;
71
+ } else {
72
+ jsonSchema = zodToJsonSchema(schema, { target: "openAi" }) as Record<string, unknown>;
9
73
  }
10
- return zodToJsonSchema(schema) as Record<string, unknown>;
74
+
75
+ delete jsonSchema['$schema'];
76
+ return makeStrictJsonSchema(jsonSchema);
11
77
  }
12
78
 
13
79
  export function transformToChatCompletionRequest<T extends z.ZodTypeAny>(
@@ -0,0 +1,186 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 7964db007a96
4
+ */
5
+
6
+ import { MistralCore } from "../core.js";
7
+ import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { MistralError } from "../models/errors/mistralerror.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+
30
+ /**
31
+ * Get the auth URL for a connector.
32
+ *
33
+ * @remarks
34
+ * Get the OAuth2 authorization URL for a connector to initiate user authentication.
35
+ */
36
+ export function betaConnectorsGetAuthUrl(
37
+ client: MistralCore,
38
+ request: operations.ConnectorGetAuthUrlV1Request,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ components.AuthUrlResponse,
43
+ | errors.HTTPValidationError
44
+ | MistralError
45
+ | ResponseValidationError
46
+ | ConnectionError
47
+ | RequestAbortedError
48
+ | RequestTimeoutError
49
+ | InvalidRequestError
50
+ | UnexpectedClientError
51
+ | SDKValidationError
52
+ >
53
+ > {
54
+ return new APIPromise($do(
55
+ client,
56
+ request,
57
+ options,
58
+ ));
59
+ }
60
+
61
+ async function $do(
62
+ client: MistralCore,
63
+ request: operations.ConnectorGetAuthUrlV1Request,
64
+ options?: RequestOptions,
65
+ ): Promise<
66
+ [
67
+ Result<
68
+ components.AuthUrlResponse,
69
+ | errors.HTTPValidationError
70
+ | MistralError
71
+ | ResponseValidationError
72
+ | ConnectionError
73
+ | RequestAbortedError
74
+ | RequestTimeoutError
75
+ | InvalidRequestError
76
+ | UnexpectedClientError
77
+ | SDKValidationError
78
+ >,
79
+ APICall,
80
+ ]
81
+ > {
82
+ const parsed = safeParse(
83
+ request,
84
+ (value) =>
85
+ operations.ConnectorGetAuthUrlV1Request$outboundSchema.parse(value),
86
+ "Input validation failed",
87
+ );
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = null;
93
+
94
+ const pathParams = {
95
+ connector_id_or_name: encodeSimple(
96
+ "connector_id_or_name",
97
+ payload.connector_id_or_name,
98
+ { explode: false, charEncoding: "percent" },
99
+ ),
100
+ };
101
+
102
+ const path = pathToFunc("/v1/connectors/{connector_id_or_name}/auth_url")(
103
+ pathParams,
104
+ );
105
+
106
+ const query = encodeFormQuery({
107
+ "app_return_url": payload.app_return_url,
108
+ });
109
+
110
+ const headers = new Headers(compactMap({
111
+ Accept: "application/json",
112
+ }));
113
+
114
+ const secConfig = await extractSecurity(client._options.apiKey);
115
+ const securityInput = secConfig == null ? {} : { apiKey: secConfig };
116
+ const requestSecurity = resolveGlobalSecurity(securityInput);
117
+
118
+ const context = {
119
+ options: client._options,
120
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
121
+ operationID: "connector_get_auth_url_v1",
122
+ oAuth2Scopes: null,
123
+
124
+ resolvedSecurity: requestSecurity,
125
+
126
+ securitySource: client._options.apiKey,
127
+ retryConfig: options?.retries
128
+ || client._options.retryConfig
129
+ || { strategy: "none" },
130
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
131
+ };
132
+
133
+ const requestRes = client._createRequest(context, {
134
+ security: requestSecurity,
135
+ method: "GET",
136
+ baseURL: options?.serverURL,
137
+ path: path,
138
+ headers: headers,
139
+ query: query,
140
+ body: body,
141
+ userAgent: client._options.userAgent,
142
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
143
+ }, options);
144
+ if (!requestRes.ok) {
145
+ return [requestRes, { status: "invalid" }];
146
+ }
147
+ const req = requestRes.value;
148
+
149
+ const doResult = await client._do(req, {
150
+ context,
151
+ errorCodes: ["422", "4XX", "5XX"],
152
+ retryConfig: context.retryConfig,
153
+ retryCodes: context.retryCodes,
154
+ });
155
+ if (!doResult.ok) {
156
+ return [doResult, { status: "request-error", request: req }];
157
+ }
158
+ const response = doResult.value;
159
+
160
+ const responseFields = {
161
+ HttpMeta: { Response: response, Request: req },
162
+ };
163
+
164
+ const [result] = await M.match<
165
+ components.AuthUrlResponse,
166
+ | errors.HTTPValidationError
167
+ | MistralError
168
+ | ResponseValidationError
169
+ | ConnectionError
170
+ | RequestAbortedError
171
+ | RequestTimeoutError
172
+ | InvalidRequestError
173
+ | UnexpectedClientError
174
+ | SDKValidationError
175
+ >(
176
+ M.json(200, components.AuthUrlResponse$inboundSchema),
177
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
178
+ M.fail("4XX"),
179
+ M.fail("5XX"),
180
+ )(response, req, { extraFields: responseFields });
181
+ if (!result.ok) {
182
+ return [result, { status: "complete", request: req, response }];
183
+ }
184
+
185
+ return [result, { status: "complete", request: req, response }];
186
+ }