diff --git a/README.md b/README.md index fc91a6c..d9aaf08 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,7 @@ npm install modelslab import { Client, Community } from "modelslab"; // Initialize the client with your API key -const client = new Client("your-api-key-here"); +const client = new Client("your_api_key"); // Create API instances const community = new Community(client.key); @@ -63,20 +63,20 @@ console.log("Generated image:", result.output[0]); 3. Set it as an environment variable (optional): ```bash -export API_KEY="your-api-key-here" +export API_KEY="your_api_key" ``` ### 2. Initialize the Client ```javascript // Method 1: Direct API key -const client = new Client("your-api-key"); +const client = new Client("your_api_key"); // Method 2: Environment variable const client = new Client(); // Reads from process.env.API_KEY // Method 3: With custom settings -const client = new Client("your-api-key", 5, 10); // 5 retries, 10 second timeout +const client = new Client("your_api_key", 5, 10); // 5 retries, 10 second timeout ``` ### 3. Available APIs diff --git a/package.json b/package.json index e7955ac..07fb07f 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "main": "dist/client.js", "author": "Tanmay Patil ", "license": "MIT", - "version": "1.2.0", + "version": "1.3.0", "repository": { "type": "git", "url": "git+https://github.com/ModelsLab/modelslab-js.git" diff --git a/src/apis/community.ts b/src/apis/community.ts index aa6d48c..e332ea1 100644 --- a/src/apis/community.ts +++ b/src/apis/community.ts @@ -5,6 +5,7 @@ import { Image2Image, Inpainting, ControlNet, + QwenText2Image, } from "../schemas/community"; export class Community extends BaseAPI { @@ -33,4 +34,11 @@ export class Community extends BaseAPI { async controlnet(schema: ControlNet) { return this.post(this.baseUrl + "controlnet", schema); } + + async qwenTextToImage(schema: QwenText2Image) { + if (!this.enterprise) { + throw new Error("Qwen API is only available for enterprise users."); + } + return this.post("https://modelslab.com/api/v1/enterprise/qwen/text2img", schema); + } } diff --git a/src/schemas/audio.ts b/src/schemas/audio.ts index 8bac093..f8a0d41 100644 --- a/src/schemas/audio.ts +++ b/src/schemas/audio.ts @@ -78,6 +78,7 @@ export type MusicGen = z.infer; export const LyricsGeneratorSchema = z.object({ ...BaseSchemaFields, prompt: z.string(), + length: z.string().optional(), }); export type LyricsGenerator = z.infer; @@ -86,6 +87,7 @@ export const SongGeneratorSchema = z.object({ lyrics_generation: z.boolean().optional(), init_audio: z.any().optional(), prompt: z.string(), + model_id: z.string().optional(), lyrics: z.string().optional(), }); export type SongGenerator = z.infer; diff --git a/src/schemas/community.ts b/src/schemas/community.ts index 0638a66..e7b6be2 100644 --- a/src/schemas/community.ts +++ b/src/schemas/community.ts @@ -58,3 +58,13 @@ export const ControlNetSchema = z.object({ ...SharedImageFields, }); export type ControlNet = z.infer; + +export const QwenText2ImageSchema = z.object({ + ...BaseSchemaFields, + prompt: z.string(), + negative_prompt: z.string().optional(), + width: z.number().optional().default(512), + height: z.number().optional().default(512), + samples: z.number().optional().default(1), +}); +export type QwenText2Image = z.infer;