BREAKING CHANGE(vercel-ai-sdk): migrate to Vercel AI SDK v6 and introduce provider registry (getModel) returning LanguageModelV3

This commit is contained in:
2026-03-05 19:37:29 +00:00
parent 27cef60900
commit c24010c9bc
61 changed files with 4789 additions and 9083 deletions

24
ts_audio/index.ts Normal file
View File

@@ -0,0 +1,24 @@
import * as plugins from './plugins.js';
import { Readable } from 'stream';
export interface IOpenAiTtsOptions {
apiKey: string;
text: string;
voice?: 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer';
model?: 'tts-1' | 'tts-1-hd';
responseFormat?: 'mp3' | 'opus' | 'aac' | 'flac';
speed?: number;
}
export async function textToSpeech(options: IOpenAiTtsOptions): Promise<NodeJS.ReadableStream> {
const client = new plugins.OpenAI({ apiKey: options.apiKey });
const result = await client.audio.speech.create({
model: options.model ?? 'tts-1',
voice: options.voice ?? 'alloy',
input: options.text,
response_format: options.responseFormat ?? 'mp3',
speed: options.speed ?? 1,
});
const stream = result.body;
return Readable.fromWeb(stream as any);
}

2
ts_audio/plugins.ts Normal file
View File

@@ -0,0 +1,2 @@
import OpenAI from 'openai';
export { OpenAI };