@commoncompute/vercel-ai 0.1.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Common Compute, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # @commoncompute/vercel-ai
2
+
3
+ Vercel AI SDK provider for [Common Compute](https://commoncompute.ai).
4
+
5
+ ```bash
6
+ npm install @commoncompute/vercel-ai @ai-sdk/openai-compatible ai
7
+ ```
8
+
9
+ ```ts
10
+ import { createCommonCompute } from "@commoncompute/vercel-ai";
11
+ import { streamText } from "ai";
12
+
13
+ const cc = createCommonCompute({ apiKey: process.env.CC_API_KEY });
14
+
15
+ const result = await streamText({
16
+ model: cc("qwen-2.5-7b"),
17
+ messages: [{ role: "user", content: "hi" }],
18
+ });
19
+ for await (const delta of result.textStream) process.stdout.write(delta);
20
+ ```
21
+
22
+ Under the hood this delegates to `@ai-sdk/openai-compatible` (or `@ai-sdk/openai` as a fallback) pointed at `https://api.commoncompute.ai/v1`, so every AI SDK feature — streaming, tool calls, structured output, UI hooks — works out of the box.
23
+
24
+ Set `CC_API_KEY` in your environment or pass `apiKey` at construction.
package/dist/index.cjs ADDED
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ createCommonCompute: () => createCommonCompute,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var import_node_module = require("module");
28
+ var import_meta = {};
29
+ function createCommonCompute(opts = {}) {
30
+ const apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env.CC_API_KEY : void 0);
31
+ if (!apiKey) {
32
+ throw new Error("createCommonCompute: apiKey is required (or set CC_API_KEY).");
33
+ }
34
+ const baseURL = (opts.baseURL ?? (typeof process !== "undefined" ? process.env.CC_BASE_URL : void 0) ?? "https://api.commoncompute.ai") + "/v1";
35
+ const headers = opts.org || opts.headers ? { ...opts.headers ?? {}, ...opts.org ? { "X-CC-Org": opts.org } : {} } : void 0;
36
+ return (modelId) => {
37
+ const req = (0, import_node_module.createRequire)(typeof __filename === "string" ? __filename : import_meta.url);
38
+ let createOpenAICompatible;
39
+ try {
40
+ createOpenAICompatible = req("@ai-sdk/openai-compatible").createOpenAICompatible;
41
+ } catch {
42
+ try {
43
+ const { createOpenAI } = req("@ai-sdk/openai");
44
+ const openai = createOpenAI({ apiKey, baseURL, headers, fetch: opts.fetch });
45
+ return typeof openai.chat === "function" ? openai.chat(modelId) : openai(modelId);
46
+ } catch {
47
+ throw new Error(
48
+ "Vercel AI provider missing. Install one of: `@ai-sdk/openai-compatible` or `@ai-sdk/openai`."
49
+ );
50
+ }
51
+ }
52
+ const provider = createOpenAICompatible({
53
+ name: "commoncompute",
54
+ apiKey,
55
+ baseURL,
56
+ headers,
57
+ fetch: opts.fetch
58
+ });
59
+ return provider.chatModel(modelId);
60
+ };
61
+ }
62
+ var index_default = createCommonCompute;
63
+ // Annotate the CommonJS export names for ESM import in node:
64
+ 0 && (module.exports = {
65
+ createCommonCompute
66
+ });
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Vercel AI SDK provider for Common Compute.
3
+ *
4
+ * Minimal wrapper: delegates to Common Compute's OpenAI-compatible
5
+ * `/v1/chat/completions`. For the full AI SDK experience use the AI
6
+ * SDK's OpenAI provider pointed at our base URL — this package is a
7
+ * convenience wrapper so consumers don't have to remember the URL.
8
+ *
9
+ * import { createCommonCompute } from "@commoncompute/vercel-ai";
10
+ * import { streamText } from "ai";
11
+ *
12
+ * const cc = createCommonCompute({ apiKey: process.env.CC_API_KEY });
13
+ * const result = await streamText({
14
+ * model: cc("qwen-2.5-7b"),
15
+ * messages: [{ role: "user", content: "hi" }],
16
+ * });
17
+ * for await (const delta of result.textStream) process.stdout.write(delta);
18
+ */
19
+ interface CreateCommonComputeOptions {
20
+ apiKey?: string;
21
+ baseURL?: string;
22
+ org?: string;
23
+ /** Extra headers sent with every request. */
24
+ headers?: Record<string, string>;
25
+ /** Custom fetch implementation (testing / proxies). */
26
+ fetch?: typeof globalThis.fetch;
27
+ }
28
+ /**
29
+ * Returns a function that, given a model id, yields a LanguageModelV1
30
+ * compatible instance by deferring to the AI SDK's `openai` provider
31
+ * configured with Common Compute's base URL. This keeps us feature-
32
+ * parity with any upstream improvements to OpenAI's provider without
33
+ * having to maintain our own streaming + tool-calling implementation.
34
+ */
35
+ declare function createCommonCompute(opts?: CreateCommonComputeOptions): (modelId: string) => any;
36
+
37
+ export { type CreateCommonComputeOptions, createCommonCompute, createCommonCompute as default };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Vercel AI SDK provider for Common Compute.
3
+ *
4
+ * Minimal wrapper: delegates to Common Compute's OpenAI-compatible
5
+ * `/v1/chat/completions`. For the full AI SDK experience use the AI
6
+ * SDK's OpenAI provider pointed at our base URL — this package is a
7
+ * convenience wrapper so consumers don't have to remember the URL.
8
+ *
9
+ * import { createCommonCompute } from "@commoncompute/vercel-ai";
10
+ * import { streamText } from "ai";
11
+ *
12
+ * const cc = createCommonCompute({ apiKey: process.env.CC_API_KEY });
13
+ * const result = await streamText({
14
+ * model: cc("qwen-2.5-7b"),
15
+ * messages: [{ role: "user", content: "hi" }],
16
+ * });
17
+ * for await (const delta of result.textStream) process.stdout.write(delta);
18
+ */
19
+ interface CreateCommonComputeOptions {
20
+ apiKey?: string;
21
+ baseURL?: string;
22
+ org?: string;
23
+ /** Extra headers sent with every request. */
24
+ headers?: Record<string, string>;
25
+ /** Custom fetch implementation (testing / proxies). */
26
+ fetch?: typeof globalThis.fetch;
27
+ }
28
+ /**
29
+ * Returns a function that, given a model id, yields a LanguageModelV1
30
+ * compatible instance by deferring to the AI SDK's `openai` provider
31
+ * configured with Common Compute's base URL. This keeps us feature-
32
+ * parity with any upstream improvements to OpenAI's provider without
33
+ * having to maintain our own streaming + tool-calling implementation.
34
+ */
35
+ declare function createCommonCompute(opts?: CreateCommonComputeOptions): (modelId: string) => any;
36
+
37
+ export { type CreateCommonComputeOptions, createCommonCompute, createCommonCompute as default };
package/dist/index.js ADDED
@@ -0,0 +1,40 @@
1
+ // src/index.ts
2
+ import { createRequire } from "module";
3
+ function createCommonCompute(opts = {}) {
4
+ const apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env.CC_API_KEY : void 0);
5
+ if (!apiKey) {
6
+ throw new Error("createCommonCompute: apiKey is required (or set CC_API_KEY).");
7
+ }
8
+ const baseURL = (opts.baseURL ?? (typeof process !== "undefined" ? process.env.CC_BASE_URL : void 0) ?? "https://api.commoncompute.ai") + "/v1";
9
+ const headers = opts.org || opts.headers ? { ...opts.headers ?? {}, ...opts.org ? { "X-CC-Org": opts.org } : {} } : void 0;
10
+ return (modelId) => {
11
+ const req = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
12
+ let createOpenAICompatible;
13
+ try {
14
+ createOpenAICompatible = req("@ai-sdk/openai-compatible").createOpenAICompatible;
15
+ } catch {
16
+ try {
17
+ const { createOpenAI } = req("@ai-sdk/openai");
18
+ const openai = createOpenAI({ apiKey, baseURL, headers, fetch: opts.fetch });
19
+ return typeof openai.chat === "function" ? openai.chat(modelId) : openai(modelId);
20
+ } catch {
21
+ throw new Error(
22
+ "Vercel AI provider missing. Install one of: `@ai-sdk/openai-compatible` or `@ai-sdk/openai`."
23
+ );
24
+ }
25
+ }
26
+ const provider = createOpenAICompatible({
27
+ name: "commoncompute",
28
+ apiKey,
29
+ baseURL,
30
+ headers,
31
+ fetch: opts.fetch
32
+ });
33
+ return provider.chatModel(modelId);
34
+ };
35
+ }
36
+ var index_default = createCommonCompute;
37
+ export {
38
+ createCommonCompute,
39
+ index_default as default
40
+ };
package/package.json ADDED
@@ -0,0 +1,72 @@
1
+ {
2
+ "name": "@commoncompute/vercel-ai",
3
+ "version": "0.1.0",
4
+ "description": "Vercel AI SDK provider for Common Compute.",
5
+ "license": "MIT",
6
+ "author": "Common Compute <support@commoncompute.ai>",
7
+ "homepage": "https://commoncompute.ai",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/Ikaikaalika/commoncomputeai.git",
11
+ "directory": "packages/integrations-vercel-ai"
12
+ },
13
+ "keywords": [
14
+ "ai",
15
+ "vercel",
16
+ "ai-sdk",
17
+ "provider",
18
+ "llm",
19
+ "openai-compatible",
20
+ "apple-silicon"
21
+ ],
22
+ "type": "module",
23
+ "sideEffects": false,
24
+ "main": "./dist/index.cjs",
25
+ "module": "./dist/index.js",
26
+ "types": "./dist/index.d.ts",
27
+ "exports": {
28
+ ".": {
29
+ "types": "./dist/index.d.ts",
30
+ "import": "./dist/index.js",
31
+ "require": "./dist/index.cjs"
32
+ }
33
+ },
34
+ "files": [
35
+ "dist",
36
+ "src",
37
+ "README.md",
38
+ "LICENSE"
39
+ ],
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "engines": {
44
+ "node": ">=18"
45
+ },
46
+ "peerDependencies": {
47
+ "@ai-sdk/openai-compatible": ">=0.0.1",
48
+ "@ai-sdk/openai": ">=1.0.0"
49
+ },
50
+ "peerDependenciesMeta": {
51
+ "@ai-sdk/openai-compatible": {
52
+ "optional": true
53
+ },
54
+ "@ai-sdk/openai": {
55
+ "optional": true
56
+ }
57
+ },
58
+ "dependencies": {
59
+ "@commoncompute/sdk": "0.1.0"
60
+ },
61
+ "devDependencies": {
62
+ "@ai-sdk/openai-compatible": "^3",
63
+ "@types/node": "^22",
64
+ "tsup": "^8",
65
+ "typescript": "^5.7",
66
+ "vitest": "^2"
67
+ },
68
+ "scripts": {
69
+ "build": "tsup src/index.ts --format esm,cjs --dts --clean --target node18",
70
+ "test": "vitest run"
71
+ }
72
+ }
package/src/index.ts ADDED
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Vercel AI SDK provider for Common Compute.
3
+ *
4
+ * Minimal wrapper: delegates to Common Compute's OpenAI-compatible
5
+ * `/v1/chat/completions`. For the full AI SDK experience use the AI
6
+ * SDK's OpenAI provider pointed at our base URL — this package is a
7
+ * convenience wrapper so consumers don't have to remember the URL.
8
+ *
9
+ * import { createCommonCompute } from "@commoncompute/vercel-ai";
10
+ * import { streamText } from "ai";
11
+ *
12
+ * const cc = createCommonCompute({ apiKey: process.env.CC_API_KEY });
13
+ * const result = await streamText({
14
+ * model: cc("qwen-2.5-7b"),
15
+ * messages: [{ role: "user", content: "hi" }],
16
+ * });
17
+ * for await (const delta of result.textStream) process.stdout.write(delta);
18
+ */
19
+
20
+ import { createRequire } from "node:module";
21
+
22
+ export interface CreateCommonComputeOptions {
23
+ apiKey?: string;
24
+ baseURL?: string;
25
+ org?: string;
26
+ /** Extra headers sent with every request. */
27
+ headers?: Record<string, string>;
28
+ /** Custom fetch implementation (testing / proxies). */
29
+ fetch?: typeof globalThis.fetch;
30
+ }
31
+
32
+ /**
33
+ * Returns a function that, given a model id, yields a LanguageModelV1
34
+ * compatible instance by deferring to the AI SDK's `openai` provider
35
+ * configured with Common Compute's base URL. This keeps us feature-
36
+ * parity with any upstream improvements to OpenAI's provider without
37
+ * having to maintain our own streaming + tool-calling implementation.
38
+ */
39
+ export function createCommonCompute(opts: CreateCommonComputeOptions = {}) {
40
+ const apiKey = opts.apiKey ?? (typeof process !== "undefined" ? process.env.CC_API_KEY : undefined);
41
+ if (!apiKey) {
42
+ throw new Error("createCommonCompute: apiKey is required (or set CC_API_KEY).");
43
+ }
44
+ const baseURL = (opts.baseURL ?? (typeof process !== "undefined" ? process.env.CC_BASE_URL : undefined) ?? "https://api.commoncompute.ai") + "/v1";
45
+ const headers: Record<string, string> | undefined =
46
+ opts.org || opts.headers ? { ...(opts.headers ?? {}), ...(opts.org ? { "X-CC-Org": opts.org } : {}) } : undefined;
47
+
48
+ return (modelId: string) => {
49
+ // Late-load so apps that don't install @ai-sdk/openai-compatible still
50
+ // get a clean error at the call site. This package ships "type":
51
+ // "module", so a bare `require` is undefined in the ESM build — it threw
52
+ // ReferenceError, both catches swallowed it, and the "provider missing"
53
+ // error fired even when the provider WAS installed (2026-07-17 audit).
54
+ // createRequire works in both builds — but the base must be __filename in
55
+ // the CJS build (esbuild shims import.meta to {} there, and
56
+ // createRequire(undefined) throws for every require() consumer).
57
+ const req = createRequire(typeof __filename === "string" ? __filename : import.meta.url);
58
+ let createOpenAICompatible: any;
59
+ try {
60
+ createOpenAICompatible = req("@ai-sdk/openai-compatible").createOpenAICompatible;
61
+ } catch {
62
+ try {
63
+ const { createOpenAI } = req("@ai-sdk/openai");
64
+ // `.chat()` forces the /chat/completions API — newer @ai-sdk/openai
65
+ // versions default `provider(modelId)` to OpenAI's Responses API,
66
+ // which Common Compute does not implement.
67
+ const openai = createOpenAI({ apiKey, baseURL, headers, fetch: opts.fetch });
68
+ return typeof openai.chat === "function" ? openai.chat(modelId) : openai(modelId);
69
+ } catch {
70
+ throw new Error(
71
+ "Vercel AI provider missing. Install one of: `@ai-sdk/openai-compatible` or `@ai-sdk/openai`.",
72
+ );
73
+ }
74
+ }
75
+ const provider = createOpenAICompatible({
76
+ name: "commoncompute",
77
+ apiKey,
78
+ baseURL,
79
+ headers,
80
+ fetch: opts.fetch,
81
+ });
82
+ return provider.chatModel(modelId);
83
+ };
84
+ }
85
+
86
+ export default createCommonCompute;