@vargai/sdk 0.1.1
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/.env.example +24 -0
- package/CLAUDE.md +118 -0
- package/HIGGSFIELD_REWRITE_SUMMARY.md +300 -0
- package/README.md +231 -0
- package/SKILLS.md +157 -0
- package/STRUCTURE.md +92 -0
- package/TEST_RESULTS.md +122 -0
- package/action/captions/SKILL.md +170 -0
- package/action/captions/index.ts +169 -0
- package/action/edit/SKILL.md +235 -0
- package/action/edit/index.ts +437 -0
- package/action/image/SKILL.md +140 -0
- package/action/image/index.ts +105 -0
- package/action/sync/SKILL.md +136 -0
- package/action/sync/index.ts +145 -0
- package/action/transcribe/SKILL.md +179 -0
- package/action/transcribe/index.ts +210 -0
- package/action/video/SKILL.md +116 -0
- package/action/video/index.ts +125 -0
- package/action/voice/SKILL.md +125 -0
- package/action/voice/index.ts +136 -0
- package/biome.json +33 -0
- package/bun.lock +842 -0
- package/cli/commands/find.ts +58 -0
- package/cli/commands/help.ts +70 -0
- package/cli/commands/list.ts +49 -0
- package/cli/commands/run.ts +237 -0
- package/cli/commands/which.ts +66 -0
- package/cli/discover.ts +66 -0
- package/cli/index.ts +33 -0
- package/cli/runner.ts +65 -0
- package/cli/types.ts +49 -0
- package/cli/ui.ts +185 -0
- package/index.ts +75 -0
- package/lib/README.md +144 -0
- package/lib/ai-sdk/fal.ts +106 -0
- package/lib/ai-sdk/replicate.ts +107 -0
- package/lib/elevenlabs.ts +382 -0
- package/lib/fal.ts +467 -0
- package/lib/ffmpeg.ts +467 -0
- package/lib/fireworks.ts +235 -0
- package/lib/groq.ts +246 -0
- package/lib/higgsfield/MIGRATION.md +308 -0
- package/lib/higgsfield/README.md +273 -0
- package/lib/higgsfield/example.ts +228 -0
- package/lib/higgsfield/index.ts +241 -0
- package/lib/higgsfield/soul.ts +262 -0
- package/lib/higgsfield.ts +176 -0
- package/lib/remotion/SKILL.md +823 -0
- package/lib/remotion/cli.ts +115 -0
- package/lib/remotion/functions.ts +283 -0
- package/lib/remotion/index.ts +19 -0
- package/lib/remotion/templates.ts +73 -0
- package/lib/replicate.ts +304 -0
- package/output.txt +1 -0
- package/package.json +42 -0
- package/pipeline/cookbooks/SKILL.md +285 -0
- package/pipeline/cookbooks/remotion-video.md +585 -0
- package/pipeline/cookbooks/round-video-character.md +337 -0
- package/pipeline/cookbooks/talking-character.md +59 -0
- package/scripts/produce-menopause-campaign.sh +202 -0
- package/service/music/SKILL.md +229 -0
- package/service/music/index.ts +296 -0
- package/test-import.ts +7 -0
- package/test-services.ts +97 -0
- package/tsconfig.json +29 -0
- package/utilities/s3.ts +147 -0
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
# Higgsfield API Client
|
|
2
|
+
|
|
3
|
+
HTTP-based client for the Higgsfield AI platform, implementing the asynchronous queue pattern for content generation.
|
|
4
|
+
|
|
5
|
+
## Overview
|
|
6
|
+
|
|
7
|
+
The Higgsfield API uses an asynchronous request-response pattern where requests enter a queue and process in the background. This implementation provides:
|
|
8
|
+
|
|
9
|
+
- Direct HTTP requests (no external client library)
|
|
10
|
+
- Queue management (submit, status check, cancel)
|
|
11
|
+
- Automatic polling with status updates
|
|
12
|
+
- Webhook support for async notifications
|
|
13
|
+
- Model-specific clients (Soul, etc.)
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
Set your Higgsfield API credentials as environment variables:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
export HIGGSFIELD_API_KEY="your-api-key"
|
|
21
|
+
export HIGGSFIELD_SECRET="your-api-secret"
|
|
22
|
+
# or
|
|
23
|
+
export HF_API_KEY="your-api-key"
|
|
24
|
+
export HF_API_SECRET="your-api-secret"
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
### Soul Image Generation
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { generateSoul, SoulSize, SoulQuality } from "./lib/higgsfield/soul";
|
|
33
|
+
|
|
34
|
+
// Simple generation
|
|
35
|
+
const result = await generateSoul({
|
|
36
|
+
prompt: "beautiful sunset over mountains",
|
|
37
|
+
width_and_height: SoulSize.PORTRAIT_1152x2048,
|
|
38
|
+
quality: SoulQuality.HD,
|
|
39
|
+
batch_size: 1,
|
|
40
|
+
enhance_prompt: false,
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
console.log(result.images[0].url);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### With Style
|
|
47
|
+
|
|
48
|
+
```typescript
|
|
49
|
+
import { generateSoul, listSoulStyles } from "./lib/higgsfield/soul";
|
|
50
|
+
|
|
51
|
+
// List available styles
|
|
52
|
+
const styles = await listSoulStyles();
|
|
53
|
+
console.log(styles);
|
|
54
|
+
|
|
55
|
+
// Generate with specific style
|
|
56
|
+
const result = await generateSoul({
|
|
57
|
+
prompt: "portrait of a woman",
|
|
58
|
+
style_id: "style-id-from-list",
|
|
59
|
+
quality: "1080p",
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### With Webhook
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const result = await generateSoul(
|
|
67
|
+
{
|
|
68
|
+
prompt: "landscape painting",
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
webhook: "https://your-webhook.url/endpoint",
|
|
72
|
+
},
|
|
73
|
+
);
|
|
74
|
+
|
|
75
|
+
// Returns immediately with request info
|
|
76
|
+
console.log(result.request_id);
|
|
77
|
+
// Your webhook will receive the result when ready
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Manual Queue Management
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { SoulClient } from "./lib/higgsfield/soul";
|
|
84
|
+
|
|
85
|
+
const client = new SoulClient();
|
|
86
|
+
|
|
87
|
+
// Submit request
|
|
88
|
+
const request = await client.submitRequest("soul", {
|
|
89
|
+
prompt: "beautiful landscape",
|
|
90
|
+
quality: "1080p",
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
console.log(request.request_id);
|
|
94
|
+
|
|
95
|
+
// Check status manually
|
|
96
|
+
const status = await client.getStatus(request.request_id);
|
|
97
|
+
console.log(status.status); // "queued", "in_progress", "completed", etc.
|
|
98
|
+
|
|
99
|
+
// Cancel if still queued
|
|
100
|
+
if (status.status === "queued") {
|
|
101
|
+
await client.cancelRequest(request.request_id);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Or wait for completion
|
|
105
|
+
const result = await client.waitForCompletion(request.request_id, {
|
|
106
|
+
pollingInterval: 2000, // 2 seconds
|
|
107
|
+
maxWaitTime: 300000, // 5 minutes
|
|
108
|
+
onUpdate: (status) => {
|
|
109
|
+
console.log(`Status: ${status.status}`);
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Using the Base Client
|
|
115
|
+
|
|
116
|
+
```typescript
|
|
117
|
+
import HiggsfieldClient from "./lib/higgsfield/index";
|
|
118
|
+
|
|
119
|
+
const client = new HiggsfieldClient({
|
|
120
|
+
apiKey: "your-api-key",
|
|
121
|
+
apiSecret: "your-api-secret",
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
// Works with any Higgsfield model
|
|
125
|
+
const result = await client.generate("model-id", {
|
|
126
|
+
// model-specific params
|
|
127
|
+
});
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## CLI Usage
|
|
131
|
+
|
|
132
|
+
### Soul Commands
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
# Generate image
|
|
136
|
+
bun run lib/higgsfield/soul.ts generate "beautiful sunset"
|
|
137
|
+
|
|
138
|
+
# Generate with style
|
|
139
|
+
bun run lib/higgsfield/soul.ts generate "portrait" "style-id-123"
|
|
140
|
+
|
|
141
|
+
# List available styles
|
|
142
|
+
bun run lib/higgsfield/soul.ts list_styles
|
|
143
|
+
|
|
144
|
+
# Check request status
|
|
145
|
+
bun run lib/higgsfield/soul.ts status "request-id"
|
|
146
|
+
|
|
147
|
+
# Cancel pending request
|
|
148
|
+
bun run lib/higgsfield/soul.ts cancel "request-id"
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
### Legacy Commands (backward compatible)
|
|
152
|
+
|
|
153
|
+
```bash
|
|
154
|
+
bun run lib/higgsfield.ts generate_soul "beautiful landscape"
|
|
155
|
+
bun run lib/higgsfield.ts list_styles
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## API Reference
|
|
159
|
+
|
|
160
|
+
### Request Statuses
|
|
161
|
+
|
|
162
|
+
| Status | Description |
|
|
163
|
+
|--------|-------------|
|
|
164
|
+
| `queued` | Request is waiting in queue |
|
|
165
|
+
| `in_progress` | Generation is actively processing |
|
|
166
|
+
| `nsfw` | Content failed moderation (credits refunded) |
|
|
167
|
+
| `failed` | Generation failed (credits refunded) |
|
|
168
|
+
| `completed` | Generation finished successfully |
|
|
169
|
+
| `canceled` | Request was canceled |
|
|
170
|
+
|
|
171
|
+
### Soul Parameters
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
interface SoulGenerationParams {
|
|
175
|
+
prompt: string; // Required
|
|
176
|
+
width_and_height?: string; // e.g., "1152x2048"
|
|
177
|
+
quality?: "720p" | "1080p";
|
|
178
|
+
style_id?: string; // From listSoulStyles()
|
|
179
|
+
batch_size?: 1 | 4;
|
|
180
|
+
enhance_prompt?: boolean;
|
|
181
|
+
seed?: number;
|
|
182
|
+
style_strength?: number;
|
|
183
|
+
image_reference?: string; // URL
|
|
184
|
+
custom_reference_id?: string;
|
|
185
|
+
custom_reference_strength?: number;
|
|
186
|
+
}
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Soul Size Options
|
|
190
|
+
|
|
191
|
+
```typescript
|
|
192
|
+
import { SoulSize } from "./lib/higgsfield/soul";
|
|
193
|
+
|
|
194
|
+
SoulSize.PORTRAIT_1152x2048
|
|
195
|
+
SoulSize.PORTRAIT_2048x1152
|
|
196
|
+
SoulSize.SQUARE_2048x2048
|
|
197
|
+
SoulSize.LANDSCAPE_1536x2048
|
|
198
|
+
SoulSize.LANDSCAPE_2016x1344
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### Quality Options
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { SoulQuality } from "./lib/higgsfield/soul";
|
|
205
|
+
|
|
206
|
+
SoulQuality.SD // "720p"
|
|
207
|
+
SoulQuality.HD // "1080p"
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
## Webhook Integration
|
|
211
|
+
|
|
212
|
+
When you provide a webhook URL, the API will send a POST request to your endpoint when generation completes:
|
|
213
|
+
|
|
214
|
+
```typescript
|
|
215
|
+
// Your webhook endpoint receives:
|
|
216
|
+
{
|
|
217
|
+
"status": "completed",
|
|
218
|
+
"request_id": "uuid",
|
|
219
|
+
"status_url": "https://...",
|
|
220
|
+
"cancel_url": "https://...",
|
|
221
|
+
"images": [{ "url": "https://..." }]
|
|
222
|
+
}
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Webhook retries:
|
|
226
|
+
- Retries for up to 2 hours
|
|
227
|
+
- Continues until your endpoint returns 2xx status
|
|
228
|
+
- Implement idempotency using `request_id`
|
|
229
|
+
|
|
230
|
+
## Best Practices
|
|
231
|
+
|
|
232
|
+
1. **Store Request IDs**: Save `request_id` to retrieve results later
|
|
233
|
+
2. **Handle All Statuses**: Check for `completed`, `failed`, `nsfw`, and `canceled`
|
|
234
|
+
3. **Use Webhooks for Long Tasks**: Avoid keeping connections open
|
|
235
|
+
4. **Implement Idempotency**: Handle duplicate webhook deliveries gracefully
|
|
236
|
+
5. **Set Reasonable Timeouts**: Default is 5 minutes, adjust as needed
|
|
237
|
+
6. **Cancel Unused Requests**: Free up queue slots when possible
|
|
238
|
+
|
|
239
|
+
## Migration from Client Library
|
|
240
|
+
|
|
241
|
+
If you're migrating from `@higgsfield/client`:
|
|
242
|
+
|
|
243
|
+
### Before
|
|
244
|
+
```typescript
|
|
245
|
+
import { HiggsfieldClient } from "@higgsfield/client";
|
|
246
|
+
|
|
247
|
+
const client = new HiggsfieldClient({ apiKey, apiSecret });
|
|
248
|
+
const jobSet = await client.generate("/v1/text2image/soul", params);
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### After
|
|
252
|
+
```typescript
|
|
253
|
+
import { generateSoul } from "./lib/higgsfield/soul";
|
|
254
|
+
|
|
255
|
+
const result = await generateSoul(params);
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
The new API returns the same data structure but uses native HTTP requests instead of a client library.
|
|
259
|
+
|
|
260
|
+
## Architecture
|
|
261
|
+
|
|
262
|
+
```
|
|
263
|
+
lib/higgsfield/
|
|
264
|
+
├── index.ts # Base HiggsfieldClient class
|
|
265
|
+
├── soul.ts # Soul-specific API
|
|
266
|
+
└── README.md # This file
|
|
267
|
+
|
|
268
|
+
lib/higgsfield.ts # Backward-compatible wrapper
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
Each model can have its own file with specialized methods while sharing the base queue management from `index.ts`.
|
|
272
|
+
|
|
273
|
+
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
2
|
+
/**
|
|
3
|
+
* Example usage of the new Higgsfield HTTP API
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
generateSoul,
|
|
8
|
+
listSoulStyles,
|
|
9
|
+
SoulClient,
|
|
10
|
+
SoulSize,
|
|
11
|
+
SoulQuality,
|
|
12
|
+
BatchSize,
|
|
13
|
+
} from "./soul";
|
|
14
|
+
|
|
15
|
+
// Example 1: Simple generation
|
|
16
|
+
async function simpleGeneration() {
|
|
17
|
+
console.log("=== Example 1: Simple Generation ===\n");
|
|
18
|
+
|
|
19
|
+
const result = await generateSoul({
|
|
20
|
+
prompt: "a serene mountain landscape at sunset",
|
|
21
|
+
width_and_height: SoulSize.LANDSCAPE_1536x2048,
|
|
22
|
+
quality: SoulQuality.HD,
|
|
23
|
+
batch_size: BatchSize.SINGLE,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
if (result.status === "completed" && result.images) {
|
|
27
|
+
console.log("✓ Generation successful!");
|
|
28
|
+
console.log(`Image URL: ${result.images[0].url}`);
|
|
29
|
+
} else {
|
|
30
|
+
console.log(`✗ Generation ${result.status}`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Example 2: List and use styles
|
|
35
|
+
async function generationWithStyle() {
|
|
36
|
+
console.log("\n=== Example 2: Generation with Style ===\n");
|
|
37
|
+
|
|
38
|
+
// First, list available styles
|
|
39
|
+
const styles = await listSoulStyles();
|
|
40
|
+
console.log(`Found ${styles.length} available styles`);
|
|
41
|
+
|
|
42
|
+
if (styles.length > 0) {
|
|
43
|
+
const firstStyle = styles[0];
|
|
44
|
+
console.log(`Using style: ${firstStyle.name} (${firstStyle.id})`);
|
|
45
|
+
|
|
46
|
+
const result = await generateSoul({
|
|
47
|
+
prompt: "portrait of a wise old wizard",
|
|
48
|
+
style_id: firstStyle.id,
|
|
49
|
+
quality: SoulQuality.HD,
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
if (result.status === "completed" && result.images) {
|
|
53
|
+
console.log("✓ Generation with style successful!");
|
|
54
|
+
console.log(`Image URL: ${result.images[0].url}`);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Example 3: Manual queue management
|
|
60
|
+
async function manualQueueManagement() {
|
|
61
|
+
console.log("\n=== Example 3: Manual Queue Management ===\n");
|
|
62
|
+
|
|
63
|
+
const client = new SoulClient();
|
|
64
|
+
|
|
65
|
+
// Submit request
|
|
66
|
+
const request = await client.submitRequest("soul", {
|
|
67
|
+
prompt: "futuristic city skyline",
|
|
68
|
+
quality: "1080p",
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
console.log(`Request submitted: ${request.request_id}`);
|
|
72
|
+
console.log(`Status: ${request.status}`);
|
|
73
|
+
|
|
74
|
+
// Poll for status updates
|
|
75
|
+
const result = await client.waitForCompletion(request.request_id, {
|
|
76
|
+
pollingInterval: 2000,
|
|
77
|
+
maxWaitTime: 300000,
|
|
78
|
+
onUpdate: (status) => {
|
|
79
|
+
console.log(` → ${status.status}`);
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
if (result.status === "completed" && result.images) {
|
|
84
|
+
console.log("✓ Generation complete!");
|
|
85
|
+
console.log(`Image URL: ${result.images[0].url}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// Example 4: With webhook (for production)
|
|
90
|
+
async function generationWithWebhook() {
|
|
91
|
+
console.log("\n=== Example 4: Generation with Webhook ===\n");
|
|
92
|
+
|
|
93
|
+
const result = await generateSoul(
|
|
94
|
+
{
|
|
95
|
+
prompt: "abstract art with vibrant colors",
|
|
96
|
+
quality: SoulQuality.HD,
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
webhook: "https://your-webhook.url/higgsfield",
|
|
100
|
+
},
|
|
101
|
+
);
|
|
102
|
+
|
|
103
|
+
console.log(
|
|
104
|
+
"Request submitted with webhook - will receive results at webhook URL",
|
|
105
|
+
);
|
|
106
|
+
console.log(`Request ID: ${result.request_id}`);
|
|
107
|
+
console.log(`Status URL: ${result.status_url}`);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// Example 5: Batch generation
|
|
111
|
+
async function batchGeneration() {
|
|
112
|
+
console.log("\n=== Example 5: Batch Generation ===\n");
|
|
113
|
+
|
|
114
|
+
const result = await generateSoul({
|
|
115
|
+
prompt: "cute cartoon character designs",
|
|
116
|
+
batch_size: BatchSize.FOUR,
|
|
117
|
+
quality: SoulQuality.HD,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
if (result.status === "completed" && result.images) {
|
|
121
|
+
console.log(`✓ Generated ${result.images.length} images`);
|
|
122
|
+
for (const [index, image] of result.images.entries()) {
|
|
123
|
+
console.log(` ${index + 1}. ${image.url}`);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Example 6: Error handling
|
|
129
|
+
async function errorHandling() {
|
|
130
|
+
console.log("\n=== Example 6: Error Handling ===\n");
|
|
131
|
+
|
|
132
|
+
const client = new SoulClient();
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
const result = await client.generateSoul({
|
|
136
|
+
prompt: "test prompt",
|
|
137
|
+
quality: SoulQuality.HD,
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
switch (result.status) {
|
|
141
|
+
case "completed":
|
|
142
|
+
console.log("✓ Success!");
|
|
143
|
+
break;
|
|
144
|
+
case "failed":
|
|
145
|
+
console.log(`✗ Failed: ${result.error}`);
|
|
146
|
+
break;
|
|
147
|
+
case "nsfw":
|
|
148
|
+
console.log("✗ Content flagged as NSFW (credits refunded)");
|
|
149
|
+
break;
|
|
150
|
+
case "canceled":
|
|
151
|
+
console.log("✗ Request was canceled");
|
|
152
|
+
break;
|
|
153
|
+
default:
|
|
154
|
+
console.log(`? Unexpected status: ${result.status}`);
|
|
155
|
+
}
|
|
156
|
+
} catch (error) {
|
|
157
|
+
console.error("Error during generation:", error);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Run examples
|
|
162
|
+
if (import.meta.main) {
|
|
163
|
+
const example = process.argv[2];
|
|
164
|
+
|
|
165
|
+
try {
|
|
166
|
+
switch (example) {
|
|
167
|
+
case "1":
|
|
168
|
+
case "simple":
|
|
169
|
+
await simpleGeneration();
|
|
170
|
+
break;
|
|
171
|
+
case "2":
|
|
172
|
+
case "style":
|
|
173
|
+
await generationWithStyle();
|
|
174
|
+
break;
|
|
175
|
+
case "3":
|
|
176
|
+
case "queue":
|
|
177
|
+
await manualQueueManagement();
|
|
178
|
+
break;
|
|
179
|
+
case "4":
|
|
180
|
+
case "webhook":
|
|
181
|
+
await generationWithWebhook();
|
|
182
|
+
break;
|
|
183
|
+
case "5":
|
|
184
|
+
case "batch":
|
|
185
|
+
await batchGeneration();
|
|
186
|
+
break;
|
|
187
|
+
case "6":
|
|
188
|
+
case "error":
|
|
189
|
+
await errorHandling();
|
|
190
|
+
break;
|
|
191
|
+
case "all":
|
|
192
|
+
// Run all examples (except webhook)
|
|
193
|
+
await simpleGeneration();
|
|
194
|
+
await generationWithStyle();
|
|
195
|
+
await manualQueueManagement();
|
|
196
|
+
await batchGeneration();
|
|
197
|
+
await errorHandling();
|
|
198
|
+
break;
|
|
199
|
+
default:
|
|
200
|
+
console.log(`
|
|
201
|
+
Higgsfield API Examples
|
|
202
|
+
|
|
203
|
+
Usage:
|
|
204
|
+
bun run lib/higgsfield/example.ts <example>
|
|
205
|
+
|
|
206
|
+
Available examples:
|
|
207
|
+
1, simple - Simple generation
|
|
208
|
+
2, style - Generation with style
|
|
209
|
+
3, queue - Manual queue management
|
|
210
|
+
4, webhook - Generation with webhook
|
|
211
|
+
5, batch - Batch generation (4 images)
|
|
212
|
+
6, error - Error handling
|
|
213
|
+
all - Run all examples
|
|
214
|
+
|
|
215
|
+
Examples:
|
|
216
|
+
bun run lib/higgsfield/example.ts simple
|
|
217
|
+
bun run lib/higgsfield/example.ts style
|
|
218
|
+
bun run lib/higgsfield/example.ts all
|
|
219
|
+
`);
|
|
220
|
+
process.exit(1);
|
|
221
|
+
}
|
|
222
|
+
} catch (error) {
|
|
223
|
+
console.error("\nExample failed:", error);
|
|
224
|
+
process.exit(1);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
|