craterview 0.4.27 → 0.4.31

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.
Files changed (3) hide show
  1. package/README.md +6 -5
  2. package/index.ts +19 -5
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -152,7 +152,7 @@ above tells the two apart.
152
152
 
153
153
  | Class | Meaning |
154
154
  |---|---|
155
- | `RateLimited` | 429 — one of five limits, and `.code` says which: `rate_limited` (the key's request rate), `too_many_uploads`, `too_many_keys`, `too_many_jobs` or `queue_full`. `.retryAfter` is seconds to wait: until the window rolls over for the two per-minute limits, until a new key can be made for the hourly one, or an interval to poll on for the other two. |
155
+ | `RateLimited` | 429 — one of five limits, and `.code` says which: `rate_limited` (the account's request rate), `too_many_uploads`, `too_many_keys`, `too_many_jobs` or `queue_full`. `.retryAfter` is seconds to wait: until the window rolls over for the two per-minute limits, until a new key can be made for the hourly one, or an interval to poll on for the other two. |
156
156
  | `JobFailed` | The job ran and did not succeed. `.message` says what you can do about it; `.errorCode` is the half to branch on; `.jobId` is the job. |
157
157
  | `InvalidSignature` | A webhook delivery did not verify. Do not act on its body. |
158
158
  | `CraterViewError` | Everything else, including 4xx and 5xx from the API, and storage refusing an upload or a download. |
@@ -187,8 +187,9 @@ result's file are getters onto `result.output` rather than separate fields — t
187
187
  those links once. A model with no file to hand back returns its answer in `result` and leaves
188
188
  every one of them null; the fields it answers with are its `result_schema` in `cv.models()`.
189
189
 
190
- `credits` is the only figure about cost the API states, and the price is fixed and published
191
- per model, so an invoice reconciles against `credits` alone. For how long a job took, subtract
190
+ `credits` is the only figure about cost the API states, and each model publishes its price in
191
+ `cv.models()` — `credits_per_image`, and `credit_steps` where a smaller image costs less — so
192
+ an invoice reconciles against `credits` alone. For how long a job took, subtract
192
193
  `createdAt` from `finishedAt` — that is the wait you had, queue included.
193
194
 
194
195
  **Uploads declare their size.** `upload()` and `run()` take the length from the `Blob`
@@ -197,8 +198,8 @@ accepts exactly that length and nothing else. You do not pass it — it is read
197
198
  in hand, which is what makes it impossible to get wrong.
198
199
 
199
200
  **Running out of credit does not stop you.** A job submitted against a balance of zero is
200
- accepted and run, and charged when it succeeds — it goes to the community queue, which runs
201
- on shared, free capacity and can wait longer at busy times. It comes back with `community`
201
+ accepted, and unless a subscription has work left this period it runs free on the community
202
+ queue, which runs on shared, free capacity and can wait longer at busy times. It comes back with `community`
202
203
  set, and `usage()` reports the same flag for your next job before you send it. There is no
203
204
  payment error to handle: paying — with credit, or with a subscription — moves work onto paid
204
205
  compute that scales with demand, rather than buying the right to submit.
package/index.ts CHANGED
@@ -18,7 +18,7 @@ import { imageSize } from "image-size";
18
18
  // Mirrored from package.json, which is the number a release bumps. It cannot be imported
19
19
  // from there — this ships as TypeScript, so the import would have to resolve in the
20
20
  // consumer's toolchain — so test/version.test.ts asserts the two agree.
21
- export const VERSION = "0.4.27";
21
+ export const VERSION = "0.4.31";
22
22
  const DEFAULT_BASE_URL = "https://api.craterview.ai";
23
23
  // The server rejects a longer wait outright, so asking for one costs a 422 rather than the
24
24
  // wait you asked for. `run()` clamps to this rather than letting that happen.
@@ -154,7 +154,8 @@ export class CraterViewError extends Error {
154
154
  * says which — `rate_limited`, `too_many_keys`, `too_many_uploads`, `too_many_jobs` or
155
155
  * `queue_full`, in this order:
156
156
  *
157
- * - the key's request rate, per minute;
157
+ * - the account's request rate, per minute — counted across all its keys, for submitting
158
+ * jobs, creating keys and gallery calls. No other call counts;
158
159
  * - the account's new keys, per hour — counted across all its keys, and only from
159
160
  * `createKey`;
160
161
  * - the account's upload URLs, per minute — counted across all its keys;
@@ -436,8 +437,23 @@ export interface ModelInfo {
436
437
  * runs, as `input_too_small`, and is not charged. The same for every key.
437
438
  */
438
439
  min_input_side: number;
439
- /** Whole credits. The price is flat and knowable before you send anything. */
440
+ /**
441
+ * Whole credits: what one still image costs, or the most one costs where `credit_steps`
442
+ * charges less for a smaller one. Knowable before you send anything.
443
+ */
440
444
  credits_per_image: number;
445
+ /**
446
+ * A lower price for a smaller still image, or null where every one costs
447
+ * `credits_per_image`. `by` is `megapixels` — the part of the image a job works on, the
448
+ * region you name with `roi` or the whole image, in millions of pixels, divided by 4 at
449
+ * `binning` 2x2, 9 at 3x3 and 16 at 4x4 — or `faces`, the faces the model redraws, counted
450
+ * when the job finishes. A still costs the first step its measure is at or under, and
451
+ * `credits_per_image` past the last.
452
+ */
453
+ credit_steps?: {
454
+ by: "megapixels" | "faces";
455
+ steps: { up_to: number; credits: number }[];
456
+ } | null;
441
457
  /** Whole credits. Null means this model takes stills only. */
442
458
  credits_per_video_second?: number | null;
443
459
  reference_fps: number;
@@ -480,7 +496,6 @@ export interface KeyInfo {
480
496
  created_at: string | null;
481
497
  /** When it stopped working, or null while it still does. */
482
498
  revoked_at?: string;
483
- rate_limit_per_minute: number;
484
499
  /**
485
500
  * Whether this is the key you are calling with. It cannot be revoked by id while it is;
486
501
  * `DELETE /v1/keys/current` ends it on request, unless it is the account's only way
@@ -496,7 +511,6 @@ export interface NewKey {
496
511
  key: string;
497
512
  prefix: string;
498
513
  name: string;
499
- rate_limit_per_minute: number;
500
514
  }
501
515
 
502
516
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "craterview",
3
- "version": "0.4.27",
3
+ "version": "0.4.31",
4
4
  "dependencies": {
5
5
  "image-size": "^2.0.4"
6
6
  },