@thalam/ai-sdk-provider 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,15 @@
1
+ Apache License 2.0
2
+
3
+ Copyright 2026 thalam.
4
+
5
+ Licensed under the Apache License, Version 2.0 (the "License");
6
+ you may not use this file except in compliance with the License.
7
+ You may obtain a copy of the License at
8
+
9
+ http://www.apache.org/licenses/LICENSE-2.0
10
+
11
+ Unless required by applicable law or agreed to in writing, software
12
+ distributed under the License is distributed on an "AS IS" BASIS,
13
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ See the License for the specific language governing permissions and
15
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # @thalam/ai-sdk-provider
2
+
3
+ [Vercel AI SDK](https://ai-sdk.dev) provider for **thalam.** — one OpenAI-compatible endpoint for every leading AI model.
4
+
5
+ Built in the UAE. Text, image, and video models from a single endpoint, with per-key spend caps and audit logs as a built-in governance layer.
6
+
7
+ - **One endpoint** — DeepSeek, Qwen, Kimi, GLM, MiniMax, Claude, GPT, Llama, Grok, Mistral and more
8
+ - **Drop-in OpenAI compatibility** — every Vercel AI SDK feature works unchanged
9
+ - **Pay per token** — no subscription, no minimums
10
+ - **AED or USD invoicing** on Enterprise contracts
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install @thalam/ai-sdk-provider ai
16
+ # or: pnpm add @thalam/ai-sdk-provider ai
17
+ # or: yarn add @thalam/ai-sdk-provider ai
18
+ ```
19
+
20
+ Sign up at [thalam.ai](https://www.thalam.ai) — new accounts get **$1 in starter credit** to test, then pay as you go.
21
+
22
+ ## Quickstart
23
+
24
+ ```ts
25
+ import { thalam } from '@thalam/ai-sdk-provider';
26
+ import { generateText } from 'ai';
27
+
28
+ const { text } = await generateText({
29
+ model: thalam('deepseek/deepseek-v3.2'),
30
+ prompt: 'Explain quantum entanglement in 2 sentences.',
31
+ });
32
+
33
+ console.log(text);
34
+ ```
35
+
36
+ Set `THALAM_API_KEY` in your environment, or pass `apiKey` explicitly:
37
+
38
+ ```ts
39
+ import { createThalam } from '@thalam/ai-sdk-provider';
40
+
41
+ const thalam = createThalam({
42
+ apiKey: process.env.THALAM_API_KEY,
43
+ });
44
+ ```
45
+
46
+ ## Streaming
47
+
48
+ ```ts
49
+ import { thalam } from '@thalam/ai-sdk-provider';
50
+ import { streamText } from 'ai';
51
+
52
+ const result = streamText({
53
+ model: thalam('qwen/qwen3-max'),
54
+ prompt: 'Write a haiku about Dubai.',
55
+ });
56
+
57
+ for await (const chunk of result.textStream) {
58
+ process.stdout.write(chunk);
59
+ }
60
+ ```
61
+
62
+ ## Tool calling
63
+
64
+ ```ts
65
+ import { thalam } from '@thalam/ai-sdk-provider';
66
+ import { generateText, tool } from 'ai';
67
+ import { z } from 'zod';
68
+
69
+ const { text } = await generateText({
70
+ model: thalam('deepseek/deepseek-v4-pro'),
71
+ tools: {
72
+ weather: tool({
73
+ description: 'Get the weather in a city',
74
+ parameters: z.object({ city: z.string() }),
75
+ execute: async ({ city }) => ({ temp: 32, unit: 'C', city }),
76
+ }),
77
+ },
78
+ prompt: 'What is the weather in Dubai?',
79
+ });
80
+ ```
81
+
82
+ ## Structured outputs (with Zod)
83
+
84
+ ```ts
85
+ import { thalam } from '@thalam/ai-sdk-provider';
86
+ import { generateObject } from 'ai';
87
+ import { z } from 'zod';
88
+
89
+ const { object } = await generateObject({
90
+ model: thalam('deepseek/deepseek-v3.2'),
91
+ schema: z.object({
92
+ title: z.string(),
93
+ tags: z.array(z.string()),
94
+ }),
95
+ prompt: 'Generate metadata for a blog post about MENA fintech.',
96
+ });
97
+ ```
98
+
99
+ ## Available models
100
+
101
+ The full live catalog is at [thalam.ai/models](https://www.thalam.ai/models) or via:
102
+
103
+ ```ts
104
+ const res = await fetch('https://api.thalam.ai/v1/models', {
105
+ headers: { Authorization: `Bearer ${process.env.THALAM_API_KEY}` },
106
+ });
107
+ const { data } = await res.json();
108
+ ```
109
+
110
+ Common text-model IDs (exported as constants for editor auto-complete):
111
+
112
+ | Constant | ID |
113
+ |---------------------------|-----------------------------------------------|
114
+ | `deepseekV4Pro` | `deepseek/deepseek-v4-pro` |
115
+ | `deepseekV4Flash` | `deepseek/deepseek-v4-flash` |
116
+ | `deepseekV3_2` | `deepseek/deepseek-v3.2` |
117
+ | `deepseekR1_0528` | `deepseek/deepseek-r1-0528` |
118
+ | `qwen3Max` | `qwen/qwen3-max` |
119
+ | `qwen3_5_397B` | `qwen/qwen3.5-397b-a17b` |
120
+ | `qwen3Coder480B` | `qwen/qwen3-coder-480b-a35b-instruct` |
121
+ | `glm5_1` | `zhipu/glm-5.1` |
122
+ | `kimiK2Thinking` | `moonshotai/kimi-k2-thinking` |
123
+ | `kimiK2_5` | `moonshotai/kimi-k2.5` |
124
+ | `claudeOpus4_8` | `anthropic/claude-opus-4.8` |
125
+ | `claudeOpus4_7` | `anthropic/claude-opus-4.7` |
126
+ | `claudeSonnet4_6` | `anthropic/claude-sonnet-4.6` |
127
+ | `gpt5_4` | `openai/gpt-5.4` |
128
+ | `grok4` | `xai/grok-4` |
129
+ | `llama3_3_70B` | `meta-llama/llama-3.3-70b-instruct` |
130
+
131
+ ```ts
132
+ import { thalam, ThalamChatModelIds } from '@thalam/ai-sdk-provider';
133
+
134
+ const model = thalam(ThalamChatModelIds.deepseekV4Pro);
135
+ ```
136
+
137
+ ## Configuration
138
+
139
+ ```ts
140
+ import { createThalam } from '@thalam/ai-sdk-provider';
141
+
142
+ const thalam = createThalam({
143
+ apiKey: process.env.THALAM_API_KEY, // default: env THALAM_API_KEY
144
+ baseURL: 'https://api.thalam.ai/v1', // default
145
+ name: 'thalam', // shown in error messages
146
+ headers: { 'X-Custom': '...' }, // optional extra headers
147
+ fetch: globalThis.fetch, // override (for testing)
148
+ });
149
+ ```
150
+
151
+ ## Links
152
+
153
+ - [thalam.ai](https://www.thalam.ai)
154
+ - [Documentation](https://www.thalam.ai/docs)
155
+ - [Model catalog](https://www.thalam.ai/models)
156
+ - [Pricing](https://www.thalam.ai/pricing)
157
+ - [Vercel AI SDK](https://ai-sdk.dev)
158
+
159
+ ## License
160
+
161
+ Apache-2.0
@@ -0,0 +1,104 @@
1
+ import { OpenAICompatibleProviderSettings, OpenAICompatibleProvider } from '@ai-sdk/openai-compatible';
2
+
3
+ /**
4
+ * @thalam/ai-sdk-provider
5
+ *
6
+ * Vercel AI SDK provider for thalam. — one OpenAI-compatible endpoint
7
+ * for every leading AI model (text, image, video).
8
+ *
9
+ * Wraps `@ai-sdk/openai-compatible` and points it at `https://api.thalam.ai/v1`.
10
+ *
11
+ * Usage:
12
+ * import { thalam } from '@thalam/ai-sdk-provider';
13
+ * import { generateText } from 'ai';
14
+ *
15
+ * const { text } = await generateText({
16
+ * model: thalam('deepseek/deepseek-v3.2'),
17
+ * prompt: 'Hello',
18
+ * });
19
+ *
20
+ * Configuration:
21
+ * THALAM_API_KEY — env var read by default
22
+ * apiKey — pass to createThalam() to override
23
+ * baseURL — pass to createThalam() if you're using a self-hosted gateway
24
+ */
25
+
26
+ /**
27
+ * Options accepted by `createThalam`. All optional — defaults pick up
28
+ * the API key from `process.env.THALAM_API_KEY`.
29
+ */
30
+ interface ThalamProviderSettings extends Omit<OpenAICompatibleProviderSettings, 'baseURL' | 'apiKey' | 'name'> {
31
+ /** API key. Defaults to `process.env.THALAM_API_KEY`. */
32
+ apiKey?: string;
33
+ /** Override base URL (use for self-hosted / staging only). */
34
+ baseURL?: string;
35
+ /** Provider name shown in error messages. Default: 'thalam'. */
36
+ name?: string;
37
+ }
38
+ /**
39
+ * Common thalam. model IDs surfaced as constants for editor auto-complete.
40
+ * You can still pass any string ID — this is just a hint list. Visit
41
+ * https://www.thalam.ai/models for the live catalog or call `GET /v1/models`.
42
+ */
43
+ declare const ThalamChatModelIds: {
44
+ readonly deepseekV4Pro: "deepseek/deepseek-v4-pro";
45
+ readonly deepseekV4Flash: "deepseek/deepseek-v4-flash";
46
+ readonly deepseekV3_2: "deepseek/deepseek-v3.2";
47
+ readonly deepseekV3_1Terminus: "deepseek/deepseek-v3.1-terminus";
48
+ readonly deepseekR1_0528: "deepseek/deepseek-r1-0528";
49
+ readonly qwen3Max: "qwen/qwen3-max";
50
+ readonly qwen3_5_397B: "qwen/qwen3.5-397b-a17b";
51
+ readonly qwen3_5_122B: "qwen/qwen3.5-122b-a10b";
52
+ readonly qwen3Coder480B: "qwen/qwen3-coder-480b-a35b-instruct";
53
+ readonly qwen3Coder30B: "qwen/qwen3-coder-30b-a3b-instruct";
54
+ readonly qwen3CoderNext: "qwen/qwen3-coder-next";
55
+ readonly glm5: "zhipu/glm-5";
56
+ readonly glm5_1: "zhipu/glm-5.1";
57
+ readonly glm4_6V: "zhipu/glm-4.6v";
58
+ readonly kimiK2Thinking: "moonshotai/kimi-k2-thinking";
59
+ readonly kimiK2_5: "moonshotai/kimi-k2.5";
60
+ readonly miniMaxM2_7: "minimax/minimax-m2.7";
61
+ readonly miniMaxM2_5: "minimax/minimax-m2.5";
62
+ readonly gpt5_4: "openai/gpt-5.4";
63
+ readonly gpt5Mini: "openai/gpt-5-mini";
64
+ readonly gptOss120B: "openai/gpt-oss-120b";
65
+ readonly claudeOpus4_8: "anthropic/claude-opus-4.8";
66
+ readonly claudeOpus4_7: "anthropic/claude-opus-4.7";
67
+ readonly claudeSonnet4_6: "anthropic/claude-sonnet-4.6";
68
+ readonly grok4: "xai/grok-4";
69
+ readonly llama3_3_70B: "meta-llama/llama-3.3-70b-instruct";
70
+ readonly llama4Maverick: "meta-llama/llama-4-maverick-17b-128e-instruct-fp8";
71
+ readonly llama4Scout: "meta-llama/llama-4-scout-17b-16e-instruct";
72
+ readonly mistralNemo: "mistralai/mistral-nemo";
73
+ readonly gemma4_31B: "google/gemma-4-31b-it";
74
+ };
75
+ type ThalamChatModelId = (typeof ThalamChatModelIds)[keyof typeof ThalamChatModelIds] | (string & {});
76
+ /**
77
+ * Create a thalam. provider instance.
78
+ *
79
+ * @example
80
+ * import { createThalam } from '@thalam/ai-sdk-provider';
81
+ * const thalam = createThalam({ apiKey: 'tl-...' });
82
+ * const model = thalam('deepseek/deepseek-v3.2');
83
+ *
84
+ * @example
85
+ * // Using the default export (reads THALAM_API_KEY from env)
86
+ * import { thalam } from '@thalam/ai-sdk-provider';
87
+ * const model = thalam('qwen/qwen3-max');
88
+ */
89
+ declare function createThalam(options?: ThalamProviderSettings): OpenAICompatibleProvider<ThalamChatModelId, string, string, string>;
90
+ /**
91
+ * Default provider instance. Reads `THALAM_API_KEY` from the environment.
92
+ *
93
+ * @example
94
+ * import { thalam } from '@thalam/ai-sdk-provider';
95
+ * import { generateText } from 'ai';
96
+ *
97
+ * const { text } = await generateText({
98
+ * model: thalam('deepseek/deepseek-v3.2'),
99
+ * prompt: 'Explain quantum entanglement in 2 sentences.',
100
+ * });
101
+ */
102
+ declare const thalam: OpenAICompatibleProvider<ThalamChatModelId, string, string, string>;
103
+
104
+ export { type ThalamChatModelId, ThalamChatModelIds, type ThalamProviderSettings, createThalam, thalam };
package/dist/index.js ADDED
@@ -0,0 +1,69 @@
1
+ // src/index.ts
2
+ import {
3
+ createOpenAICompatible
4
+ } from "@ai-sdk/openai-compatible";
5
+ var DEFAULT_BASE_URL = "https://api.thalam.ai/v1";
6
+ var DEFAULT_NAME = "thalam";
7
+ var ThalamChatModelIds = {
8
+ // DeepSeek
9
+ deepseekV4Pro: "deepseek/deepseek-v4-pro",
10
+ deepseekV4Flash: "deepseek/deepseek-v4-flash",
11
+ deepseekV3_2: "deepseek/deepseek-v3.2",
12
+ deepseekV3_1Terminus: "deepseek/deepseek-v3.1-terminus",
13
+ deepseekR1_0528: "deepseek/deepseek-r1-0528",
14
+ // Qwen
15
+ qwen3Max: "qwen/qwen3-max",
16
+ qwen3_5_397B: "qwen/qwen3.5-397b-a17b",
17
+ qwen3_5_122B: "qwen/qwen3.5-122b-a10b",
18
+ qwen3Coder480B: "qwen/qwen3-coder-480b-a35b-instruct",
19
+ qwen3Coder30B: "qwen/qwen3-coder-30b-a3b-instruct",
20
+ qwen3CoderNext: "qwen/qwen3-coder-next",
21
+ // GLM
22
+ glm5: "zhipu/glm-5",
23
+ glm5_1: "zhipu/glm-5.1",
24
+ glm4_6V: "zhipu/glm-4.6v",
25
+ // Kimi
26
+ kimiK2Thinking: "moonshotai/kimi-k2-thinking",
27
+ kimiK2_5: "moonshotai/kimi-k2.5",
28
+ // MiniMax
29
+ miniMaxM2_7: "minimax/minimax-m2.7",
30
+ miniMaxM2_5: "minimax/minimax-m2.5",
31
+ // OpenAI
32
+ gpt5_4: "openai/gpt-5.4",
33
+ gpt5Mini: "openai/gpt-5-mini",
34
+ gptOss120B: "openai/gpt-oss-120b",
35
+ // Anthropic
36
+ claudeOpus4_8: "anthropic/claude-opus-4.8",
37
+ claudeOpus4_7: "anthropic/claude-opus-4.7",
38
+ claudeSonnet4_6: "anthropic/claude-sonnet-4.6",
39
+ // xAI
40
+ grok4: "xai/grok-4",
41
+ // Llama
42
+ llama3_3_70B: "meta-llama/llama-3.3-70b-instruct",
43
+ llama4Maverick: "meta-llama/llama-4-maverick-17b-128e-instruct-fp8",
44
+ llama4Scout: "meta-llama/llama-4-scout-17b-16e-instruct",
45
+ // Mistral
46
+ mistralNemo: "mistralai/mistral-nemo",
47
+ // Google
48
+ gemma4_31B: "google/gemma-4-31b-it"
49
+ };
50
+ function createThalam(options = {}) {
51
+ const apiKey = options.apiKey ?? (typeof process !== "undefined" ? process.env?.THALAM_API_KEY : void 0);
52
+ return createOpenAICompatible({
53
+ name: options.name ?? DEFAULT_NAME,
54
+ baseURL: options.baseURL ?? DEFAULT_BASE_URL,
55
+ apiKey,
56
+ headers: {
57
+ ...options.headers ?? {},
58
+ "X-Thalam-Provider-SDK": "@thalam/ai-sdk-provider"
59
+ },
60
+ queryParams: options.queryParams,
61
+ fetch: options.fetch
62
+ });
63
+ }
64
+ var thalam = createThalam();
65
+ export {
66
+ ThalamChatModelIds,
67
+ createThalam,
68
+ thalam
69
+ };
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@thalam/ai-sdk-provider",
3
+ "version": "0.1.0",
4
+ "description": "Vercel AI SDK provider for thalam. — one OpenAI-compatible endpoint for every leading AI model (text, image, video).",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "module": "./dist/index.js",
9
+ "types": "./dist/index.d.ts",
10
+ "exports": {
11
+ ".": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "README.md",
19
+ "LICENSE"
20
+ ],
21
+ "publishConfig": {
22
+ "access": "public"
23
+ },
24
+ "scripts": {
25
+ "build": "tsup src/index.ts --format esm --dts --clean",
26
+ "test": "node --experimental-vm-modules tests/smoke.test.mjs"
27
+ },
28
+ "keywords": [
29
+ "ai",
30
+ "ai-sdk",
31
+ "vercel",
32
+ "thalam",
33
+ "openai-compatible",
34
+ "llm",
35
+ "gateway"
36
+ ],
37
+ "homepage": "https://www.thalam.ai",
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/thalam-ai/ai-sdk-provider.git"
41
+ },
42
+ "bugs": {
43
+ "url": "https://github.com/thalam-ai/ai-sdk-provider/issues"
44
+ },
45
+ "author": "thalam. <press@thalam.ai>",
46
+ "engines": {
47
+ "node": ">=18"
48
+ },
49
+ "peerDependencies": {
50
+ "ai": "^5.0.0 || ^6.0.0",
51
+ "zod": "^3.0.0"
52
+ },
53
+ "peerDependenciesMeta": {
54
+ "ai": { "optional": false }
55
+ },
56
+ "dependencies": {
57
+ "@ai-sdk/openai-compatible": "^2.0.0",
58
+ "@ai-sdk/provider": "^3.0.0",
59
+ "@ai-sdk/provider-utils": "^4.0.0"
60
+ },
61
+ "devDependencies": {
62
+ "tsup": "^8.0.0",
63
+ "typescript": "^5.0.0",
64
+ "zod": "^3.23.0"
65
+ }
66
+ }