@blaxel/vercel 0.2.65-dev.77 → 0.2.65-preview.78

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.
package/dist/esm/model.js CHANGED
@@ -8,14 +8,57 @@ import { createOpenAI } from "@ai-sdk/openai";
8
8
  import { createDeepSeek } from "@ai-sdk/deepseek";
9
9
  import { authenticate, getModelMetadata, handleDynamicImportError, settings } from "@blaxel/core";
10
10
  export const blModel = async (model, options) => {
11
- const url = `${settings.runUrl}/${settings.workspace}/models/${model}`;
12
11
  const modelData = await getModelMetadata(model);
13
12
  if (!modelData) {
14
13
  throw new Error(`Model ${model} not found`);
15
14
  }
16
15
  await authenticate();
17
- const type = modelData?.spec.runtime?.type || "openai";
18
16
  const modelId = modelData?.spec.runtime?.model || "gpt-4o";
17
+ // mk3 models use the direct gateway URL and always speak OpenAI-compatible API
18
+ if (modelData.spec.runtime?.generation === "mk3") {
19
+ const gatewayUrl = modelData.metadata.url;
20
+ if (!gatewayUrl) {
21
+ throw new Error(`Model ${model} is mk3 but has no gateway URL in metadata`);
22
+ }
23
+ const mk3Fetch = async (input, init) => {
24
+ await authenticate();
25
+ let existingHeaders = {};
26
+ if (init?.headers) {
27
+ if (init.headers instanceof Headers) {
28
+ init.headers.forEach((value, key) => {
29
+ existingHeaders[key] = value;
30
+ });
31
+ }
32
+ else if (Array.isArray(init.headers)) {
33
+ for (const [key, value] of init.headers) {
34
+ existingHeaders[key] = value;
35
+ }
36
+ }
37
+ else {
38
+ existingHeaders = { ...init.headers };
39
+ }
40
+ }
41
+ delete existingHeaders['authorization'];
42
+ delete existingHeaders['Authorization'];
43
+ const headers = {
44
+ 'Cache-Control': 'no-transform',
45
+ ...existingHeaders,
46
+ ...settings.headers,
47
+ };
48
+ return fetch(input, {
49
+ ...init,
50
+ headers,
51
+ });
52
+ };
53
+ return createOpenAI({
54
+ apiKey: "replaced",
55
+ baseURL: `${gatewayUrl}/v1`,
56
+ fetch: mk3Fetch,
57
+ ...options,
58
+ })(model);
59
+ }
60
+ const url = `${settings.runUrl}/${settings.workspace}/models/${model}`;
61
+ const type = modelData?.spec.runtime?.type || "openai";
19
62
  // Custom fetch function that refreshes authentication on each request
20
63
  const authenticatedFetch = async (input, init) => {
21
64
  await authenticate();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaxel/vercel",
3
- "version": "0.2.65-dev.77",
3
+ "version": "0.2.65-preview.78",
4
4
  "description": "Blaxel SDK for TypeScript",
5
5
  "license": "MIT",
6
6
  "author": "Blaxel, INC (https://blaxel.ai)",
@@ -58,7 +58,7 @@
58
58
  "@ai-sdk/mistral": "^2.0.24",
59
59
  "@ai-sdk/openai": "^2.0.57",
60
60
  "@ai-sdk/provider": "^2.0.0",
61
- "@blaxel/core": "0.2.65-dev.77",
61
+ "@blaxel/core": "0.2.65-preview.78",
62
62
  "ai": "^5.0.82"
63
63
  },
64
64
  "devDependencies": {