diff --git a/package.json b/package.json index 07fb07f..cc97b0c 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "dist/client.js", "author": "Tanmay Patil ", "license": "MIT", - "version": "1.3.0", + "version": "1.4.0", "repository": { "type": "git", "url": "git+https://github.com/ModelsLab/modelslab-js.git" diff --git a/src/apis/base.ts b/src/apis/base.ts index aa5f661..ab018d9 100644 --- a/src/apis/base.ts +++ b/src/apis/base.ts @@ -34,6 +34,7 @@ export class BaseAPI { headers: { Authorization: `Bearer ${this.key}`, "Content-Type": "application/json", + "X-Requested-With": "modelslab-js", }, }); return response.data; diff --git a/src/apis/community.ts b/src/apis/community.ts index e332ea1..649d7fa 100644 --- a/src/apis/community.ts +++ b/src/apis/community.ts @@ -6,6 +6,8 @@ import { Inpainting, ControlNet, QwenText2Image, + ZImageTurbo, + Flux2Dev, } from "../schemas/community"; export class Community extends BaseAPI { @@ -41,4 +43,14 @@ export class Community extends BaseAPI { } return this.post("https://modelslab.com/api/v1/enterprise/qwen/text2img", schema); } + + async zImageTurbo(schema: ZImageTurbo) { + const data = { ...schema, model_id: "z-image-turbo" }; + return this.post(this.baseUrl + "text2img", data); + } + + async flux2Dev(schema: Flux2Dev) { + const data = { ...schema, model_id: "flux-2-dev" }; + return this.post(this.baseUrl + "text2img", data); + } } diff --git a/src/client.ts b/src/client.ts index bb7ade2..c9c4e4a 100644 --- a/src/client.ts +++ b/src/client.ts @@ -11,6 +11,9 @@ export { Audio } from "./apis/audio"; export { ImageEditing } from "./apis/image_editing"; export { Video } from "./apis/video"; +// Export providers +export * from "./providers"; + // Export schemas export * from "./schemas/base"; export * from "./schemas/community"; diff --git a/src/providers/alibaba/api.ts b/src/providers/alibaba/api.ts new file mode 100644 index 0000000..9a6cf39 --- /dev/null +++ b/src/providers/alibaba/api.ts @@ -0,0 +1,44 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { Wan25I2VSchema, Wan25T2VSchema } from "./schemas"; + +export class AlibabaProvider extends BaseAPI { + static readonly MODEL_WAN25_I2V = "wan2.5-i2v"; + static readonly MODEL_WAN25_T2V = "wan2.5-t2v"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + wan25_i2v: AlibabaProvider.MODEL_WAN25_I2V, + wan25_t2v: AlibabaProvider.MODEL_WAN25_T2V, + }; + } + + async wan25I2V(schema: Wan25I2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || AlibabaProvider.MODEL_WAN25_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async wan25T2V(schema: Wan25T2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || AlibabaProvider.MODEL_WAN25_T2V, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/alibaba/index.ts b/src/providers/alibaba/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/alibaba/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/alibaba/schemas.ts b/src/providers/alibaba/schemas.ts new file mode 100644 index 0000000..39b5bfa --- /dev/null +++ b/src/providers/alibaba/schemas.ts @@ -0,0 +1,14 @@ +export interface Wan25I2VSchema { + model_id?: string; + init_image: string; + init_audio: string; + prompt: string; +} + +export interface Wan25T2VSchema { + model_id?: string; + prompt: string; + init_audio: string; + enhance_prompt?: boolean; + generate_audio?: boolean; +} diff --git a/src/providers/bfl/api.ts b/src/providers/bfl/api.ts new file mode 100644 index 0000000..30a4474 --- /dev/null +++ b/src/providers/bfl/api.ts @@ -0,0 +1,97 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { + FluxPro1752000026Schema, + FluxPro11Schema, + FluxPro11UltraSchema, + FluxKontextProSchema, + Flux2ProSchema, + Flux2ProImageEditingSchema, +} from "./schemas"; + +export class BFLProvider extends BaseAPI { + static readonly MODEL_FLUX_PRO_1752000026 = "flux-pro-1752000026"; + static readonly MODEL_FLUX_PRO_11 = "flux-pro-1.1"; + static readonly MODEL_FLUX_PRO_11_ULTRA = "flux-pro-1.1-ultra"; + static readonly MODEL_FLUX_KONTEXT_PRO = "flux-kontext-pro"; + static readonly MODEL_FLUX_2_PRO = "flux-2-pro"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + flux_pro_1752000026: BFLProvider.MODEL_FLUX_PRO_1752000026, + flux_pro_11: BFLProvider.MODEL_FLUX_PRO_11, + flux_pro_11_ultra: BFLProvider.MODEL_FLUX_PRO_11_ULTRA, + flux_kontext_pro: BFLProvider.MODEL_FLUX_KONTEXT_PRO, + flux_2_pro: BFLProvider.MODEL_FLUX_2_PRO, + }; + } + + async fluxPro1752000026(schema: FluxPro1752000026Schema) { + const endpoint = this.baseUrl + "v6/images/text2img"; + const data = { + key: this.key, + model_id: schema.model_id || BFLProvider.MODEL_FLUX_PRO_1752000026, + ...schema, + }; + return this.post(endpoint, data); + } + + async fluxPro11(schema: FluxPro11Schema) { + const endpoint = this.baseUrl + "v6/images/text2img"; + const data = { + key: this.key, + model_id: schema.model_id || BFLProvider.MODEL_FLUX_PRO_11, + ...schema, + }; + return this.post(endpoint, data); + } + + async fluxPro11Ultra(schema: FluxPro11UltraSchema) { + const endpoint = this.baseUrl + "v6/images/text2img"; + const data = { + key: this.key, + model_id: schema.model_id || BFLProvider.MODEL_FLUX_PRO_11_ULTRA, + ...schema, + }; + return this.post(endpoint, data); + } + + async fluxKontextPro(schema: FluxKontextProSchema) { + const endpoint = this.baseUrl + "v7/images/image-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || BFLProvider.MODEL_FLUX_KONTEXT_PRO, + ...schema, + }; + return this.post(endpoint, data); + } + + async flux2Pro(schema: Flux2ProSchema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || BFLProvider.MODEL_FLUX_2_PRO, + ...schema, + }; + return this.post(endpoint, data); + } + + async flux2ProImageEditing(schema: Flux2ProImageEditingSchema) { + const endpoint = this.baseUrl + "v7/images/image-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || BFLProvider.MODEL_FLUX_2_PRO, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/bfl/index.ts b/src/providers/bfl/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/bfl/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/bfl/schemas.ts b/src/providers/bfl/schemas.ts new file mode 100644 index 0000000..3377097 --- /dev/null +++ b/src/providers/bfl/schemas.ts @@ -0,0 +1,51 @@ +export interface FluxPro1752000026Schema { + model_id?: string; + prompt: string; + lora_model?: string; + width: number; + height: number; + negative_prompt?: string; + scheduler?: string; + guidance_scale?: number; +} + +export interface FluxPro11Schema { + model_id?: string; + prompt: string; + width?: number; + height?: number; + samples?: number; +} + +export interface FluxPro11UltraSchema { + model_id?: string; + prompt: string; + aspect_ratio?: string; + output_format?: string; +} + +export interface FluxKontextProSchema { + model_id?: string; + prompt: string; + init_image: string; + aspect_ratio?: string; + output_format?: string; +} + +export interface Flux2ProSchema { + model_id?: string; + prompt: string; + width?: number; + height?: number; + samples?: number; + guidance_scale?: number; +} + +export interface Flux2ProImageEditingSchema { + model_id?: string; + prompt: string; + init_image: string; + width?: number; + height?: number; + guidance_scale?: number; +} diff --git a/src/providers/byteplus/api.ts b/src/providers/byteplus/api.ts new file mode 100644 index 0000000..5f3177d --- /dev/null +++ b/src/providers/byteplus/api.ts @@ -0,0 +1,164 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { + SeeDreamT2ISchema, + SeeDanceT2VSchema, + SeeDanceI2VSchema, + SeeEditI2ISchema, + SeeDream4Schema, + SeeDream4I2ISchema, + SeeDance10ProI2VSchema, + OmniHumanSchema, + OmniHuman15Schema, + SeeDance10ProFastI2VSchema, + SeeDance10ProFastT2VSchema, +} from "./schemas"; + +export class BytePlusProvider extends BaseAPI { + static readonly MODEL_SEEDREAM_T2I = "seedream-t2i"; + static readonly MODEL_SEEDANCE_T2V = "seedance-t2v"; + static readonly MODEL_SEEDANCE_I2V = "seedance-i2v"; + static readonly MODEL_SEEDEDIT_I2I = "seededit-i2i"; + static readonly MODEL_SEEDREAM_4 = "seedream-4"; + static readonly MODEL_SEEDREAM_4_I2I = "seedream-4.0-i2i"; + static readonly MODEL_SEEDANCE_10_PRO_I2V = "seedance-1.0-pro-i2v"; + static readonly MODEL_OMNI_HUMAN = "omni-human"; + static readonly MODEL_OMNI_HUMAN_15 = "omni-human-1.5"; + static readonly MODEL_SEEDANCE_10_PRO_FAST_I2V = "seedance-1.0-pro-fast-i2v"; + static readonly MODEL_SEEDANCE_10_PRO_FAST_T2V = "seedance-1.0-pro-fast-t2v"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + seedream_t2i: BytePlusProvider.MODEL_SEEDREAM_T2I, + seedance_t2v: BytePlusProvider.MODEL_SEEDANCE_T2V, + seedance_i2v: BytePlusProvider.MODEL_SEEDANCE_I2V, + seededit_i2i: BytePlusProvider.MODEL_SEEDEDIT_I2I, + seedream_4: BytePlusProvider.MODEL_SEEDREAM_4, + seedream_4_i2i: BytePlusProvider.MODEL_SEEDREAM_4_I2I, + seedance_10_pro_i2v: BytePlusProvider.MODEL_SEEDANCE_10_PRO_I2V, + omni_human: BytePlusProvider.MODEL_OMNI_HUMAN, + omni_human_15: BytePlusProvider.MODEL_OMNI_HUMAN_15, + seedance_10_pro_fast_i2v: BytePlusProvider.MODEL_SEEDANCE_10_PRO_FAST_I2V, + seedance_10_pro_fast_t2v: BytePlusProvider.MODEL_SEEDANCE_10_PRO_FAST_T2V, + }; + } + + async seedreamT2I(schema: SeeDreamT2ISchema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDREAM_T2I, + ...schema, + }; + return this.post(endpoint, data); + } + + async seedanceT2V(schema: SeeDanceT2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDANCE_T2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async seedanceI2V(schema: SeeDanceI2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDANCE_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async seededitI2I(schema: SeeEditI2ISchema) { + const endpoint = this.baseUrl + "v7/images/image-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDEDIT_I2I, + ...schema, + }; + return this.post(endpoint, data); + } + + async seedream4(schema: SeeDream4Schema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDREAM_4, + ...schema, + }; + return this.post(endpoint, data); + } + + async seedream4I2I(schema: SeeDream4I2ISchema) { + const endpoint = this.baseUrl + "v7/images/image-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDREAM_4_I2I, + ...schema, + }; + return this.post(endpoint, data); + } + + async seedance10ProI2V(schema: SeeDance10ProI2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDANCE_10_PRO_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async omniHuman(schema: OmniHumanSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_OMNI_HUMAN, + ...schema, + }; + return this.post(endpoint, data); + } + + async omniHuman15(schema: OmniHuman15Schema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_OMNI_HUMAN_15, + ...schema, + }; + return this.post(endpoint, data); + } + + async seedance10ProFastI2V(schema: SeeDance10ProFastI2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDANCE_10_PRO_FAST_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async seedance10ProFastT2V(schema: SeeDance10ProFastT2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || BytePlusProvider.MODEL_SEEDANCE_10_PRO_FAST_T2V, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/byteplus/index.ts b/src/providers/byteplus/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/byteplus/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/byteplus/schemas.ts b/src/providers/byteplus/schemas.ts new file mode 100644 index 0000000..7b2e129 --- /dev/null +++ b/src/providers/byteplus/schemas.ts @@ -0,0 +1,72 @@ +export interface SeeDreamT2ISchema { + model_id?: string; + prompt: string; + width: number; + height: number; +} + +export interface SeeDanceT2VSchema { + model_id?: string; + prompt: string; + aspect_ratio?: string; + resolution?: string; + camera_fixed?: boolean; +} + +export interface SeeDanceI2VSchema { + model_id?: string; + init_image: string; + prompt: string; +} + +export interface SeeEditI2ISchema { + model_id?: string; + init_image: string; + prompt: string; +} + +export interface SeeDream4Schema { + model_id?: string; + prompt: string; + width?: number; + height?: number; + samples?: number; +} + +export interface SeeDream4I2ISchema { + model_id?: string; + init_image: string; + prompt: string; +} + +export interface SeeDance10ProI2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration?: string; +} + +export interface OmniHumanSchema { + model_id?: string; + init_image: string; + prompt: string; +} + +export interface OmniHuman15Schema { + model_id?: string; + init_image: string; + prompt: string; +} + +export interface SeeDance10ProFastI2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration?: string; +} + +export interface SeeDance10ProFastT2VSchema { + model_id?: string; + prompt: string; + duration?: string; +} diff --git a/src/providers/elevenlabs/api.ts b/src/providers/elevenlabs/api.ts new file mode 100644 index 0000000..a300422 --- /dev/null +++ b/src/providers/elevenlabs/api.ts @@ -0,0 +1,86 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { + ScribeV1Schema, + ElevenMultilingualV2Schema, + ElevenEnglishStsV2Schema, + ElevenSoundEffectSchema, + MusicV1Schema, +} from "./schemas"; + +export class ElevenLabsProvider extends BaseAPI { + static readonly MODEL_SCRIBE_V1 = "scribe_v1"; + static readonly MODEL_ELEVEN_MULTILINGUAL_V2 = "eleven_multilingual_v2"; + static readonly MODEL_ELEVEN_ENGLISH_STS_V2 = "eleven_english_sts_v2"; + static readonly MODEL_ELEVEN_SOUND_EFFECT = "eleven_sound_effect"; + static readonly MODEL_MUSIC_V1 = "music_v1"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + scribe_v1: ElevenLabsProvider.MODEL_SCRIBE_V1, + eleven_multilingual_v2: ElevenLabsProvider.MODEL_ELEVEN_MULTILINGUAL_V2, + eleven_english_sts_v2: ElevenLabsProvider.MODEL_ELEVEN_ENGLISH_STS_V2, + eleven_sound_effect: ElevenLabsProvider.MODEL_ELEVEN_SOUND_EFFECT, + music_v1: ElevenLabsProvider.MODEL_MUSIC_V1, + }; + } + + async scribeV1(schema: ScribeV1Schema) { + const endpoint = this.baseUrl + "v7/voice/speech-to-text"; + const data = { + key: this.key, + model_id: schema.model_id || ElevenLabsProvider.MODEL_SCRIBE_V1, + ...schema, + }; + return this.post(endpoint, data); + } + + async elevenMultilingualV2(schema: ElevenMultilingualV2Schema) { + const endpoint = this.baseUrl + "v7/voice/text-to-speech"; + const data = { + key: this.key, + model_id: schema.model_id || ElevenLabsProvider.MODEL_ELEVEN_MULTILINGUAL_V2, + ...schema, + }; + return this.post(endpoint, data); + } + + async elevenEnglishStsV2(schema: ElevenEnglishStsV2Schema) { + const endpoint = this.baseUrl + "v7/voice/speech-to-speech"; + const data = { + key: this.key, + model_id: schema.model_id || ElevenLabsProvider.MODEL_ELEVEN_ENGLISH_STS_V2, + ...schema, + }; + return this.post(endpoint, data); + } + + async elevenSoundEffect(schema: ElevenSoundEffectSchema) { + const endpoint = this.baseUrl + "v7/voice/sound-generation"; + const data = { + key: this.key, + model_id: schema.model_id || ElevenLabsProvider.MODEL_ELEVEN_SOUND_EFFECT, + ...schema, + }; + return this.post(endpoint, data); + } + + async musicV1(schema: MusicV1Schema) { + const endpoint = this.baseUrl + "v7/voice/music-gen"; + const data = { + key: this.key, + model_id: schema.model_id || ElevenLabsProvider.MODEL_MUSIC_V1, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/elevenlabs/index.ts b/src/providers/elevenlabs/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/elevenlabs/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/elevenlabs/schemas.ts b/src/providers/elevenlabs/schemas.ts new file mode 100644 index 0000000..47f65ea --- /dev/null +++ b/src/providers/elevenlabs/schemas.ts @@ -0,0 +1,29 @@ +export interface ScribeV1Schema { + model_id?: string; + init_audio: string; +} + +export interface ElevenMultilingualV2Schema { + model_id?: string; + prompt: string; + voice_id: string; +} + +export interface ElevenEnglishStsV2Schema { + model_id?: string; + init_audio: string; + voice_id: string; +} + +export interface ElevenSoundEffectSchema { + model_id?: string; + prompt: string; + duration_seconds?: number; + prompt_influence?: number; +} + +export interface MusicV1Schema { + model_id?: string; + prompt: string; + duration?: number; +} diff --git a/src/providers/google/api.ts b/src/providers/google/api.ts new file mode 100644 index 0000000..b5efb78 --- /dev/null +++ b/src/providers/google/api.ts @@ -0,0 +1,123 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { + Imagen4Schema, + Imagen3Schema, + Imagen40FastGenerateSchema, + Imagen40UltraSchema, + NanoBananaT2ISchema, + NanoBananaSchema, + NanoBanaProSchema, + NanoBanaProImageEditSchema, +} from "./schemas"; + +export class GoogleProvider extends BaseAPI { + static readonly MODEL_IMAGEN_4 = "imagen-4"; + static readonly MODEL_IMAGEN_3 = "imagen-3"; + static readonly MODEL_IMAGEN_40_FAST_GENERATE = "imagen-4.0-fast-generate"; + static readonly MODEL_IMAGEN_40_ULTRA = "imagen-4.0-ultra"; + static readonly MODEL_NANO_BANANA_T2I = "nano-banana-t2i"; + static readonly MODEL_NANO_BANANA = "nano-banana"; + static readonly MODEL_NANO_BANANA_PRO = "nano-banana-pro"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + imagen_4: GoogleProvider.MODEL_IMAGEN_4, + imagen_3: GoogleProvider.MODEL_IMAGEN_3, + imagen_40_fast_generate: GoogleProvider.MODEL_IMAGEN_40_FAST_GENERATE, + imagen_40_ultra: GoogleProvider.MODEL_IMAGEN_40_ULTRA, + nano_banana_t2i: GoogleProvider.MODEL_NANO_BANANA_T2I, + nano_banana: GoogleProvider.MODEL_NANO_BANANA, + nano_banana_pro: GoogleProvider.MODEL_NANO_BANANA_PRO, + }; + } + + async imagen4(schema: Imagen4Schema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_IMAGEN_4, + ...schema, + }; + return this.post(endpoint, data); + } + + async imagen3(schema: Imagen3Schema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_IMAGEN_3, + ...schema, + }; + return this.post(endpoint, data); + } + + async imagen40FastGenerate(schema: Imagen40FastGenerateSchema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_IMAGEN_40_FAST_GENERATE, + ...schema, + }; + return this.post(endpoint, data); + } + + async imagen40Ultra(schema: Imagen40UltraSchema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_IMAGEN_40_ULTRA, + ...schema, + }; + return this.post(endpoint, data); + } + + async nanoBananaT2I(schema: NanoBananaT2ISchema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_NANO_BANANA_T2I, + ...schema, + }; + return this.post(endpoint, data); + } + + async nanoBanana(schema: NanoBananaSchema) { + const endpoint = this.baseUrl + "v7/images/image-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_NANO_BANANA, + ...schema, + }; + return this.post(endpoint, data); + } + + async nanoBananaPro(schema: NanoBanaProSchema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_NANO_BANANA_PRO, + ...schema, + }; + return this.post(endpoint, data); + } + + async nanoBanaProImageEdit(schema: NanoBanaProImageEditSchema) { + const endpoint = this.baseUrl + "v7/images/image-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || GoogleProvider.MODEL_NANO_BANANA_PRO, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/google/index.ts b/src/providers/google/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/google/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/google/schemas.ts b/src/providers/google/schemas.ts new file mode 100644 index 0000000..7789d64 --- /dev/null +++ b/src/providers/google/schemas.ts @@ -0,0 +1,53 @@ +export interface Imagen4Schema { + model_id?: string; + prompt: string; + aspect_ratio: string; +} + +export interface Imagen3Schema { + model_id?: string; + prompt: string; +} + +export interface Imagen40FastGenerateSchema { + model_id?: string; + prompt: string; + aspect_ratio: string; +} + +export interface Imagen40UltraSchema { + model_id?: string; + prompt: string; + aspect_ratio: string; + samples?: number; +} + +export interface NanoBananaT2ISchema { + model_id?: string; + prompt: string; + width?: number; + height?: number; + samples?: number; +} + +export interface NanoBananaSchema { + model_id?: string; + init_image: string; + prompt: string; + width?: number; + height?: number; +} + +export interface NanoBanaProSchema { + model_id?: string; + prompt: string; + width?: number; + height?: number; + samples?: number; +} + +export interface NanoBanaProImageEditSchema { + model_id?: string; + init_image: string[]; + prompt: string; +} diff --git a/src/providers/index.ts b/src/providers/index.ts new file mode 100644 index 0000000..3f923e8 --- /dev/null +++ b/src/providers/index.ts @@ -0,0 +1,12 @@ +export * from "./alibaba"; +export * from "./bfl"; +export * from "./byteplus"; +export * from "./elevenlabs"; +export * from "./google"; +export * from "./inworld"; +export * from "./klingai"; +export * from "./minimax"; +export * from "./openai"; +export * from "./runway"; +export * from "./sonauto"; +export * from "./sync"; diff --git a/src/providers/inworld/api.ts b/src/providers/inworld/api.ts new file mode 100644 index 0000000..548b73e --- /dev/null +++ b/src/providers/inworld/api.ts @@ -0,0 +1,32 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { InworldTTSSchema } from "./schemas"; + +export class InworldProvider extends BaseAPI { + static readonly MODEL_INWORLD_TTS = "inworld-tts"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + inworld_tts: InworldProvider.MODEL_INWORLD_TTS, + }; + } + + async inworldTTS(schema: InworldTTSSchema) { + const endpoint = this.baseUrl + "v7/voice/text-to-speech"; + const data = { + key: this.key, + model_id: schema.model_id || InworldProvider.MODEL_INWORLD_TTS, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/inworld/index.ts b/src/providers/inworld/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/inworld/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/inworld/schemas.ts b/src/providers/inworld/schemas.ts new file mode 100644 index 0000000..62d74bd --- /dev/null +++ b/src/providers/inworld/schemas.ts @@ -0,0 +1,5 @@ +export interface InworldTTSSchema { + model_id?: string; + prompt: string; + voice_id: string; +} diff --git a/src/providers/klingai/api.ts b/src/providers/klingai/api.ts new file mode 100644 index 0000000..862b564 --- /dev/null +++ b/src/providers/klingai/api.ts @@ -0,0 +1,112 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { + KlingV21I2VSchema, + KlingV25TurboI2VSchema, + KlingV25TurboT2VSchema, + KlingV2MasterT2VSchema, + KlingV2MasterI2VSchema, + KlingV21MasterT2VSchema, + KlingV21MasterI2VSchema, +} from "./schemas"; + +export class KlingAIProvider extends BaseAPI { + static readonly MODEL_KLING_V21_I2V = "kling-v2-1-i2v"; + static readonly MODEL_KLING_V25_TURBO_I2V = "Kling-V2-5-Turbo-i2v"; + static readonly MODEL_KLING_V25_TURBO_T2V = "kling-v2-5-turbo-t2v"; + static readonly MODEL_KLING_V2_MASTER_T2V = "kling-v2-master-t2v"; + static readonly MODEL_KLING_V2_MASTER_I2V = "kling-v2-master-i2v"; + static readonly MODEL_KLING_V21_MASTER_T2V = "kling-v2-1-master-t2v"; + static readonly MODEL_KLING_V21_MASTER_I2V = "kling-v2-1-master-i2v"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + kling_v21_i2v: KlingAIProvider.MODEL_KLING_V21_I2V, + kling_v25_turbo_i2v: KlingAIProvider.MODEL_KLING_V25_TURBO_I2V, + kling_v25_turbo_t2v: KlingAIProvider.MODEL_KLING_V25_TURBO_T2V, + kling_v2_master_t2v: KlingAIProvider.MODEL_KLING_V2_MASTER_T2V, + kling_v2_master_i2v: KlingAIProvider.MODEL_KLING_V2_MASTER_I2V, + kling_v21_master_t2v: KlingAIProvider.MODEL_KLING_V21_MASTER_T2V, + kling_v21_master_i2v: KlingAIProvider.MODEL_KLING_V21_MASTER_I2V, + }; + } + + async klingV21I2V(schema: KlingV21I2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || KlingAIProvider.MODEL_KLING_V21_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async klingV25TurboI2V(schema: KlingV25TurboI2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || KlingAIProvider.MODEL_KLING_V25_TURBO_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async klingV25TurboT2V(schema: KlingV25TurboT2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || KlingAIProvider.MODEL_KLING_V25_TURBO_T2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async klingV2MasterT2V(schema: KlingV2MasterT2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || KlingAIProvider.MODEL_KLING_V2_MASTER_T2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async klingV2MasterI2V(schema: KlingV2MasterI2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || KlingAIProvider.MODEL_KLING_V2_MASTER_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async klingV21MasterT2V(schema: KlingV21MasterT2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || KlingAIProvider.MODEL_KLING_V21_MASTER_T2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async klingV21MasterI2V(schema: KlingV21MasterI2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || KlingAIProvider.MODEL_KLING_V21_MASTER_I2V, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/klingai/index.ts b/src/providers/klingai/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/klingai/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/klingai/schemas.ts b/src/providers/klingai/schemas.ts new file mode 100644 index 0000000..d6ebd53 --- /dev/null +++ b/src/providers/klingai/schemas.ts @@ -0,0 +1,48 @@ +export interface KlingV21I2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration: string; +} + +export interface KlingV25TurboI2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration: string; +} + +export interface KlingV25TurboT2VSchema { + model_id?: string; + prompt: string; + duration: string; + aspect_ratio?: string; +} + +export interface KlingV2MasterT2VSchema { + model_id?: string; + prompt: string; + duration: string; + aspect_ratio?: string; +} + +export interface KlingV2MasterI2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration: string; +} + +export interface KlingV21MasterT2VSchema { + model_id?: string; + prompt: string; + duration: string; + aspect_ratio?: string; +} + +export interface KlingV21MasterI2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration: string; +} diff --git a/src/providers/minimax/api.ts b/src/providers/minimax/api.ts new file mode 100644 index 0000000..b167b4d --- /dev/null +++ b/src/providers/minimax/api.ts @@ -0,0 +1,99 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { + Hailuo23T2VSchema, + Hailuo02T2VSchema, + Hailuo23I2VSchema, + Hailuo23FastI2VSchema, + Hailuo02I2VSchema, + Hailuo02StartEndFrameSchema, +} from "./schemas"; + +export class MinimaxProvider extends BaseAPI { + static readonly MODEL_HAILUO_23_T2V = "Hailuo-2.3-t2v"; + static readonly MODEL_HAILUO_02_T2V = "Hailuo-02-t2v"; + static readonly MODEL_HAILUO_23_I2V = "Hailuo-2.3-i2v"; + static readonly MODEL_HAILUO_23_FAST_I2V = "Hailuo-2.3-Fast-i2v"; + static readonly MODEL_HAILUO_02_I2V = "Hailuo-02-i2v"; + static readonly MODEL_HAILUO_02_START_END_FRAME = "Hailuo-02-start-end-frame"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + hailuo_23_t2v: MinimaxProvider.MODEL_HAILUO_23_T2V, + hailuo_02_t2v: MinimaxProvider.MODEL_HAILUO_02_T2V, + hailuo_23_i2v: MinimaxProvider.MODEL_HAILUO_23_I2V, + hailuo_23_fast_i2v: MinimaxProvider.MODEL_HAILUO_23_FAST_I2V, + hailuo_02_i2v: MinimaxProvider.MODEL_HAILUO_02_I2V, + hailuo_02_start_end_frame: MinimaxProvider.MODEL_HAILUO_02_START_END_FRAME, + }; + } + + async hailuo23T2V(schema: Hailuo23T2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || MinimaxProvider.MODEL_HAILUO_23_T2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async hailuo02T2V(schema: Hailuo02T2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || MinimaxProvider.MODEL_HAILUO_02_T2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async hailuo23I2V(schema: Hailuo23I2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || MinimaxProvider.MODEL_HAILUO_23_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async hailuo23FastI2V(schema: Hailuo23FastI2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || MinimaxProvider.MODEL_HAILUO_23_FAST_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async hailuo02I2V(schema: Hailuo02I2VSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || MinimaxProvider.MODEL_HAILUO_02_I2V, + ...schema, + }; + return this.post(endpoint, data); + } + + async hailuo02StartEndFrame(schema: Hailuo02StartEndFrameSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/image-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || MinimaxProvider.MODEL_HAILUO_02_START_END_FRAME, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/minimax/index.ts b/src/providers/minimax/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/minimax/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/minimax/schemas.ts b/src/providers/minimax/schemas.ts new file mode 100644 index 0000000..1167598 --- /dev/null +++ b/src/providers/minimax/schemas.ts @@ -0,0 +1,35 @@ +export interface Hailuo23T2VSchema { + model_id?: string; + prompt: string; +} + +export interface Hailuo02T2VSchema { + model_id?: string; + prompt: string; +} + +export interface Hailuo23I2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration?: string; +} + +export interface Hailuo23FastI2VSchema { + model_id?: string; + init_image: string; + prompt: string; + duration?: string; +} + +export interface Hailuo02I2VSchema { + model_id?: string; + init_image: string; + prompt: string; +} + +export interface Hailuo02StartEndFrameSchema { + model_id?: string; + init_image: string[]; + prompt: string; +} diff --git a/src/providers/openai/api.ts b/src/providers/openai/api.ts new file mode 100644 index 0000000..6e78c57 --- /dev/null +++ b/src/providers/openai/api.ts @@ -0,0 +1,32 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { Sora2Schema } from "./schemas"; + +export class OpenAIProvider extends BaseAPI { + static readonly MODEL_SORA_2 = "sora-2"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + sora_2: OpenAIProvider.MODEL_SORA_2, + }; + } + + async sora2(schema: Sora2Schema) { + const endpoint = this.baseUrl + "v7/video-fusion/text-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || OpenAIProvider.MODEL_SORA_2, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/openai/index.ts b/src/providers/openai/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/openai/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/openai/schemas.ts b/src/providers/openai/schemas.ts new file mode 100644 index 0000000..cb9d947 --- /dev/null +++ b/src/providers/openai/schemas.ts @@ -0,0 +1,6 @@ +export interface Sora2Schema { + model_id?: string; + prompt: string; + resolution?: string; + duration?: string; +} diff --git a/src/providers/runway/api.ts b/src/providers/runway/api.ts new file mode 100644 index 0000000..6f3bc0e --- /dev/null +++ b/src/providers/runway/api.ts @@ -0,0 +1,56 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { Gen4ImageSchema, Gen4ImageTurboSchema, Gen4AlephSchema } from "./schemas"; + +export class RunwayProvider extends BaseAPI { + static readonly MODEL_GEN4_IMAGE = "gen4_image"; + static readonly MODEL_GEN4_IMAGE_TURBO = "gen4_image_turbo"; + static readonly MODEL_GEN4_ALEPH = "gen4_aleph"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + gen4_image: RunwayProvider.MODEL_GEN4_IMAGE, + gen4_image_turbo: RunwayProvider.MODEL_GEN4_IMAGE_TURBO, + gen4_aleph: RunwayProvider.MODEL_GEN4_ALEPH, + }; + } + + async gen4Image(schema: Gen4ImageSchema) { + const endpoint = this.baseUrl + "v7/images/text-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || RunwayProvider.MODEL_GEN4_IMAGE, + ...schema, + }; + return this.post(endpoint, data); + } + + async gen4ImageTurbo(schema: Gen4ImageTurboSchema) { + const endpoint = this.baseUrl + "v7/images/image-to-image"; + const data = { + key: this.key, + model_id: schema.model_id || RunwayProvider.MODEL_GEN4_IMAGE_TURBO, + ...schema, + }; + return this.post(endpoint, data); + } + + async gen4Aleph(schema: Gen4AlephSchema) { + const endpoint = this.baseUrl + "v7/video-fusion/video-to-video"; + const data = { + key: this.key, + model_id: schema.model_id || RunwayProvider.MODEL_GEN4_ALEPH, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/runway/index.ts b/src/providers/runway/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/runway/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/runway/schemas.ts b/src/providers/runway/schemas.ts new file mode 100644 index 0000000..23eba1e --- /dev/null +++ b/src/providers/runway/schemas.ts @@ -0,0 +1,17 @@ +export interface Gen4ImageSchema { + model_id?: string; + prompt: string; + aspect_ratio?: string; +} + +export interface Gen4ImageTurboSchema { + model_id?: string; + init_image: string; + prompt: string; +} + +export interface Gen4AlephSchema { + model_id?: string; + init_video: string; + prompt: string; +} diff --git a/src/providers/sonauto/api.ts b/src/providers/sonauto/api.ts new file mode 100644 index 0000000..eb4af5f --- /dev/null +++ b/src/providers/sonauto/api.ts @@ -0,0 +1,56 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { SonautoSongSchema, SongExtenderSchema, SongInpaintSchema } from "./schemas"; + +export class SonautoProvider extends BaseAPI { + static readonly MODEL_SONAUTO_SONG = "sonauto_song"; + static readonly MODEL_SONG_EXTENDER = "song-extender"; + static readonly MODEL_SONG_INPAINT = "song-inpaint"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + sonauto_song: SonautoProvider.MODEL_SONAUTO_SONG, + song_extender: SonautoProvider.MODEL_SONG_EXTENDER, + song_inpaint: SonautoProvider.MODEL_SONG_INPAINT, + }; + } + + async sonautoSong(schema: SonautoSongSchema) { + const endpoint = this.baseUrl + "v7/voice/music-gen"; + const data = { + key: this.key, + model_id: schema.model_id || SonautoProvider.MODEL_SONAUTO_SONG, + ...schema, + }; + return this.post(endpoint, data); + } + + async songExtender(schema: SongExtenderSchema) { + const endpoint = this.baseUrl + "v7/voice/song-extender"; + const data = { + key: this.key, + model_id: schema.model_id || SonautoProvider.MODEL_SONG_EXTENDER, + ...schema, + }; + return this.post(endpoint, data); + } + + async songInpaint(schema: SongInpaintSchema) { + const endpoint = this.baseUrl + "v7/voice/song-inpaint"; + const data = { + key: this.key, + model_id: schema.model_id || SonautoProvider.MODEL_SONG_INPAINT, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/sonauto/index.ts b/src/providers/sonauto/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/sonauto/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/sonauto/schemas.ts b/src/providers/sonauto/schemas.ts new file mode 100644 index 0000000..aa84267 --- /dev/null +++ b/src/providers/sonauto/schemas.ts @@ -0,0 +1,18 @@ +export interface SonautoSongSchema { + model_id?: string; + prompt: string; + make_instrumental?: boolean; + wait_audio?: boolean; +} + +export interface SongExtenderSchema { + model_id?: string; + prompt: string; + init_audio: string; +} + +export interface SongInpaintSchema { + model_id?: string; + init_audio: string; + prompt: string; +} diff --git a/src/providers/sync/api.ts b/src/providers/sync/api.ts new file mode 100644 index 0000000..9d7379e --- /dev/null +++ b/src/providers/sync/api.ts @@ -0,0 +1,32 @@ +import { BaseAPI } from "../../apis/base"; +import { Client } from "../../client"; +import { Lipsync2Schema } from "./schemas"; + +export class SyncProvider extends BaseAPI { + static readonly MODEL_LIPSYNC_2 = "lipsync-2"; + + constructor(client: Client) { + super({ + key: client.key, + baseUrl: client.baseUrl, + fetchRetry: client.fetchRetry, + fetchTimeout: client.fetchTimeout, + }); + } + + static getModelIds() { + return { + lipsync_2: SyncProvider.MODEL_LIPSYNC_2, + }; + } + + async lipsync2(schema: Lipsync2Schema) { + const endpoint = this.baseUrl + "v7/video-fusion/lip-sync"; + const data = { + key: this.key, + model_id: schema.model_id || SyncProvider.MODEL_LIPSYNC_2, + ...schema, + }; + return this.post(endpoint, data); + } +} diff --git a/src/providers/sync/index.ts b/src/providers/sync/index.ts new file mode 100644 index 0000000..fce40e8 --- /dev/null +++ b/src/providers/sync/index.ts @@ -0,0 +1,2 @@ +export * from "./api"; +export * from "./schemas"; diff --git a/src/providers/sync/schemas.ts b/src/providers/sync/schemas.ts new file mode 100644 index 0000000..30079c3 --- /dev/null +++ b/src/providers/sync/schemas.ts @@ -0,0 +1,5 @@ +export interface Lipsync2Schema { + model_id?: string; + init_video: string; + init_audio: string; +} diff --git a/src/schemas/community.ts b/src/schemas/community.ts index e7b6be2..9f78426 100644 --- a/src/schemas/community.ts +++ b/src/schemas/community.ts @@ -68,3 +68,21 @@ export const QwenText2ImageSchema = z.object({ samples: z.number().optional().default(1), }); export type QwenText2Image = z.infer; + +export const ZImageTurboSchema = z.object({ + ...BaseSchemaFields, + prompt: z.string(), + width: z.number().optional(), + height: z.number().optional(), + samples: z.number().optional(), +}); +export type ZImageTurbo = z.infer; + +export const Flux2DevSchema = z.object({ + ...BaseSchemaFields, + prompt: z.string(), + width: z.number().optional(), + height: z.number().optional(), + samples: z.number().optional(), +}); +export type Flux2Dev = z.infer;