corent-sdk 0.1.0 → 0.3.0
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/README.md +129 -4
- package/dist/index.cjs +288 -16
- package/dist/index.d.cts +262 -7
- package/dist/index.d.ts +262 -7
- package/dist/index.js +288 -16
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Corent TypeScript SDK — one API for AI image, video, and
|
|
2
|
+
* Corent TypeScript SDK — one API for AI image, video, voice, and text.
|
|
3
3
|
*
|
|
4
4
|
* import { Corent } from "corent-sdk";
|
|
5
5
|
* const client = new Corent("co_live_...");
|
|
@@ -16,6 +16,8 @@ interface GeneratedImage {
|
|
|
16
16
|
/** MEASURED pixels of the delivered file — Corent parses the file, never echoes the request. */
|
|
17
17
|
width?: number;
|
|
18
18
|
height?: number;
|
|
19
|
+
/** The tier that served it ("image-premium"), or the model you pinned,
|
|
20
|
+
* always in its published spelling ("corent-flux-schnell"). */
|
|
19
21
|
model?: string;
|
|
20
22
|
costCents?: number;
|
|
21
23
|
}
|
|
@@ -26,15 +28,90 @@ interface GeneratedVideo {
|
|
|
26
28
|
height?: number;
|
|
27
29
|
resolution?: string;
|
|
28
30
|
durationS?: number;
|
|
31
|
+
/** The tier that served it ("video-premium"), or the model you pinned,
|
|
32
|
+
* always in its published spelling ("corent-seedance-2.0"). */
|
|
29
33
|
model?: string;
|
|
30
34
|
costCents?: number;
|
|
31
35
|
}
|
|
32
36
|
interface GeneratedSpeech {
|
|
33
37
|
id: string;
|
|
34
38
|
url: string;
|
|
39
|
+
/** The tier that served it ("corent-speech-tts"), or the model you pinned,
|
|
40
|
+
* always in its published spelling ("corent-eleven-multilingual-v2"). */
|
|
35
41
|
model?: string;
|
|
36
42
|
costCents?: number;
|
|
37
43
|
}
|
|
44
|
+
/** One voice `speech.generate` accepts. Descriptors are neutral labels a
|
|
45
|
+
* picker can filter on; no supplier or model name is published. */
|
|
46
|
+
interface Voice {
|
|
47
|
+
voice_id: string;
|
|
48
|
+
name?: string;
|
|
49
|
+
preview_url?: string;
|
|
50
|
+
gender?: string;
|
|
51
|
+
age?: string;
|
|
52
|
+
accent?: string;
|
|
53
|
+
use_case?: string;
|
|
54
|
+
}
|
|
55
|
+
interface Balance {
|
|
56
|
+
balanceCents: number;
|
|
57
|
+
/** Reserved by generations still running. */
|
|
58
|
+
heldCents: number;
|
|
59
|
+
/** What a new request can actually spend: balance minus holds. */
|
|
60
|
+
availableCents: number;
|
|
61
|
+
}
|
|
62
|
+
/** One image in a batch. Batch items are tier-routed: to pin an exact model,
|
|
63
|
+
* use images.generate() one at a time. */
|
|
64
|
+
interface ImageBatchItem {
|
|
65
|
+
prompt: string;
|
|
66
|
+
tier?: Tier;
|
|
67
|
+
style?: string;
|
|
68
|
+
aspectRatio?: string;
|
|
69
|
+
}
|
|
70
|
+
interface VideoBatchItem {
|
|
71
|
+
prompt: string;
|
|
72
|
+
tier?: Tier;
|
|
73
|
+
style?: string;
|
|
74
|
+
aspectRatio?: string;
|
|
75
|
+
durationS?: number;
|
|
76
|
+
resolution?: "720p" | "1080p" | "4k";
|
|
77
|
+
}
|
|
78
|
+
/** The 202 from a batch submission: the batch id and one job id per item. */
|
|
79
|
+
interface SubmittedBatch {
|
|
80
|
+
batchId: string;
|
|
81
|
+
jobIds: string[];
|
|
82
|
+
}
|
|
83
|
+
interface BatchProgress {
|
|
84
|
+
batchId: string;
|
|
85
|
+
total: number;
|
|
86
|
+
completed: number;
|
|
87
|
+
failed: number;
|
|
88
|
+
pending: number;
|
|
89
|
+
jobs: {
|
|
90
|
+
id: string;
|
|
91
|
+
status: string;
|
|
92
|
+
}[];
|
|
93
|
+
}
|
|
94
|
+
/** OpenAI-shaped message, for callers driving a real conversation. */
|
|
95
|
+
interface ChatMessage {
|
|
96
|
+
role: "system" | "user" | "assistant" | "tool";
|
|
97
|
+
content?: unknown;
|
|
98
|
+
name?: string;
|
|
99
|
+
tool_call_id?: string;
|
|
100
|
+
tool_calls?: Record<string, unknown>[];
|
|
101
|
+
}
|
|
102
|
+
interface GeneratedText {
|
|
103
|
+
id: string;
|
|
104
|
+
text: string;
|
|
105
|
+
/** The tier that served it ("corent/text-premium"), or the model you pinned,
|
|
106
|
+
* always in its published spelling ("corent-claude-opus-5"). */
|
|
107
|
+
model?: string;
|
|
108
|
+
finishReason?: string;
|
|
109
|
+
/** Present when the model answered with tool calls instead of prose. */
|
|
110
|
+
toolCalls?: Record<string, unknown>[];
|
|
111
|
+
promptTokens?: number;
|
|
112
|
+
completionTokens?: number;
|
|
113
|
+
costCents?: number;
|
|
114
|
+
}
|
|
38
115
|
interface Job {
|
|
39
116
|
id: string;
|
|
40
117
|
status: "processing" | "completed" | "failed";
|
|
@@ -67,14 +144,34 @@ declare class Corent {
|
|
|
67
144
|
readonly images: Images;
|
|
68
145
|
readonly videos: Videos;
|
|
69
146
|
readonly speech: Speech;
|
|
147
|
+
readonly text: Text;
|
|
70
148
|
readonly jobs: Jobs;
|
|
149
|
+
readonly batches: Batches;
|
|
71
150
|
constructor(apiKey: string, options?: ClientOptions);
|
|
72
|
-
/** Prepaid balance in cents. */
|
|
151
|
+
/** Prepaid balance in cents. See `balance()` for what is actually spendable. */
|
|
73
152
|
balanceCents(): Promise<number>;
|
|
153
|
+
/** The full picture: the total, what running generations have reserved, and
|
|
154
|
+
* what a new request can actually spend. availableCents is the number a 402
|
|
155
|
+
* is decided against — check that one before an expensive batch. */
|
|
156
|
+
balance(): Promise<Balance>;
|
|
157
|
+
/** The voices `speech.generate` will accept as voiceId. This exists
|
|
158
|
+
* because the API requires a voice id and, until 2026-08-30, published no
|
|
159
|
+
* list of legal values. */
|
|
160
|
+
voices(): Promise<Voice[]>;
|
|
161
|
+
/** What this account has spent, by lane and over time. */
|
|
162
|
+
usage(): Promise<Record<string, unknown>>;
|
|
163
|
+
/** Live operational status of the generation tiers. Public. */
|
|
164
|
+
status(): Promise<Record<string, unknown>>;
|
|
74
165
|
/** The live tier catalog with honest min–max price ranges. Public. */
|
|
75
166
|
tiers(): Promise<Record<string, unknown>[]>;
|
|
167
|
+
/** The direct-access menu: every model you can pin by name, with its kind,
|
|
168
|
+
* quality score and live status. Names come back in their published
|
|
169
|
+
* spelling ("corent-flux-schnell") and can be passed straight back as
|
|
170
|
+
* `model`. Carries no price -- billing is flat cost-plus and the exact
|
|
171
|
+
* charge comes back on each generation. Public. */
|
|
172
|
+
models(): Promise<Record<string, unknown>[]>;
|
|
76
173
|
/** @internal */
|
|
77
|
-
request(method: string, path: string, body?: Record<string, unknown>, idempotent?: boolean): Promise<Record<string, any>>;
|
|
174
|
+
request(method: string, path: string, body?: Record<string, unknown>, idempotent?: boolean, retryTransport?: boolean, idempotencyKey?: string): Promise<Record<string, any>>;
|
|
78
175
|
/** @internal */
|
|
79
176
|
waitForJob(jobId: string, timeoutMs: number): Promise<Record<string, any>>;
|
|
80
177
|
}
|
|
@@ -82,27 +179,109 @@ declare class Images {
|
|
|
82
179
|
private c;
|
|
83
180
|
constructor(c: Corent);
|
|
84
181
|
/** Render an image. Submits as a background job and polls, so a client
|
|
85
|
-
* timeout can never lose a finished render. Pass wait:false for the Job.
|
|
182
|
+
* timeout can never lose a finished render. Pass wait:false for the Job.
|
|
183
|
+
*
|
|
184
|
+
* `model` pins an exact model from client.models() instead of letting the
|
|
185
|
+
* router choose — direct access: never substituted, flat cost-plus price.
|
|
186
|
+
* e.g. model: "corent-flux-schnell". Pass tier OR model, not both. */
|
|
86
187
|
generate(prompt: string, options?: {
|
|
87
188
|
tier?: Tier;
|
|
189
|
+
model?: string;
|
|
88
190
|
style?: string;
|
|
89
191
|
aspectRatio?: string;
|
|
192
|
+
/** 1–4 public https image URLs that keep a character, face, or product
|
|
193
|
+
* consistent across generations: the prompt is applied as an EDIT of
|
|
194
|
+
* these references. Served only by edit-capable models, which sit at
|
|
195
|
+
* premium and up — pass tier "premium" | "pro" | "max_pro" (or no tier
|
|
196
|
+
* at all), never "air" or "lite". Omit for plain text-to-image. */
|
|
197
|
+
referenceImageUrls?: string[];
|
|
198
|
+
/** Reproducibility. The same seed, prompt and model give the same
|
|
199
|
+
* image, so you can render it again and change one thing. The seed that
|
|
200
|
+
* was actually used comes back on the result. */
|
|
201
|
+
seed?: number;
|
|
202
|
+
/** What must NOT appear, e.g. "text, watermark". */
|
|
203
|
+
negativePrompt?: string;
|
|
204
|
+
/** Image-to-image: start from this picture instead of from noise.
|
|
205
|
+
* Different from referenceImageUrls, which pins an identity. */
|
|
206
|
+
sourceImageUrl?: string;
|
|
207
|
+
/** How far the render may travel from sourceImageUrl. 0 keeps it, 1 ignores it. */
|
|
208
|
+
strength?: number;
|
|
209
|
+
/** Delivered file type: png | jpeg | webp. png is the one with transparency. */
|
|
210
|
+
outputFormat?: "png" | "jpeg" | "webp";
|
|
211
|
+
/** Transparent background, for logos and cutouts. Forces png. */
|
|
212
|
+
transparent?: boolean;
|
|
213
|
+
/** Explicit pixel size. Pass both or neither. */
|
|
214
|
+
width?: number;
|
|
215
|
+
height?: number;
|
|
216
|
+
/** Corent rewrites your prompt before dispatch to get a better render.
|
|
217
|
+
* Set false to send it exactly as typed. */
|
|
218
|
+
enhancePrompt?: boolean;
|
|
219
|
+
/** Deliver the finished job to your own https endpoint instead of
|
|
220
|
+
* polling. Returns the Job immediately when set. */
|
|
221
|
+
webhookUrl?: string;
|
|
222
|
+
/** Signs each delivery: X-Corent-Signature: t=<unix>,v1=HMAC-SHA256. */
|
|
223
|
+
webhookSecret?: string;
|
|
224
|
+
/** Your own idempotency key, so a retry from another process or after a
|
|
225
|
+
* restart replays the original job instead of generating again. */
|
|
226
|
+
idempotencyKey?: string;
|
|
90
227
|
wait?: false | true;
|
|
91
228
|
timeoutMs?: number;
|
|
92
229
|
}): Promise<GeneratedImage | Job>;
|
|
230
|
+
/** Render several versions of one prompt in a single call, 2–10.
|
|
231
|
+
*
|
|
232
|
+
* Each one is a real render at the normal price, so asking for four costs
|
|
233
|
+
* four images. They come back together, and `totalCostCents` is the whole
|
|
234
|
+
* charge. Partial success is a real outcome: if three of four land you get
|
|
235
|
+
* three and are billed for three.
|
|
236
|
+
*
|
|
237
|
+
* Different from client.batches.images(), which runs DIFFERENT prompts and
|
|
238
|
+
* returns job ids to poll. This one runs the SAME prompt and waits. */
|
|
239
|
+
generateMany(prompt: string, count: number, options?: Omit<Parameters<Images["generate"]>[1], "wait">): Promise<{
|
|
240
|
+
images: GeneratedImage[];
|
|
241
|
+
totalCostCents?: number;
|
|
242
|
+
}>;
|
|
93
243
|
}
|
|
94
244
|
declare class Videos {
|
|
95
245
|
private c;
|
|
96
246
|
constructor(c: Corent);
|
|
97
247
|
/** Render a video (1–5 minutes typical). resolution: 720p | 1080p | 4k —
|
|
98
248
|
* tier-capped, clamped down rather than rejected. imageUrl animates an
|
|
99
|
-
* existing image (image-to-video).
|
|
249
|
+
* existing image (image-to-video).
|
|
250
|
+
*
|
|
251
|
+
* `model` pins an exact model from client.models() — direct access, never
|
|
252
|
+
* substituted, and duration/resolution snap to THAT model's own menu rather
|
|
253
|
+
* than a tier cap. e.g. model: "corent-seedance-2.0". Pass tier OR model,
|
|
254
|
+
* not both. */
|
|
100
255
|
generate(prompt: string, options?: {
|
|
101
256
|
tier?: Tier;
|
|
257
|
+
model?: string;
|
|
258
|
+
style?: string;
|
|
102
259
|
aspectRatio?: string;
|
|
103
260
|
durationS?: number;
|
|
104
261
|
resolution?: "720p" | "1080p" | "4k";
|
|
105
262
|
imageUrl?: string;
|
|
263
|
+
/** Ask for native sound. Some models render audio and some are
|
|
264
|
+
* silent. true routes only to models that deliver sound, so a silent
|
|
265
|
+
* model can never quietly serve the request; false prefers a silent
|
|
266
|
+
* one; omit to let routing choose. */
|
|
267
|
+
audio?: boolean;
|
|
268
|
+
/** The frame the clip should END on. With imageUrl this is the
|
|
269
|
+
* go-from-A-to-B effect. */
|
|
270
|
+
endImageUrl?: string;
|
|
271
|
+
/** Camera move: static | pan_left | pan_right | zoom_in | zoom_out |
|
|
272
|
+
* orbit_left | orbit_right | tilt_up | tilt_down. */
|
|
273
|
+
camera?: string;
|
|
274
|
+
/** What must NOT appear in the clip. */
|
|
275
|
+
negativePrompt?: string;
|
|
276
|
+
seed?: number;
|
|
277
|
+
fps?: number;
|
|
278
|
+
/** Set false to send your prompt exactly as typed. */
|
|
279
|
+
enhancePrompt?: boolean;
|
|
280
|
+
/** Deliver the finished clip to your own https endpoint instead of
|
|
281
|
+
* polling. Recommended for video, which takes 1–5 minutes. */
|
|
282
|
+
webhookUrl?: string;
|
|
283
|
+
webhookSecret?: string;
|
|
284
|
+
idempotencyKey?: string;
|
|
106
285
|
wait?: false | true;
|
|
107
286
|
timeoutMs?: number;
|
|
108
287
|
}): Promise<GeneratedVideo | Job>;
|
|
@@ -110,16 +289,92 @@ declare class Videos {
|
|
|
110
289
|
declare class Speech {
|
|
111
290
|
private c;
|
|
112
291
|
constructor(c: Corent);
|
|
113
|
-
/** Text to speech; synchronous, returns the finished audio and exact charge.
|
|
292
|
+
/** Text to speech; synchronous, returns the finished audio and exact charge.
|
|
293
|
+
* `model` pins an exact speech model from client.models(),
|
|
294
|
+
* e.g. model: "corent-eleven-multilingual-v2". */
|
|
114
295
|
generate(text: string, options?: {
|
|
115
296
|
voiceId?: string;
|
|
297
|
+
model?: string;
|
|
298
|
+
/** 0–1. Low is more expressive and more variable; high is steadier. */
|
|
299
|
+
stability?: number;
|
|
300
|
+
/** 0–1. How closely to hold the original voice's character. */
|
|
301
|
+
similarity?: number;
|
|
302
|
+
/** 0–1. Extra expressiveness. */
|
|
303
|
+
style?: number;
|
|
304
|
+
/** Playback speed; 1.0 is natural pace. */
|
|
305
|
+
speed?: number;
|
|
306
|
+
/** ISO code for the multilingual models, e.g. "en" or "pt-BR". */
|
|
307
|
+
language?: string;
|
|
308
|
+
/** "mp3" | "wav" | "pcm", or an exact "mp3_44100_128". */
|
|
309
|
+
outputFormat?: string;
|
|
310
|
+
idempotencyKey?: string;
|
|
116
311
|
}): Promise<GeneratedSpeech>;
|
|
117
312
|
}
|
|
313
|
+
interface TextOptions {
|
|
314
|
+
tier?: Tier;
|
|
315
|
+
model?: string;
|
|
316
|
+
maxTokens?: number;
|
|
317
|
+
/** OpenAI's newer alias; honoured by the API when maxTokens is absent. */
|
|
318
|
+
maxCompletionTokens?: number;
|
|
319
|
+
temperature?: number;
|
|
320
|
+
tools?: Record<string, unknown>[];
|
|
321
|
+
/** "auto" | "none" | "required" | { type: "function", function: { name } } */
|
|
322
|
+
toolChoice?: unknown;
|
|
323
|
+
responseFormat?: Record<string, unknown>;
|
|
324
|
+
}
|
|
325
|
+
declare class Text {
|
|
326
|
+
private c;
|
|
327
|
+
constructor(c: Corent);
|
|
328
|
+
/** One prompt in, the finished text out. `system` frames the request.
|
|
329
|
+
*
|
|
330
|
+
* `model` pins an exact text model from client.models() (kind "text"),
|
|
331
|
+
* e.g. model: "corent-claude-opus-5"; otherwise `tier` picks the routed
|
|
332
|
+
* lane. Pass tier OR model, not both. */
|
|
333
|
+
generate(prompt: string, options?: TextOptions & {
|
|
334
|
+
system?: string;
|
|
335
|
+
}): Promise<GeneratedText>;
|
|
336
|
+
/** A full OpenAI-shaped conversation, including tool results. Streaming is
|
|
337
|
+
* not wrapped here — point any OpenAI client at https://api.corent.tech/v1
|
|
338
|
+
* with your Corent key for that. */
|
|
339
|
+
chat(messages: ChatMessage[], options?: TextOptions): Promise<GeneratedText>;
|
|
340
|
+
}
|
|
341
|
+
/** Up to 50 renders in one call. Every item bills at the normal rate, so a
|
|
342
|
+
* 30-item image batch costs 30 generations — check client.balance() first.
|
|
343
|
+
* Asynchronous: submit returns immediately, then poll progress() or give the
|
|
344
|
+
* server a webhookUrl and let it deliver each item. */
|
|
345
|
+
declare class Batches {
|
|
346
|
+
private c;
|
|
347
|
+
constructor(c: Corent);
|
|
348
|
+
images(items: ImageBatchItem[], options?: {
|
|
349
|
+
webhookUrl?: string;
|
|
350
|
+
webhookSecret?: string;
|
|
351
|
+
idempotencyKey?: string;
|
|
352
|
+
}): Promise<SubmittedBatch>;
|
|
353
|
+
videos(items: VideoBatchItem[], options?: {
|
|
354
|
+
webhookUrl?: string;
|
|
355
|
+
webhookSecret?: string;
|
|
356
|
+
idempotencyKey?: string;
|
|
357
|
+
}): Promise<SubmittedBatch>;
|
|
358
|
+
/** How far along a submitted batch is, and each item's job id. Fetch a
|
|
359
|
+
* finished item's media with client.jobs.get(). */
|
|
360
|
+
progress(batchId: string): Promise<BatchProgress>;
|
|
361
|
+
private submit;
|
|
362
|
+
}
|
|
118
363
|
declare class Jobs {
|
|
119
364
|
private c;
|
|
120
365
|
constructor(c: Corent);
|
|
121
366
|
get(jobId: string): Promise<Job>;
|
|
367
|
+
/** Stop a job that has not finished and release its money hold.
|
|
368
|
+
*
|
|
369
|
+
* Charges nothing. A job that completed just before the cancel landed stays
|
|
370
|
+
* completed and stays billed for what was really delivered — `cancelled`
|
|
371
|
+
* says which happened. */
|
|
372
|
+
cancel(jobId: string): Promise<{
|
|
373
|
+
id: string;
|
|
374
|
+
status: string;
|
|
375
|
+
cancelled: boolean;
|
|
376
|
+
}>;
|
|
122
377
|
wait(jobId: string, timeoutMs?: number): Promise<Job>;
|
|
123
378
|
}
|
|
124
379
|
|
|
125
|
-
export { Corent, CorentError, type GeneratedImage, type GeneratedSpeech, type GeneratedVideo, GenerationFailedError, InsufficientBalanceError, InvalidRequestError, type Job, RateLimitedError, type Tier };
|
|
380
|
+
export { type Balance, type BatchProgress, type ChatMessage, Corent, CorentError, type GeneratedImage, type GeneratedSpeech, type GeneratedText, type GeneratedVideo, GenerationFailedError, type ImageBatchItem, InsufficientBalanceError, InvalidRequestError, type Job, RateLimitedError, type SubmittedBatch, type Tier, type VideoBatchItem, type Voice };
|