@spicyapi/sdk 0.2.1 → 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 +53 -4
- package/contracts/openapi.yaml +192 -3
- package/dist/src/generated/openapi.d.ts +213 -2
- package/dist/src/generated/openapi.d.ts.map +1 -1
- package/dist/src/generated/package-version.d.ts +1 -1
- package/dist/src/generated/package-version.js +1 -1
- package/dist/src/sdk/base64.d.ts +6 -0
- package/dist/src/sdk/base64.d.ts.map +1 -0
- package/dist/src/sdk/base64.js +47 -0
- package/dist/src/sdk/base64.js.map +1 -0
- package/dist/src/sdk/client.d.ts +6 -1
- package/dist/src/sdk/client.d.ts.map +1 -1
- package/dist/src/sdk/client.js +159 -21
- package/dist/src/sdk/client.js.map +1 -1
- package/dist/src/sdk/types.d.ts +32 -0
- package/dist/src/sdk/types.d.ts.map +1 -1
- package/package.json +3 -3
package/README.md
CHANGED
|
@@ -16,9 +16,31 @@ const models = await client.listModels({ includeSchema: true });
|
|
|
16
16
|
```
|
|
17
17
|
|
|
18
18
|
Set `SPICY_API_KEY` with your process secret manager. Task creation and retry may reserve funds; use
|
|
19
|
-
stable idempotency keys and explicit user confirmation.
|
|
20
|
-
|
|
21
|
-
unchanged input, `quoteId` and `expectedCost`.
|
|
19
|
+
stable idempotency keys and explicit user confirmation. When a caller needs an exact price
|
|
20
|
+
confirmation, call `quoteTask` with the request, display its `estimatedCost`, `maxCharge` and
|
|
21
|
+
`expiresAt`, then pass unchanged input, `quoteId` and `expectedCost` to `createTask` or `run`.
|
|
22
|
+
Pre-authorized server workflows can submit directly at current pricing; separate health, balance and
|
|
23
|
+
quote requests are not mandatory API steps.
|
|
24
|
+
|
|
25
|
+
## Submit and wait
|
|
26
|
+
|
|
27
|
+
```ts
|
|
28
|
+
const model = process.env.SPICY_MODEL;
|
|
29
|
+
const operationId = process.env.SPICY_IDEMPOTENCY_KEY;
|
|
30
|
+
if (!model || !operationId) throw new Error("Set a model and a persisted operation key");
|
|
31
|
+
const task = await client.run(
|
|
32
|
+
{ model, input: { prompt: "A quiet mountain lake" } },
|
|
33
|
+
{ idempotencyKey: operationId, onAccepted: ({ taskId }) => console.log({ taskId }) },
|
|
34
|
+
);
|
|
35
|
+
if (task.state === "succeeded") {
|
|
36
|
+
console.log(task.output?.assets?.[0]?.url);
|
|
37
|
+
}
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Use a model and input supported by its current schema. `run` submits once and handles adaptive
|
|
41
|
+
polling, including pending media transfer. Its local timeout includes submission and waiting; timing
|
|
42
|
+
out or aborting does not cancel the accepted task. Resume with the saved task ID. Use a webhook for
|
|
43
|
+
background jobs to avoid polling entirely.
|
|
22
44
|
|
|
23
45
|
Documentation: <https://spicyapi.ai/en/docs>
|
|
24
46
|
|
|
@@ -85,7 +107,12 @@ explicit type extension in the official client. Reasoning tokens are already inc
|
|
|
85
107
|
|
|
86
108
|
Pass a publicly accessible HTTPS image, video, or audio URL directly in the field specified by the
|
|
87
109
|
model schema. Uploading is optional: local files use `createUploadUrl` → PUT → `commitUploadedFile`,
|
|
88
|
-
then the returned account-bound `spicy://` URI (valid for one day).
|
|
110
|
+
then the returned account-bound `spicy://` URI (valid for one day). `uploadFile` wraps these steps;
|
|
111
|
+
`uploadBase64` also accepts a Data URI or raw standard Base64 with an explicit `contentType`. Small
|
|
112
|
+
schema-declared image fields can accept Data URIs directly in `input` (1 MiB decoded per image, 2
|
|
113
|
+
MiB total JSON body, with documented pixel limits). The upload helper is separate and supports
|
|
114
|
+
larger files within upload and model limits. See the
|
|
115
|
+
[media guide](https://docs.spicyapi.ai/en/docs/media).
|
|
89
116
|
|
|
90
117
|
`getTask` and `waitForTask` return ready media in `output.assets`, including `url`, `expiresAt`,
|
|
91
118
|
MIME, and available dimensions, duration, and byte count. Download `asset.url` directly without
|
|
@@ -96,3 +123,25 @@ to refresh a URL; `createDownloadUrl` remains available for older integrations.
|
|
|
96
123
|
V2 webhooks use the same result fields. A retry keeps the business event and `request_id`, but
|
|
97
124
|
refreshes `url` and `expiresAt`. Verify the signature against the exact received body and
|
|
98
125
|
deduplicate using `request_id`, not a full-body hash. V1 payloads remain unchanged.
|
|
126
|
+
|
|
127
|
+
## Task history
|
|
128
|
+
|
|
129
|
+
`listTasks` reads one page of metadata for the current API key. It does not fetch each task's
|
|
130
|
+
inputs, results, or media URLs. Keep the UTC dates fixed while paging and pass the returned cursor
|
|
131
|
+
unchanged:
|
|
132
|
+
|
|
133
|
+
```ts
|
|
134
|
+
const filters = { from: "2026-09-01", to: "2026-09-07", limit: 20 };
|
|
135
|
+
const page = await client.listTasks(filters);
|
|
136
|
+
if (page.hasMore && page.nextCursor) {
|
|
137
|
+
const nextPage = await client.listTasks({ ...filters, cursor: page.nextCursor });
|
|
138
|
+
console.log(nextPage.items);
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
The UTC interval is `[from,to)`, defaults to seven days ending tomorrow UTC, and cannot exceed 92
|
|
143
|
+
days. Page size defaults to 20 and is capped at 100. Optional `state` and `model` filters narrow the
|
|
144
|
+
results. Each item's `cost` remains an exact decimal USD string; it is final only when `settled` is
|
|
145
|
+
true. Hidden tasks are excluded, so use `getUsage` for settled spending reports. Use `getTask` for a
|
|
146
|
+
selected result, not automatically for every item. History is for discovery and recovery; use `run`,
|
|
147
|
+
`waitForTask`, or webhooks for normal completion tracking.
|
package/contracts/openapi.yaml
CHANGED
|
@@ -353,6 +353,106 @@ paths:
|
|
|
353
353
|
'404': { $ref: '#/components/responses/NotFound' }
|
|
354
354
|
'429': { $ref: '#/components/responses/RateLimited' }
|
|
355
355
|
'500': { $ref: '#/components/responses/ServerError' }
|
|
356
|
+
/api/v1/jobs:
|
|
357
|
+
get:
|
|
358
|
+
tags: [Tasks]
|
|
359
|
+
operationId: listTasks
|
|
360
|
+
summary: List task history for the authenticated API key
|
|
361
|
+
description: |
|
|
362
|
+
Returns only visible tasks created by this API key and its account,
|
|
363
|
+
newest first by createdAt and taskId. The list contains metadata only;
|
|
364
|
+
use recordInfo for a selected task's result. No input, output, signed
|
|
365
|
+
media URL, or execution-channel information is included.
|
|
366
|
+
Dates form a UTC half-open interval [from,to), up to 92 days.
|
|
367
|
+
Default to is tomorrow in UTC; omitted from is seven days before to.
|
|
368
|
+
Keep all filters, including explicit from/to dates, unchanged while
|
|
369
|
+
paginating with nextCursor. Pages read live state, not a frozen snapshot.
|
|
370
|
+
Unknown, duplicate, or empty query parameters are rejected. Queries
|
|
371
|
+
have a five-second server budget and return 503 on timeout.
|
|
372
|
+
parameters:
|
|
373
|
+
- name: from
|
|
374
|
+
in: query
|
|
375
|
+
schema: { type: string, format: date }
|
|
376
|
+
description: Inclusive UTC date in YYYY-MM-DD format.
|
|
377
|
+
- name: to
|
|
378
|
+
in: query
|
|
379
|
+
schema: { type: string, format: date }
|
|
380
|
+
description: Exclusive UTC date in YYYY-MM-DD format.
|
|
381
|
+
- name: state
|
|
382
|
+
in: query
|
|
383
|
+
schema: { type: string, enum: [queued, running, succeeded, failed, canceled, expired] }
|
|
384
|
+
- name: model
|
|
385
|
+
in: query
|
|
386
|
+
schema: { type: string }
|
|
387
|
+
description: Exact catalog model identifier or a declared alias.
|
|
388
|
+
- name: limit
|
|
389
|
+
in: query
|
|
390
|
+
schema: { type: integer, minimum: 1, maximum: 100, default: 20 }
|
|
391
|
+
- name: cursor
|
|
392
|
+
in: query
|
|
393
|
+
schema: { type: string }
|
|
394
|
+
description: Opaque nextCursor from the previous page; do not construct it yourself.
|
|
395
|
+
responses:
|
|
396
|
+
'200':
|
|
397
|
+
description: Current-key task summaries without prompt or result payloads.
|
|
398
|
+
headers:
|
|
399
|
+
Cache-Control:
|
|
400
|
+
schema: { type: string, const: no-store }
|
|
401
|
+
content:
|
|
402
|
+
application/json:
|
|
403
|
+
schema: { $ref: '#/components/schemas/APIKeyTaskListEnvelope' }
|
|
404
|
+
'400': { $ref: '#/components/responses/BadRequest' }
|
|
405
|
+
'401': { $ref: '#/components/responses/Unauthorized' }
|
|
406
|
+
'403': { $ref: '#/components/responses/Forbidden' }
|
|
407
|
+
'429': { $ref: '#/components/responses/RateLimited' }
|
|
408
|
+
'500': { $ref: '#/components/responses/ServerError' }
|
|
409
|
+
'503': { $ref: '#/components/responses/Unavailable' }
|
|
410
|
+
/api/v1/usage:
|
|
411
|
+
get:
|
|
412
|
+
tags: [Account]
|
|
413
|
+
operationId: getUsage
|
|
414
|
+
summary: Get usage for the authenticated API key
|
|
415
|
+
description: |
|
|
416
|
+
Only tasks created by this API key and its account are included,
|
|
417
|
+
including hidden historical tasks. Other keys and workspaces cannot
|
|
418
|
+
be selected. Unknown or repeated query parameters are rejected.
|
|
419
|
+
Dates form a UTC half-open interval [from,to), up to 92 days.
|
|
420
|
+
The default to is tomorrow in UTC; omitted from is seven days before to.
|
|
421
|
+
Calls are attributed to task creation time. Spend sums only settled
|
|
422
|
+
actual charges for those tasks, never pending holds. Late settlement
|
|
423
|
+
can change a previous day's spend. These are task usage totals, not
|
|
424
|
+
a statement of cash movements or remaining API-key budget.
|
|
425
|
+
An additional account-wide token bucket allows a burst of 30 requests
|
|
426
|
+
and replenishes 30 tokens per minute, shared by all keys on the account.
|
|
427
|
+
Observe Retry-After on 429. This reporting limit fails closed when its
|
|
428
|
+
limiter is unavailable. Queries have a five-second server budget;
|
|
429
|
+
a timeout returns 503 and suggests retrying a shorter date range.
|
|
430
|
+
parameters:
|
|
431
|
+
- name: from
|
|
432
|
+
in: query
|
|
433
|
+
schema: { type: string, format: date }
|
|
434
|
+
description: Inclusive UTC date in YYYY-MM-DD format.
|
|
435
|
+
- name: to
|
|
436
|
+
in: query
|
|
437
|
+
schema: { type: string, format: date }
|
|
438
|
+
description: Exclusive UTC date in YYYY-MM-DD format.
|
|
439
|
+
responses:
|
|
440
|
+
'200':
|
|
441
|
+
description: Current-key usage with exact USD decimal strings and sparse daily/model buckets.
|
|
442
|
+
headers:
|
|
443
|
+
Cache-Control:
|
|
444
|
+
schema: { type: string, const: no-store }
|
|
445
|
+
X-RateLimit-Limit: { $ref: '#/components/headers/RateLimitLimit' }
|
|
446
|
+
X-RateLimit-Remaining: { $ref: '#/components/headers/RateLimitRemaining' }
|
|
447
|
+
content:
|
|
448
|
+
application/json:
|
|
449
|
+
schema: { $ref: '#/components/schemas/APIKeyUsageEnvelope' }
|
|
450
|
+
'400': { $ref: '#/components/responses/BadRequest' }
|
|
451
|
+
'401': { $ref: '#/components/responses/Unauthorized' }
|
|
452
|
+
'403': { $ref: '#/components/responses/Forbidden' }
|
|
453
|
+
'429': { $ref: '#/components/responses/RateLimited' }
|
|
454
|
+
'500': { $ref: '#/components/responses/ServerError' }
|
|
455
|
+
'503': { $ref: '#/components/responses/Unavailable' }
|
|
356
456
|
/api/v1/chat/credit:
|
|
357
457
|
get:
|
|
358
458
|
tags: [Account]
|
|
@@ -823,7 +923,16 @@ components:
|
|
|
823
923
|
description: Exact `model` value from the model catalog.
|
|
824
924
|
input:
|
|
825
925
|
type: object
|
|
826
|
-
description:
|
|
926
|
+
description: >-
|
|
927
|
+
Validated against the selected model's inputSchema. Declared image fields accept
|
|
928
|
+
public HTTPS URLs, committed spicy:// file URIs, or standard Base64 Data URIs
|
|
929
|
+
(image/jpeg, image/png, image/webp, image/gif). Inline images are limited to
|
|
930
|
+
1048576 decoded bytes and 8388608 pixels each, 8192 pixels per side, and
|
|
931
|
+
16 images / 16777216 pixels in total. The complete JSON request must fit within
|
|
932
|
+
2097152 bytes. Model-specific limits still apply. Bare Base64, SVG and inline
|
|
933
|
+
audio/video are not accepted; use HTTPS or file uploads instead. Inline images
|
|
934
|
+
are stored as account-bound uploaded files; returned input contains file URIs,
|
|
935
|
+
never the original Base64 bytes. Quote validation does not upload or reserve funds.
|
|
827
936
|
additionalProperties: true
|
|
828
937
|
callBackUrl:
|
|
829
938
|
type: string
|
|
@@ -863,9 +972,10 @@ components:
|
|
|
863
972
|
data: { $ref: '#/components/schemas/TaskQuoteResponse' }
|
|
864
973
|
CreateTaskResponse:
|
|
865
974
|
type: object
|
|
866
|
-
required: [taskId, state, estimatedCost]
|
|
975
|
+
required: [taskId, state, estimatedCost, deadlineAt]
|
|
867
976
|
properties:
|
|
868
977
|
taskId: { type: string }
|
|
978
|
+
deadlineAt: { type: string, format: date-time, description: Server execution deadline fixed at acceptance; not a local wait timeout or result URL expiry. Idempotent replays retain the original deadline. }
|
|
869
979
|
state:
|
|
870
980
|
type: string
|
|
871
981
|
enum: [queued, running, succeeded, failed, canceled, expired]
|
|
@@ -941,7 +1051,7 @@ components:
|
|
|
941
1051
|
type: string
|
|
942
1052
|
enum: [queued, running, succeeded, failed, canceled, expired]
|
|
943
1053
|
input:
|
|
944
|
-
description: Normalized model input. Omitted after retention redaction.
|
|
1054
|
+
description: Normalized model input; inline images become account-bound file URIs. Omitted after retention redaction.
|
|
945
1055
|
type: object
|
|
946
1056
|
additionalProperties: true
|
|
947
1057
|
output: { $ref: '#/components/schemas/TaskOutput' }
|
|
@@ -952,6 +1062,7 @@ components:
|
|
|
952
1062
|
type: boolean
|
|
953
1063
|
description: When false, `cost` is the held estimate. On success the final charge is capped at that hold; unused funds are released. Failed or expired tasks release the hold in full.
|
|
954
1064
|
createdAt: { type: string, format: date-time }
|
|
1065
|
+
deadlineAt: { type: string, format: date-time, description: Server execution deadline. Present in current responses; historical stored webhook events may omit it. Not the result retention or URL expiry time. }
|
|
955
1066
|
completedAt: { type: string, format: date-time }
|
|
956
1067
|
TaskRecordEnvelope:
|
|
957
1068
|
allOf:
|
|
@@ -976,6 +1087,84 @@ components:
|
|
|
976
1087
|
error_message: { type: string }
|
|
977
1088
|
cost: { $ref: '#/components/schemas/USDString' }
|
|
978
1089
|
created_at: { type: string, format: date-time }
|
|
1090
|
+
APIKeyTaskItem:
|
|
1091
|
+
type: object
|
|
1092
|
+
additionalProperties: false
|
|
1093
|
+
required: [taskId, model, state, cost, settled, createdAt, deadlineAt]
|
|
1094
|
+
properties:
|
|
1095
|
+
taskId: { type: string }
|
|
1096
|
+
model: { type: string, description: Public model identifier. }
|
|
1097
|
+
state: { type: string, enum: [queued, running, succeeded, failed, canceled, expired] }
|
|
1098
|
+
cost:
|
|
1099
|
+
allOf:
|
|
1100
|
+
- $ref: '#/components/schemas/USDString'
|
|
1101
|
+
description: Final charged USD if settled; otherwise the current held estimate.
|
|
1102
|
+
settled: { type: boolean }
|
|
1103
|
+
createdAt: { type: string, format: date-time }
|
|
1104
|
+
deadlineAt: { type: string, format: date-time }
|
|
1105
|
+
completedAt: { type: string, format: date-time }
|
|
1106
|
+
APIKeyTaskListResponse:
|
|
1107
|
+
type: object
|
|
1108
|
+
additionalProperties: false
|
|
1109
|
+
required: [items, hasMore]
|
|
1110
|
+
properties:
|
|
1111
|
+
items:
|
|
1112
|
+
type: array
|
|
1113
|
+
items: { $ref: '#/components/schemas/APIKeyTaskItem' }
|
|
1114
|
+
hasMore: { type: boolean }
|
|
1115
|
+
nextCursor: { type: string, description: Present only when hasMore is true. }
|
|
1116
|
+
APIKeyTaskListEnvelope:
|
|
1117
|
+
allOf:
|
|
1118
|
+
- $ref: '#/components/schemas/EnvelopeBase'
|
|
1119
|
+
- type: object
|
|
1120
|
+
required: [data]
|
|
1121
|
+
properties:
|
|
1122
|
+
code: { type: integer, const: 200 }
|
|
1123
|
+
msg: { type: string, const: success }
|
|
1124
|
+
data: { $ref: '#/components/schemas/APIKeyTaskListResponse' }
|
|
1125
|
+
APIKeyUsageResponse:
|
|
1126
|
+
type: object
|
|
1127
|
+
additionalProperties: false
|
|
1128
|
+
required: [from, to, currency, totalCalls, totalSpend, days, models]
|
|
1129
|
+
properties:
|
|
1130
|
+
from: { type: string, format: date }
|
|
1131
|
+
to: { type: string, format: date }
|
|
1132
|
+
currency: { type: string, const: USD }
|
|
1133
|
+
totalCalls: { type: integer, format: int64, minimum: 0 }
|
|
1134
|
+
totalSpend: { $ref: '#/components/schemas/USDString' }
|
|
1135
|
+
days:
|
|
1136
|
+
type: array
|
|
1137
|
+
items: { $ref: '#/components/schemas/UsageDayItem' }
|
|
1138
|
+
models:
|
|
1139
|
+
type: array
|
|
1140
|
+
items: { $ref: '#/components/schemas/UsageModelItem' }
|
|
1141
|
+
UsageDayItem:
|
|
1142
|
+
type: object
|
|
1143
|
+
additionalProperties: false
|
|
1144
|
+
required: [day, calls, succeeded, failed, spend]
|
|
1145
|
+
properties:
|
|
1146
|
+
day: { type: string, format: date }
|
|
1147
|
+
calls: { type: integer, format: int64, minimum: 0 }
|
|
1148
|
+
succeeded: { type: integer, format: int64, minimum: 0 }
|
|
1149
|
+
failed: { type: integer, format: int64, minimum: 0 }
|
|
1150
|
+
spend: { $ref: '#/components/schemas/USDString' }
|
|
1151
|
+
UsageModelItem:
|
|
1152
|
+
type: object
|
|
1153
|
+
additionalProperties: false
|
|
1154
|
+
required: [model, calls, succeeded, failed, spend]
|
|
1155
|
+
properties:
|
|
1156
|
+
model: { type: string, description: Public model identifier. }
|
|
1157
|
+
calls: { type: integer, format: int64, minimum: 0 }
|
|
1158
|
+
succeeded: { type: integer, format: int64, minimum: 0 }
|
|
1159
|
+
failed: { type: integer, format: int64, minimum: 0 }
|
|
1160
|
+
spend: { $ref: '#/components/schemas/USDString' }
|
|
1161
|
+
APIKeyUsageEnvelope:
|
|
1162
|
+
allOf:
|
|
1163
|
+
- $ref: '#/components/schemas/EnvelopeBase'
|
|
1164
|
+
- type: object
|
|
1165
|
+
required: [data]
|
|
1166
|
+
properties:
|
|
1167
|
+
data: { $ref: '#/components/schemas/APIKeyUsageResponse' }
|
|
979
1168
|
Balance:
|
|
980
1169
|
type: object
|
|
981
1170
|
required: [available, held, total]
|
|
@@ -179,6 +179,68 @@ export interface paths {
|
|
|
179
179
|
patch?: never;
|
|
180
180
|
trace?: never;
|
|
181
181
|
};
|
|
182
|
+
"/api/v1/jobs": {
|
|
183
|
+
parameters: {
|
|
184
|
+
query?: never;
|
|
185
|
+
header?: never;
|
|
186
|
+
path?: never;
|
|
187
|
+
cookie?: never;
|
|
188
|
+
};
|
|
189
|
+
/**
|
|
190
|
+
* List task history for the authenticated API key
|
|
191
|
+
* @description Returns only visible tasks created by this API key and its account,
|
|
192
|
+
* newest first by createdAt and taskId. The list contains metadata only;
|
|
193
|
+
* use recordInfo for a selected task's result. No input, output, signed
|
|
194
|
+
* media URL, or execution-channel information is included.
|
|
195
|
+
* Dates form a UTC half-open interval [from,to), up to 92 days.
|
|
196
|
+
* Default to is tomorrow in UTC; omitted from is seven days before to.
|
|
197
|
+
* Keep all filters, including explicit from/to dates, unchanged while
|
|
198
|
+
* paginating with nextCursor. Pages read live state, not a frozen snapshot.
|
|
199
|
+
* Unknown, duplicate, or empty query parameters are rejected. Queries
|
|
200
|
+
* have a five-second server budget and return 503 on timeout.
|
|
201
|
+
*/
|
|
202
|
+
get: operations["listTasks"];
|
|
203
|
+
put?: never;
|
|
204
|
+
post?: never;
|
|
205
|
+
delete?: never;
|
|
206
|
+
options?: never;
|
|
207
|
+
head?: never;
|
|
208
|
+
patch?: never;
|
|
209
|
+
trace?: never;
|
|
210
|
+
};
|
|
211
|
+
"/api/v1/usage": {
|
|
212
|
+
parameters: {
|
|
213
|
+
query?: never;
|
|
214
|
+
header?: never;
|
|
215
|
+
path?: never;
|
|
216
|
+
cookie?: never;
|
|
217
|
+
};
|
|
218
|
+
/**
|
|
219
|
+
* Get usage for the authenticated API key
|
|
220
|
+
* @description Only tasks created by this API key and its account are included,
|
|
221
|
+
* including hidden historical tasks. Other keys and workspaces cannot
|
|
222
|
+
* be selected. Unknown or repeated query parameters are rejected.
|
|
223
|
+
* Dates form a UTC half-open interval [from,to), up to 92 days.
|
|
224
|
+
* The default to is tomorrow in UTC; omitted from is seven days before to.
|
|
225
|
+
* Calls are attributed to task creation time. Spend sums only settled
|
|
226
|
+
* actual charges for those tasks, never pending holds. Late settlement
|
|
227
|
+
* can change a previous day's spend. These are task usage totals, not
|
|
228
|
+
* a statement of cash movements or remaining API-key budget.
|
|
229
|
+
* An additional account-wide token bucket allows a burst of 30 requests
|
|
230
|
+
* and replenishes 30 tokens per minute, shared by all keys on the account.
|
|
231
|
+
* Observe Retry-After on 429. This reporting limit fails closed when its
|
|
232
|
+
* limiter is unavailable. Queries have a five-second server budget;
|
|
233
|
+
* a timeout returns 503 and suggests retrying a shorter date range.
|
|
234
|
+
*/
|
|
235
|
+
get: operations["getUsage"];
|
|
236
|
+
put?: never;
|
|
237
|
+
post?: never;
|
|
238
|
+
delete?: never;
|
|
239
|
+
options?: never;
|
|
240
|
+
head?: never;
|
|
241
|
+
patch?: never;
|
|
242
|
+
trace?: never;
|
|
243
|
+
};
|
|
182
244
|
"/api/v1/chat/credit": {
|
|
183
245
|
parameters: {
|
|
184
246
|
query?: never;
|
|
@@ -473,7 +535,7 @@ export interface components {
|
|
|
473
535
|
CreateTaskRequest: {
|
|
474
536
|
/** @description Exact `model` value from the model catalog. */
|
|
475
537
|
model: string;
|
|
476
|
-
/** @description Validated against the selected model's
|
|
538
|
+
/** @description Validated against the selected model's inputSchema. Declared image fields accept public HTTPS URLs, committed spicy:// file URIs, or standard Base64 Data URIs (image/jpeg, image/png, image/webp, image/gif). Inline images are limited to 1048576 decoded bytes and 8388608 pixels each, 8192 pixels per side, and 16 images / 16777216 pixels in total. The complete JSON request must fit within 2097152 bytes. Model-specific limits still apply. Bare Base64, SVG and inline audio/video are not accepted; use HTTPS or file uploads instead. Inline images are stored as account-bound uploaded files; returned input contains file URIs, never the original Base64 bytes. Quote validation does not upload or reserve funds. */
|
|
477
539
|
input: {
|
|
478
540
|
[key: string]: unknown;
|
|
479
541
|
};
|
|
@@ -506,6 +568,11 @@ export interface components {
|
|
|
506
568
|
};
|
|
507
569
|
CreateTaskResponse: {
|
|
508
570
|
taskId: string;
|
|
571
|
+
/**
|
|
572
|
+
* Format: date-time
|
|
573
|
+
* @description Server execution deadline fixed at acceptance; not a local wait timeout or result URL expiry. Idempotent replays retain the original deadline.
|
|
574
|
+
*/
|
|
575
|
+
deadlineAt: string;
|
|
509
576
|
/**
|
|
510
577
|
* @description `queued` for a new submission; an idempotent replay reports the original task's current state.
|
|
511
578
|
* @enum {string}
|
|
@@ -574,7 +641,7 @@ export interface components {
|
|
|
574
641
|
model: string;
|
|
575
642
|
/** @enum {string} */
|
|
576
643
|
state: "queued" | "running" | "succeeded" | "failed" | "canceled" | "expired";
|
|
577
|
-
/** @description Normalized model input. Omitted after retention redaction. */
|
|
644
|
+
/** @description Normalized model input; inline images become account-bound file URIs. Omitted after retention redaction. */
|
|
578
645
|
input?: {
|
|
579
646
|
[key: string]: unknown;
|
|
580
647
|
};
|
|
@@ -588,6 +655,11 @@ export interface components {
|
|
|
588
655
|
settled: boolean;
|
|
589
656
|
/** Format: date-time */
|
|
590
657
|
createdAt: string;
|
|
658
|
+
/**
|
|
659
|
+
* Format: date-time
|
|
660
|
+
* @description Server execution deadline. Present in current responses; historical stored webhook events may omit it. Not the result retention or URL expiry time.
|
|
661
|
+
*/
|
|
662
|
+
deadlineAt?: string;
|
|
591
663
|
/** Format: date-time */
|
|
592
664
|
completedAt?: string;
|
|
593
665
|
};
|
|
@@ -616,6 +688,73 @@ export interface components {
|
|
|
616
688
|
/** Format: date-time */
|
|
617
689
|
created_at: string;
|
|
618
690
|
};
|
|
691
|
+
APIKeyTaskItem: {
|
|
692
|
+
taskId: string;
|
|
693
|
+
/** @description Public model identifier. */
|
|
694
|
+
model: string;
|
|
695
|
+
/** @enum {string} */
|
|
696
|
+
state: "queued" | "running" | "succeeded" | "failed" | "canceled" | "expired";
|
|
697
|
+
/** @description Final charged USD if settled; otherwise the current held estimate. */
|
|
698
|
+
cost: components["schemas"]["USDString"];
|
|
699
|
+
settled: boolean;
|
|
700
|
+
/** Format: date-time */
|
|
701
|
+
createdAt: string;
|
|
702
|
+
/** Format: date-time */
|
|
703
|
+
deadlineAt: string;
|
|
704
|
+
/** Format: date-time */
|
|
705
|
+
completedAt?: string;
|
|
706
|
+
};
|
|
707
|
+
APIKeyTaskListResponse: {
|
|
708
|
+
items: components["schemas"]["APIKeyTaskItem"][];
|
|
709
|
+
hasMore: boolean;
|
|
710
|
+
/** @description Present only when hasMore is true. */
|
|
711
|
+
nextCursor?: string;
|
|
712
|
+
};
|
|
713
|
+
APIKeyTaskListEnvelope: components["schemas"]["EnvelopeBase"] & {
|
|
714
|
+
/** @constant */
|
|
715
|
+
code?: 200;
|
|
716
|
+
/** @constant */
|
|
717
|
+
msg?: "success";
|
|
718
|
+
data: components["schemas"]["APIKeyTaskListResponse"];
|
|
719
|
+
};
|
|
720
|
+
APIKeyUsageResponse: {
|
|
721
|
+
/** Format: date */
|
|
722
|
+
from: string;
|
|
723
|
+
/** Format: date */
|
|
724
|
+
to: string;
|
|
725
|
+
/** @constant */
|
|
726
|
+
currency: "USD";
|
|
727
|
+
/** Format: int64 */
|
|
728
|
+
totalCalls: number;
|
|
729
|
+
totalSpend: components["schemas"]["USDString"];
|
|
730
|
+
days: components["schemas"]["UsageDayItem"][];
|
|
731
|
+
models: components["schemas"]["UsageModelItem"][];
|
|
732
|
+
};
|
|
733
|
+
UsageDayItem: {
|
|
734
|
+
/** Format: date */
|
|
735
|
+
day: string;
|
|
736
|
+
/** Format: int64 */
|
|
737
|
+
calls: number;
|
|
738
|
+
/** Format: int64 */
|
|
739
|
+
succeeded: number;
|
|
740
|
+
/** Format: int64 */
|
|
741
|
+
failed: number;
|
|
742
|
+
spend: components["schemas"]["USDString"];
|
|
743
|
+
};
|
|
744
|
+
UsageModelItem: {
|
|
745
|
+
/** @description Public model identifier. */
|
|
746
|
+
model: string;
|
|
747
|
+
/** Format: int64 */
|
|
748
|
+
calls: number;
|
|
749
|
+
/** Format: int64 */
|
|
750
|
+
succeeded: number;
|
|
751
|
+
/** Format: int64 */
|
|
752
|
+
failed: number;
|
|
753
|
+
spend: components["schemas"]["USDString"];
|
|
754
|
+
};
|
|
755
|
+
APIKeyUsageEnvelope: components["schemas"]["EnvelopeBase"] & {
|
|
756
|
+
data: components["schemas"]["APIKeyUsageResponse"];
|
|
757
|
+
};
|
|
619
758
|
Balance: {
|
|
620
759
|
available: components["schemas"]["USDString"];
|
|
621
760
|
held: components["schemas"]["USDString"];
|
|
@@ -1395,6 +1534,78 @@ export interface operations {
|
|
|
1395
1534
|
500: components["responses"]["ServerError"];
|
|
1396
1535
|
};
|
|
1397
1536
|
};
|
|
1537
|
+
listTasks: {
|
|
1538
|
+
parameters: {
|
|
1539
|
+
query?: {
|
|
1540
|
+
/** @description Inclusive UTC date in YYYY-MM-DD format. */
|
|
1541
|
+
from?: string;
|
|
1542
|
+
/** @description Exclusive UTC date in YYYY-MM-DD format. */
|
|
1543
|
+
to?: string;
|
|
1544
|
+
state?: "queued" | "running" | "succeeded" | "failed" | "canceled" | "expired";
|
|
1545
|
+
/** @description Exact catalog model identifier or a declared alias. */
|
|
1546
|
+
model?: string;
|
|
1547
|
+
limit?: number;
|
|
1548
|
+
/** @description Opaque nextCursor from the previous page; do not construct it yourself. */
|
|
1549
|
+
cursor?: string;
|
|
1550
|
+
};
|
|
1551
|
+
header?: never;
|
|
1552
|
+
path?: never;
|
|
1553
|
+
cookie?: never;
|
|
1554
|
+
};
|
|
1555
|
+
requestBody?: never;
|
|
1556
|
+
responses: {
|
|
1557
|
+
/** @description Current-key task summaries without prompt or result payloads. */
|
|
1558
|
+
200: {
|
|
1559
|
+
headers: {
|
|
1560
|
+
"Cache-Control"?: "no-store";
|
|
1561
|
+
[name: string]: unknown;
|
|
1562
|
+
};
|
|
1563
|
+
content: {
|
|
1564
|
+
"application/json": components["schemas"]["APIKeyTaskListEnvelope"];
|
|
1565
|
+
};
|
|
1566
|
+
};
|
|
1567
|
+
400: components["responses"]["BadRequest"];
|
|
1568
|
+
401: components["responses"]["Unauthorized"];
|
|
1569
|
+
403: components["responses"]["Forbidden"];
|
|
1570
|
+
429: components["responses"]["RateLimited"];
|
|
1571
|
+
500: components["responses"]["ServerError"];
|
|
1572
|
+
503: components["responses"]["Unavailable"];
|
|
1573
|
+
};
|
|
1574
|
+
};
|
|
1575
|
+
getUsage: {
|
|
1576
|
+
parameters: {
|
|
1577
|
+
query?: {
|
|
1578
|
+
/** @description Inclusive UTC date in YYYY-MM-DD format. */
|
|
1579
|
+
from?: string;
|
|
1580
|
+
/** @description Exclusive UTC date in YYYY-MM-DD format. */
|
|
1581
|
+
to?: string;
|
|
1582
|
+
};
|
|
1583
|
+
header?: never;
|
|
1584
|
+
path?: never;
|
|
1585
|
+
cookie?: never;
|
|
1586
|
+
};
|
|
1587
|
+
requestBody?: never;
|
|
1588
|
+
responses: {
|
|
1589
|
+
/** @description Current-key usage with exact USD decimal strings and sparse daily/model buckets. */
|
|
1590
|
+
200: {
|
|
1591
|
+
headers: {
|
|
1592
|
+
"Cache-Control"?: "no-store";
|
|
1593
|
+
"X-RateLimit-Limit": components["headers"]["RateLimitLimit"];
|
|
1594
|
+
"X-RateLimit-Remaining": components["headers"]["RateLimitRemaining"];
|
|
1595
|
+
[name: string]: unknown;
|
|
1596
|
+
};
|
|
1597
|
+
content: {
|
|
1598
|
+
"application/json": components["schemas"]["APIKeyUsageEnvelope"];
|
|
1599
|
+
};
|
|
1600
|
+
};
|
|
1601
|
+
400: components["responses"]["BadRequest"];
|
|
1602
|
+
401: components["responses"]["Unauthorized"];
|
|
1603
|
+
403: components["responses"]["Forbidden"];
|
|
1604
|
+
429: components["responses"]["RateLimited"];
|
|
1605
|
+
500: components["responses"]["ServerError"];
|
|
1606
|
+
503: components["responses"]["Unavailable"];
|
|
1607
|
+
};
|
|
1608
|
+
};
|
|
1398
1609
|
getCreditBalance: {
|
|
1399
1610
|
parameters: {
|
|
1400
1611
|
query?: never;
|