@yetter/client 0.0.4 → 0.0.5

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/dist/api.js CHANGED
@@ -16,7 +16,7 @@ export class YetterImageClient {
16
16
  method: "POST",
17
17
  headers: {
18
18
  "Content-Type": "application/json",
19
- Authorization: `${this.apiKey}`,
19
+ Authorization: this.apiKey,
20
20
  },
21
21
  body: JSON.stringify(body),
22
22
  });
@@ -35,7 +35,7 @@ export class YetterImageClient {
35
35
  method: "GET",
36
36
  headers: {
37
37
  "Content-Type": "application/json",
38
- Authorization: `${this.apiKey}`,
38
+ Authorization: this.apiKey,
39
39
  },
40
40
  });
41
41
  if (!res.ok) {
@@ -49,7 +49,7 @@ export class YetterImageClient {
49
49
  method: "PUT",
50
50
  headers: {
51
51
  "Content-Type": "application/json",
52
- Authorization: `${this.apiKey}`,
52
+ Authorization: this.apiKey,
53
53
  },
54
54
  });
55
55
  if (!res.ok) {
@@ -63,7 +63,7 @@ export class YetterImageClient {
63
63
  method: "GET",
64
64
  headers: {
65
65
  "Content-Type": "application/json",
66
- Authorization: `${this.apiKey}`,
66
+ Authorization: this.apiKey,
67
67
  },
68
68
  });
