Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "dist/client.js",
"author": "Tanmay Patil <Tanmay@modelslab.com>",
"license": "MIT",
"version": "1.2.0",
"version": "1.3.0",
"repository": {
"type": "git",
"url": "git+https://github.com/ModelsLab/modelslab-js.git"
Expand Down
8 changes: 8 additions & 0 deletions src/apis/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
Image2Image,
Inpainting,
ControlNet,
QwenText2Image,
} from "../schemas/community";

export class Community extends BaseAPI {
Expand Down Expand Up @@ -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);
}
}
2 changes: 2 additions & 0 deletions src/schemas/audio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ export type MusicGen = z.infer<typeof MusicGenSchema>;
export const LyricsGeneratorSchema = z.object({
...BaseSchemaFields,
prompt: z.string(),
length: z.string().optional(),
});
export type LyricsGenerator = z.infer<typeof LyricsGeneratorSchema>;

Expand All @@ -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<typeof SongGeneratorSchema>;
Expand Down
10 changes: 10 additions & 0 deletions src/schemas/community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,13 @@ export const ControlNetSchema = z.object({
...SharedImageFields,
});
export type ControlNet = z.infer<typeof ControlNetSchema>;

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<typeof QwenText2ImageSchema>;