@brotu/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/CATALOG.md +387 -0
- package/LICENSE +21 -0
- package/README.md +115 -0
- package/dist/adapters/byteplus.adapter.d.ts +51 -0
- package/dist/adapters/byteplus.adapter.d.ts.map +1 -0
- package/dist/adapters/elevenlabs.adapter.d.ts +48 -0
- package/dist/adapters/elevenlabs.adapter.d.ts.map +1 -0
- package/dist/adapters/estimate.d.ts +10 -0
- package/dist/adapters/estimate.d.ts.map +1 -0
- package/dist/adapters/google.adapter.d.ts +52 -0
- package/dist/adapters/google.adapter.d.ts.map +1 -0
- package/dist/adapters/kling.adapter.d.ts +57 -0
- package/dist/adapters/kling.adapter.d.ts.map +1 -0
- package/dist/adapters/openai.adapter.d.ts +40 -0
- package/dist/adapters/openai.adapter.d.ts.map +1 -0
- package/dist/adapters/qwen.adapter.d.ts +53 -0
- package/dist/adapters/qwen.adapter.d.ts.map +1 -0
- package/dist/catalog.cjs +988 -0
- package/dist/catalog.d.ts +27 -0
- package/dist/catalog.d.ts.map +1 -0
- package/dist/catalog.js +20 -0
- package/dist/chunk-GKLTQ55S.js +1176 -0
- package/dist/client.d.ts +86 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/constants/model.types.d.ts +118 -0
- package/dist/constants/model.types.d.ts.map +1 -0
- package/dist/helpers/result.d.ts +54 -0
- package/dist/helpers/result.d.ts.map +1 -0
- package/dist/index.cjs +3568 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2386 -0
- package/dist/lib/jobs.d.ts +46 -0
- package/dist/lib/jobs.d.ts.map +1 -0
- package/dist/lib/storage.d.ts +33 -0
- package/dist/lib/storage.d.ts.map +1 -0
- package/dist/ports/content-generator.port.d.ts +170 -0
- package/dist/ports/content-generator.port.d.ts.map +1 -0
- package/dist/providers/byteplus.models.d.ts +51 -0
- package/dist/providers/byteplus.models.d.ts.map +1 -0
- package/dist/providers/elevenlabs.models.d.ts +27 -0
- package/dist/providers/elevenlabs.models.d.ts.map +1 -0
- package/dist/providers/google.models.d.ts +42 -0
- package/dist/providers/google.models.d.ts.map +1 -0
- package/dist/providers/kling.models.d.ts +159 -0
- package/dist/providers/kling.models.d.ts.map +1 -0
- package/dist/providers/openai.models.d.ts +27 -0
- package/dist/providers/openai.models.d.ts.map +1 -0
- package/dist/providers/qwen.models.d.ts +88 -0
- package/dist/providers/qwen.models.d.ts.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/package.json +72 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { AIModelConfig } from "../constants/model.types";
|
|
2
|
+
/**
|
|
3
|
+
* Qwen Cloud, which is Alibaba's DashScope International underneath — the docs
|
|
4
|
+
* brand it Qwen Cloud but the host, key format and task envelope are DashScope.
|
|
5
|
+
* Confirmed live: the same key authenticates chat there and queues video, and a
|
|
6
|
+
* submitted task returned a playable file.
|
|
7
|
+
*
|
|
8
|
+
* These are the native home of the Wan and HappyHorse families, which this SDK
|
|
9
|
+
* previously reached only through an aggregator.
|
|
10
|
+
*
|
|
11
|
+
* Nearly every field below exists because the same endpoint accepts four
|
|
12
|
+
* incompatible request shapes, discriminated only by the model string.
|
|
13
|
+
*/
|
|
14
|
+
/** How a model wants its reference media passed. */
|
|
15
|
+
export type QwenInputShape =
|
|
16
|
+
/** `input.media[]` of `{type,url}` — wan2.7, happyhorse, wan3.0. */
|
|
17
|
+
"media"
|
|
18
|
+
/** `input.img_url`, a single string — wan2.6 and earlier. */
|
|
19
|
+
| "img_url"
|
|
20
|
+
/** `input.first_frame_url` + `last_frame_url`, on a different path. */
|
|
21
|
+
| "kf2v"
|
|
22
|
+
/** `input.reference_urls[]` of plain strings — wan2.6-r2v. */
|
|
23
|
+
| "reference_urls";
|
|
24
|
+
/** How a model wants its output size expressed. */
|
|
25
|
+
export type QwenSizing =
|
|
26
|
+
/** `parameters.resolution` + `parameters.ratio`. */
|
|
27
|
+
"resolution"
|
|
28
|
+
/** `parameters.size`, as "1280*720" with a literal asterisk. */
|
|
29
|
+
| "size";
|
|
30
|
+
export type QwenMode = "t2v" | "i2v" | "r2v" | "video-edit" | "kf2v";
|
|
31
|
+
export interface QwenVideoBinding {
|
|
32
|
+
mode: QwenMode;
|
|
33
|
+
shape: QwenInputShape;
|
|
34
|
+
sizing: QwenSizing;
|
|
35
|
+
/** Only kf2v leaves the shared video path. */
|
|
36
|
+
path?: string;
|
|
37
|
+
durations?: {
|
|
38
|
+
min: number;
|
|
39
|
+
max: number;
|
|
40
|
+
} | number[];
|
|
41
|
+
resolutions?: string[];
|
|
42
|
+
/** True where DashScope stamps a visible mark unless told not to. */
|
|
43
|
+
watermarkOnByDefault?: boolean;
|
|
44
|
+
}
|
|
45
|
+
export declare const QWEN_VIDEO_MODELS: Record<string, QwenVideoBinding>;
|
|
46
|
+
export declare function videoPathFor(binding: QwenVideoBinding): string;
|
|
47
|
+
/** Which of the three image endpoints a model answers on. */
|
|
48
|
+
export type QwenImagePath = "multimodal" | "image-generation" | "text2image";
|
|
49
|
+
export declare const QWEN_IMAGE_PATHS: Record<QwenImagePath, string>;
|
|
50
|
+
export interface QwenImageBinding {
|
|
51
|
+
/**
|
|
52
|
+
* Whether the model answers inline. This is not a preference: sending
|
|
53
|
+
* `X-DashScope-Async: enable` to a sync-only model returns 429, which reads
|
|
54
|
+
* as rate limiting and never resolves on retry.
|
|
55
|
+
*/
|
|
56
|
+
sync: boolean;
|
|
57
|
+
path: QwenImagePath;
|
|
58
|
+
/** `messages` is the chat-style body; `prompt` is the legacy flat one. */
|
|
59
|
+
body: "messages" | "prompt";
|
|
60
|
+
maxN: number;
|
|
61
|
+
resolutions?: string[];
|
|
62
|
+
}
|
|
63
|
+
export declare const QWEN_IMAGE_MODELS: Record<string, QwenImageBinding>;
|
|
64
|
+
/**
|
|
65
|
+
* Speech. Verified live: these answer inline on the multimodal endpoint and hand
|
|
66
|
+
* back an audio URL with a real `expires_at`, so nothing here is inferred.
|
|
67
|
+
*
|
|
68
|
+
* Billing is per character of input text, which the caller knows before asking —
|
|
69
|
+
* unlike text models, an audio estimate can be exact.
|
|
70
|
+
*/
|
|
71
|
+
export interface QwenVoiceBinding {
|
|
72
|
+
voices: string[];
|
|
73
|
+
/** USD per character. Published as $0.15 per 10K characters. */
|
|
74
|
+
usdPerCharacter: number;
|
|
75
|
+
}
|
|
76
|
+
export declare const QWEN_AUDIO_MODELS: Record<string, QwenVoiceBinding>;
|
|
77
|
+
/**
|
|
78
|
+
* Text, through the OpenAI-compatible surface rather than the native one.
|
|
79
|
+
*
|
|
80
|
+
* Priced per million tokens, and the total depends on how much the model writes
|
|
81
|
+
* back — so an estimate can report the rate but never the bill. The catalog
|
|
82
|
+
* carries the rate; `estimateCost` says so rather than guessing a token count.
|
|
83
|
+
*/
|
|
84
|
+
export declare const QWEN_TEXT_MODELS: Record<string, {
|
|
85
|
+
usdPerMillionOutput: number;
|
|
86
|
+
}>;
|
|
87
|
+
export declare const QWEN_CATALOG: AIModelConfig[];
|
|
88
|
+
//# sourceMappingURL=qwen.models.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"qwen.models.d.ts","sourceRoot":"","sources":["../../src/providers/qwen.models.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAE9D;;;;;;;;;;;GAWG;AAEH,oDAAoD;AACpD,MAAM,MAAM,cAAc;AACzB,oEAAoE;AAClE,OAAO;AACT,6DAA6D;GAC3D,SAAS;AACX,uEAAuE;GACrE,MAAM;AACR,8DAA8D;GAC5D,gBAAgB,CAAC;AAEpB,mDAAmD;AACnD,MAAM,MAAM,UAAU;AACrB,oDAAoD;AAClD,YAAY;AACd,gEAAgE;GAC9D,MAAM,CAAC;AAEV,MAAM,MAAM,QAAQ,GAAG,KAAK,GAAG,KAAK,GAAG,KAAK,GAAG,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CAAC;AAEF;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE;IAAE,mBAAmB,EAAE,MAAM,CAAA;CAAE,CAQ3E,CAAC;AAuBH,eAAO,MAAM,YAAY,EAAE,aAAa,EA2EvC,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import type { AIModelConfig } from "./constants/model.types";
|
|
2
|
+
import type { S3StorageConfig } from "./lib/storage";
|
|
3
|
+
export interface ProviderConfig {
|
|
4
|
+
apiKey: string;
|
|
5
|
+
/** Defaults to the known base URL for the provider, when there is one. */
|
|
6
|
+
baseUrl?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ReferenceVideoInfo {
|
|
9
|
+
durationSeconds?: number;
|
|
10
|
+
width?: number;
|
|
11
|
+
height?: number;
|
|
12
|
+
}
|
|
13
|
+
export interface BrotuAIOptions {
|
|
14
|
+
/** Provider keys the caller owns. Keys are provider ids used by the catalog. */
|
|
15
|
+
providers: Record<string, ProviderConfig>;
|
|
16
|
+
/** Provider used by catalog entries that do not declare one. Defaults to "kie". */
|
|
17
|
+
defaultProvider?: string;
|
|
18
|
+
/**
|
|
19
|
+
* Turn a private reference URL into one the provider can fetch.
|
|
20
|
+
* ponytail: identity by default — the SDK has no storage of its own.
|
|
21
|
+
*/
|
|
22
|
+
resolveUrl?: (url: string) => Promise<string>;
|
|
23
|
+
/**
|
|
24
|
+
* Read duration/dimensions off a reference video. Only reference-video billing
|
|
25
|
+
* needs it; without it those models bill at their declared default.
|
|
26
|
+
* ponytail: undefined by default, wire ffmpeg here if you need exact billing.
|
|
27
|
+
*/
|
|
28
|
+
probeVideo?: (url: string) => Promise<ReferenceVideoInfo>;
|
|
29
|
+
/**
|
|
30
|
+
* An S3-compatible bucket of your own. Configure it and the SDK uploads
|
|
31
|
+
* references for you and copies finished outputs off the providers' expiring
|
|
32
|
+
* URLs. `uploadImage` below is derived from it unless you pass your own.
|
|
33
|
+
*/
|
|
34
|
+
storage?: S3StorageConfig;
|
|
35
|
+
/**
|
|
36
|
+
* Store a buffer and return a URL the provider can fetch. Overrides `storage`.
|
|
37
|
+
* Only reference-image cropping needs it; without either, cropping is skipped.
|
|
38
|
+
*/
|
|
39
|
+
uploadImage?: (buffer: Buffer, filename: string, mimeType: string) => Promise<string>;
|
|
40
|
+
/**
|
|
41
|
+
* Voice used when an ElevenLabs request names none. Their API has no default
|
|
42
|
+
* voice, and ids are account-specific — `listVoices()` on the adapter finds
|
|
43
|
+
* yours.
|
|
44
|
+
*/
|
|
45
|
+
elevenLabsVoiceId?: string;
|
|
46
|
+
/** Extra models, or overrides of built-in ones, merged by id. */
|
|
47
|
+
models?: AIModelConfig[];
|
|
48
|
+
}
|
|
49
|
+
/** Resolved per-request routing: which host and key serve this model. */
|
|
50
|
+
export interface ResolvedProvider {
|
|
51
|
+
id: string;
|
|
52
|
+
apiKey: string;
|
|
53
|
+
baseUrl: string;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAErD,MAAM,WAAW,cAAc;IAC9B,MAAM,EAAE,MAAM,CAAC;IACf,0EAA0E;IAC1E,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,kBAAkB;IAClC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,cAAc;IAC9B,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IAC1C,mFAAmF;IACnF,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IAC9C;;;;OAIG;IACH,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC1D;;;;OAIG;IACH,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B;;;OAGG;IACH,WAAW,CAAC,EAAE,CACb,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,KACZ,OAAO,CAAC,MAAM,CAAC,CAAC;IACrB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,iEAAiE;IACjE,MAAM,CAAC,EAAE,aAAa,EAAE,CAAC;CACzB;AAED,yEAAyE;AACzE,MAAM,WAAW,gBAAgB;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CAChB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@brotu/ai",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"import": "./dist/index.js",
|
|
10
|
+
"require": "./dist/index.cjs"
|
|
11
|
+
},
|
|
12
|
+
"./catalog": {
|
|
13
|
+
"types": "./dist/catalog.d.ts",
|
|
14
|
+
"import": "./dist/catalog.js",
|
|
15
|
+
"require": "./dist/catalog.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"lint": "bunx --bun biome lint src",
|
|
21
|
+
"format": "bunx --bun biome format --write src",
|
|
22
|
+
"docs:catalog": "bun run scripts/generate-catalog-doc.ts",
|
|
23
|
+
"build": "tsup && tsc -p tsconfig.build.json",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"test": "bun test",
|
|
26
|
+
"gate": "bun run scripts/gate.ts",
|
|
27
|
+
"prepublishOnly": "bun run gate && bun run build",
|
|
28
|
+
"docs:json": "bun run scripts/generate-catalog-json.ts",
|
|
29
|
+
"docs": "bun run docs:catalog && bun run docs:json"
|
|
30
|
+
},
|
|
31
|
+
"peerDependencies": {
|
|
32
|
+
"@aws-sdk/client-s3": "^3",
|
|
33
|
+
"@aws-sdk/s3-request-presigner": "^3"
|
|
34
|
+
},
|
|
35
|
+
"peerDependenciesMeta": {
|
|
36
|
+
"@aws-sdk/client-s3": {
|
|
37
|
+
"optional": true
|
|
38
|
+
},
|
|
39
|
+
"@aws-sdk/s3-request-presigner": {
|
|
40
|
+
"optional": true
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@aws-sdk/client-s3": "^3.1111.0",
|
|
45
|
+
"@aws-sdk/s3-request-presigner": "^3.1111.0",
|
|
46
|
+
"@biomejs/biome": "2.3.11",
|
|
47
|
+
"@types/bun": "^1.3.9",
|
|
48
|
+
"@types/node": "^26.2.0",
|
|
49
|
+
"tsup": "^8.5.1",
|
|
50
|
+
"typescript": "^7.0.2"
|
|
51
|
+
},
|
|
52
|
+
"description": "One TypeScript client for generative video, image, speech and text across native provider APIs.",
|
|
53
|
+
"license": "MIT",
|
|
54
|
+
"publishConfig": {
|
|
55
|
+
"access": "public"
|
|
56
|
+
},
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=18"
|
|
59
|
+
},
|
|
60
|
+
"files": [
|
|
61
|
+
"dist",
|
|
62
|
+
"CATALOG.md",
|
|
63
|
+
"README.md",
|
|
64
|
+
"LICENSE"
|
|
65
|
+
],
|
|
66
|
+
"module": "./dist/index.js",
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "git+https://github.com/brotu/brotu-sdk.git",
|
|
70
|
+
"directory": "sdks/node"
|
|
71
|
+
}
|
|
72
|
+
}
|