69
69
  if (!res.ok) {
package/dist/client.js CHANGED
@@ -4,7 +4,12 @@ import { EventSourcePolyfill } from 'event-source-polyfill';
4
4
  export class yetter {
5
5
  static configure(options) {
6
6
  if (options.apiKey) {
7
- _a.apiKey = options.apiKey;
7
+ if (options.is_bearer) {
8
+ _a.apiKey = 'Bearer ' + options.apiKey;
9
+ }
10
+ else {
11
+ _a.apiKey = 'Key ' + options.apiKey;
12
+ }
8
13
  }
9
14
  if (options.endpoint) {
10
15
  _a.endpoint = options.endpoint;
@@ -17,7 +22,7 @@ export class yetter {
17
22
  }
18
23
  const client = new YetterImageClient({
19
24
  apiKey: _a.apiKey,
20
- endpoint: _a.endpoint,
25
+ endpoint: _a.endpoint
21
26
  });
22
27
  const generateResponse = await client.generateImage({
23
28
  model: model,
@@ -67,18 +72,18 @@ export class yetter {
67
72
  if (!_a.apiKey) {
68
73
  throw new Error("API key is not configured. Call yetter.configure({ apiKey: 'your_key' }) or set YTR_API_KEY.");
69
74
  }
70
- const apiClient = new YetterImageClient({
75
+ const client = new YetterImageClient({
71
76
  apiKey: _a.apiKey,
72
- endpoint: _a.endpoint,
77
+ endpoint: _a.endpoint
73
78
  });
74
- const initialApiResponse = await apiClient.generateImage({
79
+ const initialApiResponse = await client.generateImage({
75
80
  model: model,
76
81
  ...options.input,
77
82
  });
78
83
  const requestId = initialApiResponse.request_id;
79
84
  const responseUrl = initialApiResponse.response_url;
80
85
  const cancelUrl = initialApiResponse.cancel_url;
81
- const sseStreamUrl = `${apiClient.getApiEndpoint()}/${model}/requests/${requestId}/status/stream`;
86
+ const sseStreamUrl = `${client.getApiEndpoint()}/${model}/requests/${requestId}/status/stream`;
82
87
  let eventSource;
83
88
  let streamEnded = false;
84
89
  // Setup the promise for the done() method
@@ -107,7 +112,7 @@ export class yetter {
107
112
  // Check for terminal events to resolve/reject the donePromise
108
113
  if (event.status === "COMPLETED") {
109
114
  streamEnded = true;
110
- apiClient.getResponse({ url: responseUrl })
115
+ client.getResponse({ url: responseUrl })
111
116
  .then(resolveDonePromise)
112
117
  .catch(rejectDonePromise)
113
118
  .finally(() => this.close());
@@ -208,7 +213,7 @@ export class yetter {
208
213
  cancel: async () => {
209
214
  controller.close();
210
215
  try {
211
- await apiClient.cancel({ url: cancelUrl });
216
+ await client.cancel({ url: cancelUrl });
212
217
  console.log(`Stream for ${requestId} - underlying request cancelled.`);
213
218
  }
214
219
  catch (e) {
@@ -224,7 +229,7 @@ export class yetter {
224
229
  }
225
230
  }
226
231
  _a = yetter;
227
- yetter.apiKey = process.env.YTR_API_KEY || process.env.REACT_APP_YTR_API_KEY || "";
232
+ yetter.apiKey = 'Key ' + (process.env.YTR_API_KEY || process.env.REACT_APP_YTR_API_KEY || "");
228
233
  yetter.endpoint = "https://api.yetter.ai";
229
234
  yetter.queue = {
230
235
  submit: async (model, options) => {
@@ -233,7 +238,7 @@ yetter.queue = {
233
238
  }
234
239
  const client = new YetterImageClient({
235
240
  apiKey: _a.apiKey,
236
- endpoint: _a.endpoint,
241
+ endpoint: _a.endpoint
237
242
  });
238
243
  const generateResponse = await client.generateImage({
239
244
  model: model,
@@ -247,7 +252,7 @@ yetter.queue = {
247
252
  }
248
253
  const client = new YetterImageClient({
249
254
  apiKey: _a.apiKey,
250
- endpoint: _a.endpoint,
255
+ endpoint: _a.endpoint
251
256
  });
252
257
  const endpoint = client.getApiEndpoint();
253
258
  const statusUrl = `${endpoint}/${model}/requests/${options.requestId}/status`;
@@ -263,7 +268,7 @@ yetter.queue = {
263
268
  }
264
269
  const client = new YetterImageClient({
265
270
  apiKey: _a.apiKey,
266
- endpoint: _a.endpoint,
271
+ endpoint: _a.endpoint
267
272
  });
268
273
  const endpoint = client.getApiEndpoint();
269
274
  const responseUrl = `${endpoint}/${model}/requests/${options.requestId}`;
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export interface ClientOptions {
2
2
  apiKey: string;
3
3
  endpoint?: string;
4
+ is_bearer?: boolean;
4
5
  }
5
6
  export interface GenerateImageRequest {
6
7
  model: string;
@@ -9,6 +9,7 @@ async function main() {
9
9
  const streamInstance = await yetter.stream(model, {
10
10
  input: {
11
11
  prompt: "a bioluminescent forest at night, fantasy art",
12
+ seed: 42
12
13
  // You can add other parameters like seed or num_inference_steps here
13
14
  },
14
15
  });
@@ -34,7 +35,7 @@ async function main() {
34
35
  console.log("Generated Images:", result.images);
35
36
  } else {
36
37
  console.log("No images in final result.");
37
- }
38
+ }''
38
39
  console.log("Original Prompt:", result.prompt);
39
40
 
40
41
  } catch (err: any) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yetter/client",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "build": "tsc",
package/src/api.ts CHANGED
@@ -35,7 +35,7 @@ export class YetterImageClient {
35
35
  method: "POST",
36
36
  headers: {
37
37
  "Content-Type": "application/json",
38
- Authorization: `${this.apiKey}`,
38
+ Authorization: this.apiKey,
39
39
  },
40
40
  body: JSON.stringify(body),
41
41
  });
@@ -58,7 +58,7 @@ export class YetterImageClient {
58
58
  method: "GET",
59
59
  headers: {
60
60
  "Content-Type": "application/json",
61
- Authorization: `${this.apiKey}`,
61
+ Authorization: this.apiKey,
62
62
  },
63
63
  });
64
64
 
@@ -75,7 +75,7 @@ export class YetterImageClient {
75
75
  method: "PUT",
76
76
  headers: {
77
77
  "Content-Type": "application/json",
78
- Authorization: `${this.apiKey}`,
78
+ Authorization: this.apiKey,
79
79
  },
80
80
  });
81
81
 
@@ -92,7 +92,7 @@ export class YetterImageClient {
92
92
  method: "GET",
93
93
  headers: {
94
94
  "Content-Type": "application/json",
95
- Authorization: `${this.apiKey}`,
95
+ Authorization: this.apiKey,
96
96
  },
97
97
  });
98
98
 
package/src/client.ts CHANGED
@@ -17,12 +17,16 @@ import {
17
17
  } from "./types.js";
18
18
 
19
19
  export class yetter {
20
- private static apiKey: string = process.env.YTR_API_KEY || process.env.REACT_APP_YTR_API_KEY || "";
20
+ private static apiKey: string = 'Key ' + (process.env.YTR_API_KEY || process.env.REACT_APP_YTR_API_KEY || "");
21
21
  private static endpoint: string = "https://api.yetter.ai";
22
22
 
23
23
  public static configure(options: ClientOptions) {
24
24
  if (options.apiKey) {
25
- yetter.apiKey = options.apiKey;
25
+ if (options.is_bearer) {
26
+ yetter.apiKey = 'Bearer ' + options.apiKey;
27
+ } else {
28
+ yetter.apiKey = 'Key ' + options.apiKey;
29
+ }
26
30
  }
27
31
  if (options.endpoint) {
28
32
  yetter.endpoint = options.endpoint;
@@ -38,7 +42,7 @@ export class yetter {
38
42
  }
39
43
  const client = new YetterImageClient({
40
44
  apiKey: yetter.apiKey,
41
- endpoint: yetter.endpoint,
45
+ endpoint: yetter.endpoint
42
46
  });
43
47
 
44
48
  const generateResponse = await client.generateImage({
@@ -102,7 +106,7 @@ export class yetter {
102
106
  }
103
107
  const client = new YetterImageClient({
104
108
  apiKey: yetter.apiKey,
105
- endpoint: yetter.endpoint,
109
+ endpoint: yetter.endpoint
106
110
  });
107
111
 
108
112
  const generateResponse = await client.generateImage({
@@ -122,7 +126,7 @@ export class yetter {
122
126
  }
123
127
  const client = new YetterImageClient({
124
128
  apiKey: yetter.apiKey,
125
- endpoint: yetter.endpoint,
129
+ endpoint: yetter.endpoint
126
130
  });
127
131
 
128
132
  const endpoint = client.getApiEndpoint();
@@ -146,7 +150,7 @@ export class yetter {
146
150
  }
147
151
  const client = new YetterImageClient({
148
152
  apiKey: yetter.apiKey,
149
- endpoint: yetter.endpoint,
153
+ endpoint: yetter.endpoint
150
154
  });
151
155
 
152
156
  const endpoint = client.getApiEndpoint();
@@ -169,12 +173,12 @@ export class yetter {
169
173
  if (!yetter.apiKey) {
170
174
  throw new Error("API key is not configured. Call yetter.configure({ apiKey: 'your_key' }) or set YTR_API_KEY.");
171
175
  }
172
- const apiClient = new YetterImageClient({
176
+ const client = new YetterImageClient({
173
177
  apiKey: yetter.apiKey,
174
- endpoint: yetter.endpoint,
178
+ endpoint: yetter.endpoint
175
179
  });
176
180
 
177
- const initialApiResponse = await apiClient.generateImage({
181
+ const initialApiResponse = await client.generateImage({
178
182
  model: model,
179
183
  ...options.input,
180
184
  });
@@ -182,7 +186,7 @@ export class yetter {
182
186
  const requestId = initialApiResponse.request_id;
183
187
  const responseUrl = initialApiResponse.response_url;
184
188
  const cancelUrl = initialApiResponse.cancel_url;
185
- const sseStreamUrl = `${apiClient.getApiEndpoint()}/${model}/requests/${requestId}/status/stream`;
189
+ const sseStreamUrl = `${client.getApiEndpoint()}/${model}/requests/${requestId}/status/stream`;
186
190
 
187
191
  let eventSource: EventSource;
188
192
  let streamEnded = false;
@@ -211,7 +215,7 @@ export class yetter {
211
215
  // Check for terminal events to resolve/reject the donePromise
212
216
  if (event.status === "COMPLETED") {
213
217
  streamEnded = true;
214
- apiClient.getResponse({ url: responseUrl })
218
+ client.getResponse({ url: responseUrl })
215
219
  .then(resolveDonePromise)
216
220
  .catch(rejectDonePromise)
217
221
  .finally(() => this.close());
@@ -314,7 +318,7 @@ export class yetter {
314
318
  cancel: async () => {
315
319
  controller.close();
316
320
  try {
317
- await apiClient.cancel({ url: cancelUrl });
321
+ await client.cancel({ url: cancelUrl });
318
322
  console.log(`Stream for ${requestId} - underlying request cancelled.`);
319
323
  } catch (e: any) {
320
324
  console.error(`Error cancelling underlying request for stream ${requestId}:`, e.message);
package/src/types.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export interface ClientOptions {
2
2
  apiKey: string;
3
3
  endpoint?: string;
4
+ is_bearer?: boolean;
4
5
  }
5
6
 
6
7
  export interface GenerateImageRequest {