@pdfvector/client 0.0.53 → 0.1.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/CHANGELOG.md +15 -0
- package/README.md +71 -8
- package/contract/package.json +5 -0
- package/dist/contract.cjs +3962 -0
- package/dist/contract.d.cts +2084 -0
- package/dist/contract.d.mts +2084 -0
- package/dist/contract.mjs +3945 -0
- package/dist/index.cjs +1904 -0
- package/dist/index.d.cts +2470 -0
- package/dist/index.d.mts +2470 -0
- package/dist/index.mjs +1871 -0
- package/dist/rolldown-runtime-D3KUYPsf.mjs +12 -0
- package/package.json +37 -7
- package/.tsc/lib/index.d.ts +0 -2
- package/.tsc/lib/index.d.ts.map +0 -1
- package/.tsc/lib/index.js +0 -1
|
@@ -0,0 +1,3945 @@
|
|
|
1
|
+
import { t as __exportAll } from "./rolldown-runtime-D3KUYPsf.mjs";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
Array.isArray;
|
|
4
|
+
// ../../node_modules/.bun/@orpc+shared@1.15.2+e40b0dfdd726a224/node_modules/@orpc/shared/dist/index.mjs
|
|
5
|
+
function resolveMaybeOptionalOptions(rest) {
|
|
6
|
+
return rest[0] ?? {};
|
|
7
|
+
}
|
|
8
|
+
function getConstructor(value) {
|
|
9
|
+
if (!isTypescriptObject(value)) return null;
|
|
10
|
+
return Object.getPrototypeOf(value)?.constructor;
|
|
11
|
+
}
|
|
12
|
+
function isTypescriptObject(value) {
|
|
13
|
+
return !!value && (typeof value === "object" || typeof value === "function");
|
|
14
|
+
}
|
|
15
|
+
// ../../node_modules/.bun/@orpc+client@1.15.2+e40b0dfdd726a224/node_modules/@orpc/client/dist/shared/client.t2tsjbV-.mjs
|
|
16
|
+
const ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
|
|
17
|
+
const ORPC_CLIENT_PACKAGE_VERSION = "1.15.2";
|
|
18
|
+
const COMMON_ORPC_ERROR_DEFS = {
|
|
19
|
+
BAD_REQUEST: {
|
|
20
|
+
status: 400,
|
|
21
|
+
message: "Bad Request"
|
|
22
|
+
},
|
|
23
|
+
UNAUTHORIZED: {
|
|
24
|
+
status: 401,
|
|
25
|
+
message: "Unauthorized"
|
|
26
|
+
},
|
|
27
|
+
FORBIDDEN: {
|
|
28
|
+
status: 403,
|
|
29
|
+
message: "Forbidden"
|
|
30
|
+
},
|
|
31
|
+
NOT_FOUND: {
|
|
32
|
+
status: 404,
|
|
33
|
+
message: "Not Found"
|
|
34
|
+
},
|
|
35
|
+
METHOD_NOT_SUPPORTED: {
|
|
36
|
+
status: 405,
|
|
37
|
+
message: "Method Not Supported"
|
|
38
|
+
},
|
|
39
|
+
NOT_ACCEPTABLE: {
|
|
40
|
+
status: 406,
|
|
41
|
+
message: "Not Acceptable"
|
|
42
|
+
},
|
|
43
|
+
TIMEOUT: {
|
|
44
|
+
status: 408,
|
|
45
|
+
message: "Request Timeout"
|
|
46
|
+
},
|
|
47
|
+
CONFLICT: {
|
|
48
|
+
status: 409,
|
|
49
|
+
message: "Conflict"
|
|
50
|
+
},
|
|
51
|
+
PRECONDITION_FAILED: {
|
|
52
|
+
status: 412,
|
|
53
|
+
message: "Precondition Failed"
|
|
54
|
+
},
|
|
55
|
+
PAYLOAD_TOO_LARGE: {
|
|
56
|
+
status: 413,
|
|
57
|
+
message: "Payload Too Large"
|
|
58
|
+
},
|
|
59
|
+
UNSUPPORTED_MEDIA_TYPE: {
|
|
60
|
+
status: 415,
|
|
61
|
+
message: "Unsupported Media Type"
|
|
62
|
+
},
|
|
63
|
+
UNPROCESSABLE_CONTENT: {
|
|
64
|
+
status: 422,
|
|
65
|
+
message: "Unprocessable Content"
|
|
66
|
+
},
|
|
67
|
+
TOO_MANY_REQUESTS: {
|
|
68
|
+
status: 429,
|
|
69
|
+
message: "Too Many Requests"
|
|
70
|
+
},
|
|
71
|
+
CLIENT_CLOSED_REQUEST: {
|
|
72
|
+
status: 499,
|
|
73
|
+
message: "Client Closed Request"
|
|
74
|
+
},
|
|
75
|
+
INTERNAL_SERVER_ERROR: {
|
|
76
|
+
status: 500,
|
|
77
|
+
message: "Internal Server Error"
|
|
78
|
+
},
|
|
79
|
+
NOT_IMPLEMENTED: {
|
|
80
|
+
status: 501,
|
|
81
|
+
message: "Not Implemented"
|
|
82
|
+
},
|
|
83
|
+
BAD_GATEWAY: {
|
|
84
|
+
status: 502,
|
|
85
|
+
message: "Bad Gateway"
|
|
86
|
+
},
|
|
87
|
+
SERVICE_UNAVAILABLE: {
|
|
88
|
+
status: 503,
|
|
89
|
+
message: "Service Unavailable"
|
|
90
|
+
},
|
|
91
|
+
GATEWAY_TIMEOUT: {
|
|
92
|
+
status: 504,
|
|
93
|
+
message: "Gateway Timeout"
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
function fallbackORPCErrorStatus(code, status) {
|
|
97
|
+
return status ?? COMMON_ORPC_ERROR_DEFS[code]?.status ?? 500;
|
|
98
|
+
}
|
|
99
|
+
function fallbackORPCErrorMessage(code, message) {
|
|
100
|
+
return message || COMMON_ORPC_ERROR_DEFS[code]?.message || code;
|
|
101
|
+
}
|
|
102
|
+
let globalORPCErrorConstructors;
|
|
103
|
+
(class ORPCError extends Error {
|
|
104
|
+
defined;
|
|
105
|
+
code;
|
|
106
|
+
status;
|
|
107
|
+
data;
|
|
108
|
+
static {
|
|
109
|
+
const GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL = Symbol.for(`__${ORPC_CLIENT_PACKAGE_NAME}@${ORPC_CLIENT_PACKAGE_VERSION}/error/ORPC_ERROR_CONSTRUCTORS__`);
|
|
110
|
+
globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL] ??= /* @__PURE__ */ new WeakSet();
|
|
111
|
+
globalORPCErrorConstructors = globalThis[GLOBAL_ORPC_ERROR_CONSTRUCTORS_SYMBOL];
|
|
112
|
+
globalORPCErrorConstructors.add(ORPCError);
|
|
113
|
+
}
|
|
114
|
+
constructor(code, ...rest) {
|
|
115
|
+
const options = resolveMaybeOptionalOptions(rest);
|
|
116
|
+
if (options.status !== void 0 && !isORPCErrorStatus(options.status)) throw new Error("[ORPCError] Invalid error status code.");
|
|
117
|
+
const message = fallbackORPCErrorMessage(code, options.message);
|
|
118
|
+
super(message, options);
|
|
119
|
+
this.code = code;
|
|
120
|
+
this.status = fallbackORPCErrorStatus(code, options.status);
|
|
121
|
+
this.defined = options.defined ?? false;
|
|
122
|
+
this.data = options.data;
|
|
123
|
+
}
|
|
124
|
+
toJSON() {
|
|
125
|
+
return {
|
|
126
|
+
defined: this.defined,
|
|
127
|
+
code: this.code,
|
|
128
|
+
status: this.status,
|
|
129
|
+
message: this.message,
|
|
130
|
+
data: this.data
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Workaround for Next.js where different contexts use separate
|
|
135
|
+
* dependency graphs, causing multiple ORPCError constructors existing and breaking
|
|
136
|
+
* `instanceof` checks across contexts.
|
|
137
|
+
*
|
|
138
|
+
* This is particularly problematic with "Optimized SSR", where orpc-client
|
|
139
|
+
* executes in one context but is invoked from another. When an error is thrown
|
|
140
|
+
* in the execution context, `instanceof ORPCError` checks fail in the
|
|
141
|
+
* invocation context due to separate class constructors.
|
|
142
|
+
*
|
|
143
|
+
* @todo Remove this and related code if Next.js resolves the multiple dependency graph issue.
|
|
144
|
+
*/
|
|
145
|
+
static [Symbol.hasInstance](instance) {
|
|
146
|
+
if (globalORPCErrorConstructors.has(this)) {
|
|
147
|
+
const constructor = getConstructor(instance);
|
|
148
|
+
if (constructor && globalORPCErrorConstructors.has(constructor)) return true;
|
|
149
|
+
}
|
|
150
|
+
return super[Symbol.hasInstance](instance);
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
function isORPCErrorStatus(status) {
|
|
154
|
+
return status < 200 || status >= 400;
|
|
155
|
+
}
|
|
156
|
+
// ../../node_modules/.bun/@orpc+contract@1.15.2+e40b0dfdd726a224/node_modules/@orpc/contract/dist/shared/contract.D_dZrO__.mjs
|
|
157
|
+
function mergeErrorMap(errorMap1, errorMap2) {
|
|
158
|
+
return {
|
|
159
|
+
...errorMap1,
|
|
160
|
+
...errorMap2
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
var ContractProcedure = class {
|
|
164
|
+
/**
|
|
165
|
+
* This property holds the defined options for the contract procedure.
|
|
166
|
+
*/
|
|
167
|
+
"~orpc";
|
|
168
|
+
constructor(def) {
|
|
169
|
+
if (def.route?.successStatus && isORPCErrorStatus(def.route.successStatus)) throw new Error("[ContractProcedure] Invalid successStatus.");
|
|
170
|
+
if (Object.values(def.errorMap).some((val) => val && val.status && !isORPCErrorStatus(val.status))) throw new Error("[ContractProcedure] Invalid error status code.");
|
|
171
|
+
this["~orpc"] = def;
|
|
172
|
+
}
|
|
173
|
+
};
|
|
174
|
+
function isContractProcedure(item) {
|
|
175
|
+
if (item instanceof ContractProcedure) return true;
|
|
176
|
+
return (typeof item === "object" || typeof item === "function") && item !== null && "~orpc" in item && typeof item["~orpc"] === "object" && item["~orpc"] !== null && "errorMap" in item["~orpc"] && "route" in item["~orpc"] && "meta" in item["~orpc"];
|
|
177
|
+
}
|
|
178
|
+
// ../../node_modules/.bun/@orpc+contract@1.15.2+e40b0dfdd726a224/node_modules/@orpc/contract/dist/index.mjs
|
|
179
|
+
function mergeMeta(meta1, meta2) {
|
|
180
|
+
return {
|
|
181
|
+
...meta1,
|
|
182
|
+
...meta2
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
function mergeRoute(a, b) {
|
|
186
|
+
return {
|
|
187
|
+
...a,
|
|
188
|
+
...b
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
function prefixRoute(route, prefix) {
|
|
192
|
+
if (!route.path) return route;
|
|
193
|
+
return {
|
|
194
|
+
...route,
|
|
195
|
+
path: `${prefix}${route.path}`
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
function unshiftTagRoute(route, tags) {
|
|
199
|
+
return {
|
|
200
|
+
...route,
|
|
201
|
+
tags: [...tags, ...route.tags ?? []]
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
function mergePrefix(a, b) {
|
|
205
|
+
return a ? `${a}${b}` : b;
|
|
206
|
+
}
|
|
207
|
+
function mergeTags(a, b) {
|
|
208
|
+
return a ? [...a, ...b] : b;
|
|
209
|
+
}
|
|
210
|
+
function enhanceRoute(route, options) {
|
|
211
|
+
let router = route;
|
|
212
|
+
if (options.prefix) router = prefixRoute(router, options.prefix);
|
|
213
|
+
if (options.tags?.length) router = unshiftTagRoute(router, options.tags);
|
|
214
|
+
return router;
|
|
215
|
+
}
|
|
216
|
+
function enhanceContractRouter(router, options) {
|
|
217
|
+
if (isContractProcedure(router)) return new ContractProcedure({
|
|
218
|
+
...router["~orpc"],
|
|
219
|
+
errorMap: mergeErrorMap(options.errorMap, router["~orpc"].errorMap),
|
|
220
|
+
route: enhanceRoute(router["~orpc"].route, options)
|
|
221
|
+
});
|
|
222
|
+
if (typeof router !== "object" || router === null) return router;
|
|
223
|
+
const enhanced = {};
|
|
224
|
+
for (const key in router) enhanced[key] = enhanceContractRouter(router[key], options);
|
|
225
|
+
return enhanced;
|
|
226
|
+
}
|
|
227
|
+
const oc = new class ContractBuilder extends ContractProcedure {
|
|
228
|
+
constructor(def) {
|
|
229
|
+
super(def);
|
|
230
|
+
this["~orpc"].prefix = def.prefix;
|
|
231
|
+
this["~orpc"].tags = def.tags;
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Sets or overrides the initial meta.
|
|
235
|
+
*
|
|
236
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
237
|
+
*/
|
|
238
|
+
$meta(initialMeta) {
|
|
239
|
+
return new ContractBuilder({
|
|
240
|
+
...this["~orpc"],
|
|
241
|
+
meta: initialMeta
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Sets or overrides the initial route.
|
|
246
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
247
|
+
*
|
|
248
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
249
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
250
|
+
*/
|
|
251
|
+
$route(initialRoute) {
|
|
252
|
+
return new ContractBuilder({
|
|
253
|
+
...this["~orpc"],
|
|
254
|
+
route: initialRoute
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Sets or overrides the initial input schema.
|
|
259
|
+
*
|
|
260
|
+
* @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
|
|
261
|
+
*/
|
|
262
|
+
$input(initialInputSchema) {
|
|
263
|
+
return new ContractBuilder({
|
|
264
|
+
...this["~orpc"],
|
|
265
|
+
inputSchema: initialInputSchema
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Adds type-safe custom errors to the contract.
|
|
270
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
271
|
+
*
|
|
272
|
+
* @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
273
|
+
*/
|
|
274
|
+
errors(errors) {
|
|
275
|
+
return new ContractBuilder({
|
|
276
|
+
...this["~orpc"],
|
|
277
|
+
errorMap: mergeErrorMap(this["~orpc"].errorMap, errors)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Sets or updates the metadata for the contract.
|
|
282
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
283
|
+
*
|
|
284
|
+
* @see {@link https://orpc.dev/docs/metadata Metadata Docs}
|
|
285
|
+
*/
|
|
286
|
+
meta(meta) {
|
|
287
|
+
return new ContractBuilder({
|
|
288
|
+
...this["~orpc"],
|
|
289
|
+
meta: mergeMeta(this["~orpc"].meta, meta)
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Sets or updates the route definition for the contract.
|
|
294
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
295
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
296
|
+
*
|
|
297
|
+
* @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
|
|
298
|
+
* @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
299
|
+
*/
|
|
300
|
+
route(route) {
|
|
301
|
+
return new ContractBuilder({
|
|
302
|
+
...this["~orpc"],
|
|
303
|
+
route: mergeRoute(this["~orpc"].route, route)
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Defines the input validation schema for the contract.
|
|
308
|
+
*
|
|
309
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
|
|
310
|
+
*/
|
|
311
|
+
input(schema) {
|
|
312
|
+
return new ContractBuilder({
|
|
313
|
+
...this["~orpc"],
|
|
314
|
+
inputSchema: schema
|
|
315
|
+
});
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Defines the output validation schema for the contract.
|
|
319
|
+
*
|
|
320
|
+
* @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
|
|
321
|
+
*/
|
|
322
|
+
output(schema) {
|
|
323
|
+
return new ContractBuilder({
|
|
324
|
+
...this["~orpc"],
|
|
325
|
+
outputSchema: schema
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Prefixes all procedures in the contract router.
|
|
330
|
+
* The provided prefix is post-appended to any existing router prefix.
|
|
331
|
+
*
|
|
332
|
+
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
333
|
+
*
|
|
334
|
+
* @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
335
|
+
*/
|
|
336
|
+
prefix(prefix) {
|
|
337
|
+
return new ContractBuilder({
|
|
338
|
+
...this["~orpc"],
|
|
339
|
+
prefix: mergePrefix(this["~orpc"].prefix, prefix)
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Adds tags to all procedures in the contract router.
|
|
344
|
+
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
345
|
+
*
|
|
346
|
+
* @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
347
|
+
*/
|
|
348
|
+
tag(...tags) {
|
|
349
|
+
return new ContractBuilder({
|
|
350
|
+
...this["~orpc"],
|
|
351
|
+
tags: mergeTags(this["~orpc"].tags, tags)
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
/**
|
|
355
|
+
* Applies all of the previously defined options to the specified contract router.
|
|
356
|
+
*
|
|
357
|
+
* @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
|
|
358
|
+
*/
|
|
359
|
+
router(router) {
|
|
360
|
+
return enhanceContractRouter(router, this["~orpc"]);
|
|
361
|
+
}
|
|
362
|
+
}({
|
|
363
|
+
errorMap: {},
|
|
364
|
+
route: {},
|
|
365
|
+
meta: {}
|
|
366
|
+
});
|
|
367
|
+
// ../util/lib/api-source.ts
|
|
368
|
+
const apiSources = [
|
|
369
|
+
"make",
|
|
370
|
+
"zapier",
|
|
371
|
+
"n8n",
|
|
372
|
+
"sdk",
|
|
373
|
+
"mcp",
|
|
374
|
+
"playground",
|
|
375
|
+
"api",
|
|
376
|
+
"unknown",
|
|
377
|
+
"internal"
|
|
378
|
+
];
|
|
379
|
+
// ../util/lib/tier.ts
|
|
380
|
+
const MB = 1048576;
|
|
381
|
+
const tierLimits = {
|
|
382
|
+
nano: {
|
|
383
|
+
maxFileSize: 40 * MB,
|
|
384
|
+
maxPages: 30
|
|
385
|
+
},
|
|
386
|
+
mini: {
|
|
387
|
+
maxFileSize: 40 * MB,
|
|
388
|
+
maxPages: 30
|
|
389
|
+
},
|
|
390
|
+
pro: {
|
|
391
|
+
maxFileSize: 40 * MB,
|
|
392
|
+
maxPages: 30
|
|
393
|
+
},
|
|
394
|
+
max: {
|
|
395
|
+
maxFileSize: 500 * MB,
|
|
396
|
+
maxPages: 2e3
|
|
397
|
+
},
|
|
398
|
+
auto: {
|
|
399
|
+
maxFileSize: 500 * MB,
|
|
400
|
+
maxPages: 2e3
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
/** Document parse: credits per page */
|
|
404
|
+
const documentParseCosts = {
|
|
405
|
+
nano: 1,
|
|
406
|
+
mini: 2,
|
|
407
|
+
pro: 4,
|
|
408
|
+
max: 8
|
|
409
|
+
};
|
|
410
|
+
/** Document ask/extract: credits per page */
|
|
411
|
+
const documentAskExtractCosts = {
|
|
412
|
+
nano: 2,
|
|
413
|
+
mini: 4,
|
|
414
|
+
pro: 8,
|
|
415
|
+
max: 16
|
|
416
|
+
};
|
|
417
|
+
/** Specialized parse (identity, invoice, bank statement): credits per page.
|
|
418
|
+
* Only pro and max are available — nano/mini return 0. */
|
|
419
|
+
const specializedParseCosts = {
|
|
420
|
+
pro: 6,
|
|
421
|
+
max: 10
|
|
422
|
+
};
|
|
423
|
+
/** Specialized ask/extract (identity, invoice, bank statement): credits per page */
|
|
424
|
+
const specializedAskExtractCosts = {
|
|
425
|
+
nano: 6,
|
|
426
|
+
mini: 10,
|
|
427
|
+
pro: 14,
|
|
428
|
+
max: 18
|
|
429
|
+
};
|
|
430
|
+
/** Formats supported by all tiers (nano, mini, pro, max, auto). */
|
|
431
|
+
const allTierFormats = [
|
|
432
|
+
"PDF",
|
|
433
|
+
"Word (.docx)",
|
|
434
|
+
"Excel (.xlsx)",
|
|
435
|
+
"PowerPoint (.pptx)",
|
|
436
|
+
"CSV",
|
|
437
|
+
"Text (.txt, .md, .tsv, .xml)",
|
|
438
|
+
"HTML",
|
|
439
|
+
"RTF",
|
|
440
|
+
"OpenDocument (.odt, .ods, .odp)",
|
|
441
|
+
"EPUB",
|
|
442
|
+
"Bibliography (.bib, .ris, .nbib, .enw)"
|
|
443
|
+
];
|
|
444
|
+
/** Formats added by the pro/max/auto tiers. */
|
|
445
|
+
const proTierAdditionalFormats = ["Image (PNG, JPG, TIFF, BMP, HEIF)"];
|
|
446
|
+
/** Short human-readable summary of all supported formats. */
|
|
447
|
+
const allSupportedFormatsShort = "PDF, DOCX, XLSX, PPTX, CSV, PNG, JPG, TIFF, BMP, HEIF, TXT, MD, TSV, XML, RTF, HTML, ODT, ODS, ODP, EPUB, BIB, RIS, NBIB, ENW";
|
|
448
|
+
/** Long human-readable summary of all supported formats. */
|
|
449
|
+
const allSupportedFormatsLong = "PDF, Word (.docx), Excel (.xlsx), PowerPoint (.pptx), CSV, Image (.png, .jpg, .tiff, .bmp, .heif), Plain Text (.txt, .md, .tsv, .xml), RTF, HTML, OpenDocument (.odt, .ods, .odp), EPUB, and Bibliography (.bib, .ris, .nbib, .enw) files";
|
|
450
|
+
/** Image dimension limits enforced by the underlying OCR engine (Azure Document Intelligence).
|
|
451
|
+
* Images outside this range are rejected with HTTP 400 before processing begins. */
|
|
452
|
+
const imageDimensionLimits = {
|
|
453
|
+
minPixels: 50,
|
|
454
|
+
maxPixels: 1e4
|
|
455
|
+
};
|
|
456
|
+
/** Pre-built format note for API descriptions (used in contract model descriptions). */
|
|
457
|
+
const formatsByTierDescription = `Supported formats by tier:
|
|
458
|
+
- All tiers: ${allTierFormats.join(", ")}.\n- Pro/Max/Auto adds: ${proTierAdditionalFormats.join(", ")}. Image dimensions must be between ${imageDimensionLimits.minPixels}×${imageDimensionLimits.minPixels} and ${imageDimensionLimits.maxPixels}×${imageDimensionLimits.maxPixels} pixels.`;
|
|
459
|
+
/** Academic/grant API: fixed credits per request */
|
|
460
|
+
const academicCreditCosts = {
|
|
461
|
+
academicSearch: 2,
|
|
462
|
+
academicFetch: 2,
|
|
463
|
+
academicFindCitationsPerSentence: 2,
|
|
464
|
+
academicPaperGraphMin: 2,
|
|
465
|
+
academicPaperGraphDivisor: 50,
|
|
466
|
+
academicSimilarPapers: 3,
|
|
467
|
+
grantSearch: 2
|
|
468
|
+
};
|
|
469
|
+
// ../util/lib/usage-status.ts
|
|
470
|
+
const usageStatuses = [
|
|
471
|
+
"success",
|
|
472
|
+
"user_error",
|
|
473
|
+
"system_error"
|
|
474
|
+
];
|
|
475
|
+
const errorStages = [
|
|
476
|
+
"auth",
|
|
477
|
+
"validation",
|
|
478
|
+
"preprocessing",
|
|
479
|
+
"processing"
|
|
480
|
+
];
|
|
481
|
+
// ../util/lib/api-docs.ts
|
|
482
|
+
const globalBaseUrl = "https://global.pdfvector.com";
|
|
483
|
+
const documentUrl = "https://example.com/annual-report.pdf";
|
|
484
|
+
const documentId = "my-doc-123";
|
|
485
|
+
const arxivId = "1706.03762";
|
|
486
|
+
function buildDocumentParseCurl(baseUrl = globalBaseUrl) {
|
|
487
|
+
return `curl -X POST ${baseUrl}/api/document/parse \\
|
|
488
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
489
|
+
-H "Content-Type: application/json" \\
|
|
490
|
+
-H "x-pdfvector-document-id: ${documentId}" \\
|
|
491
|
+
-d '{
|
|
492
|
+
"url": "${documentUrl}",
|
|
493
|
+
"model": "max",
|
|
494
|
+
"includePages": true
|
|
495
|
+
}'`;
|
|
496
|
+
}
|
|
497
|
+
function buildDocumentParseTypeScript() {
|
|
498
|
+
return `import { createClient } from "@pdfvector/client";
|
|
499
|
+
|
|
500
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
501
|
+
|
|
502
|
+
const result = await client.document.parse(
|
|
503
|
+
{ url: "${documentUrl}", model: "max", includePages: true },
|
|
504
|
+
{ context: { documentId: "${documentId}" } },
|
|
505
|
+
);
|
|
506
|
+
|
|
507
|
+
console.log(result.markdown);
|
|
508
|
+
console.log(result.pages?.[0]?.markdown);
|
|
509
|
+
console.log(\`Pages: \${result.pageCount}, Model: \${result.model}\`);`;
|
|
510
|
+
}
|
|
511
|
+
function buildDocumentParsePython(baseUrl = globalBaseUrl) {
|
|
512
|
+
return `import requests
|
|
513
|
+
|
|
514
|
+
response = requests.post(
|
|
515
|
+
"${baseUrl}/api/document/parse",
|
|
516
|
+
headers={
|
|
517
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
518
|
+
"x-pdfvector-document-id": "${documentId}",
|
|
519
|
+
},
|
|
520
|
+
json={
|
|
521
|
+
"url": "${documentUrl}",
|
|
522
|
+
"model": "max",
|
|
523
|
+
"includePages": True,
|
|
524
|
+
},
|
|
525
|
+
)
|
|
526
|
+
data = response.json()
|
|
527
|
+
print(data["markdown"], data["pages"][0]["markdown"], data["pageCount"])`;
|
|
528
|
+
}
|
|
529
|
+
function buildAcademicParseCurl(baseUrl = globalBaseUrl) {
|
|
530
|
+
return `curl -X POST ${baseUrl}/api/academic/parse \\
|
|
531
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
532
|
+
-H "Content-Type: application/json" \\
|
|
533
|
+
-d '{
|
|
534
|
+
"id": "${arxivId}",
|
|
535
|
+
"model": "auto",
|
|
536
|
+
"includePages": true
|
|
537
|
+
}'`;
|
|
538
|
+
}
|
|
539
|
+
function buildAcademicParseTypeScript() {
|
|
540
|
+
return `import { createClient } from "@pdfvector/client";
|
|
541
|
+
|
|
542
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
543
|
+
|
|
544
|
+
const result = await client.academic.parse({
|
|
545
|
+
id: "${arxivId}",
|
|
546
|
+
model: "auto",
|
|
547
|
+
includePages: true,
|
|
548
|
+
});
|
|
549
|
+
|
|
550
|
+
console.log(result.title);
|
|
551
|
+
console.log(result.pdfURL);
|
|
552
|
+
console.log(result.markdown);
|
|
553
|
+
console.log(result.pages?.[0]?.markdown);`;
|
|
554
|
+
}
|
|
555
|
+
function buildAcademicParsePython(baseUrl = globalBaseUrl) {
|
|
556
|
+
return `import requests
|
|
557
|
+
|
|
558
|
+
response = requests.post(
|
|
559
|
+
"${baseUrl}/api/academic/parse",
|
|
560
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
561
|
+
json={
|
|
562
|
+
"url": "https://arxiv.org/abs/${arxivId}",
|
|
563
|
+
"model": "auto",
|
|
564
|
+
"includePages": True,
|
|
565
|
+
},
|
|
566
|
+
)
|
|
567
|
+
data = response.json()
|
|
568
|
+
print(data["title"])
|
|
569
|
+
print(data["markdown"])
|
|
570
|
+
print(data["pages"][0]["markdown"])`;
|
|
571
|
+
}
|
|
572
|
+
const publicApiCodeExamples = [
|
|
573
|
+
{
|
|
574
|
+
id: "document-parse",
|
|
575
|
+
label: "Parse",
|
|
576
|
+
group: "Document",
|
|
577
|
+
curl: buildDocumentParseCurl(),
|
|
578
|
+
typescript: buildDocumentParseTypeScript(),
|
|
579
|
+
python: buildDocumentParsePython(),
|
|
580
|
+
response: `{
|
|
581
|
+
"documentId": "${documentId}",
|
|
582
|
+
"markdown": "# Annual Report 2024\\n\\n## Executive Summary\\nRevenue grew 23% year-over-year to $4.2B...",
|
|
583
|
+
"pageCount": 5,
|
|
584
|
+
"pages": [{ "pageNumber": 1, "markdown": "# Annual Report 2024\\n\\n## Executive Summary..." }],
|
|
585
|
+
"model": "max",
|
|
586
|
+
"html": "<h1>Annual Report 2024</h1><h2>Executive Summary</h2><p>Revenue grew 23% year-over-year to $4.2B...</p>",
|
|
587
|
+
"credits": 40,
|
|
588
|
+
"requestId": 42
|
|
589
|
+
}`
|
|
590
|
+
},
|
|
591
|
+
{
|
|
592
|
+
id: "document-ask",
|
|
593
|
+
label: "Ask",
|
|
594
|
+
group: "Document",
|
|
595
|
+
curl: `curl -X POST https://global.pdfvector.com/api/document/ask \\
|
|
596
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
597
|
+
-H "Content-Type: application/json" \\
|
|
598
|
+
-H "x-pdfvector-document-id: my-doc-123" \\
|
|
599
|
+
-d '{
|
|
600
|
+
"url": "https://example.com/annual-report.pdf",
|
|
601
|
+
"question": "What was the total revenue in Q4?",
|
|
602
|
+
"model": "max"
|
|
603
|
+
}'`,
|
|
604
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
605
|
+
|
|
606
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
607
|
+
|
|
608
|
+
const result = await client.document.ask(
|
|
609
|
+
{
|
|
610
|
+
url: "https://example.com/annual-report.pdf",
|
|
611
|
+
question: "What was the total revenue in Q4?",
|
|
612
|
+
model: "max",
|
|
613
|
+
},
|
|
614
|
+
{ context: { documentId: "my-doc-123" } },
|
|
615
|
+
);
|
|
616
|
+
|
|
617
|
+
console.log(result.markdown);`,
|
|
618
|
+
python: `import requests
|
|
619
|
+
|
|
620
|
+
response = requests.post(
|
|
621
|
+
"https://global.pdfvector.com/api/document/ask",
|
|
622
|
+
headers={
|
|
623
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
624
|
+
"x-pdfvector-document-id": "my-doc-123",
|
|
625
|
+
},
|
|
626
|
+
json={
|
|
627
|
+
"url": "https://example.com/annual-report.pdf",
|
|
628
|
+
"question": "What was the total revenue in Q4?",
|
|
629
|
+
"model": "max",
|
|
630
|
+
},
|
|
631
|
+
)
|
|
632
|
+
data = response.json()
|
|
633
|
+
print(data["markdown"])`,
|
|
634
|
+
response: `{
|
|
635
|
+
"documentId": "my-doc-123",
|
|
636
|
+
"markdown": "Based on the document, the total revenue in Q4 was $1.12B, representing a 15% increase from Q3 and a 23% year-over-year growth.",
|
|
637
|
+
"model": "max",
|
|
638
|
+
"requestId": 43
|
|
639
|
+
}`
|
|
640
|
+
},
|
|
641
|
+
{
|
|
642
|
+
id: "document-extract",
|
|
643
|
+
label: "Extract",
|
|
644
|
+
group: "Document",
|
|
645
|
+
curl: `curl -X POST https://global.pdfvector.com/api/document/extract \\
|
|
646
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
647
|
+
-H "Content-Type: application/json" \\
|
|
648
|
+
-H "x-pdfvector-document-id: my-doc-123" \\
|
|
649
|
+
-d '{
|
|
650
|
+
"url": "https://example.com/annual-report.pdf",
|
|
651
|
+
"prompt": "Extract the company overview, fiscal year, revenue, net income, and key business segments",
|
|
652
|
+
"schema": {
|
|
653
|
+
"type": "object",
|
|
654
|
+
"properties": {
|
|
655
|
+
"companyName": { "type": "string" },
|
|
656
|
+
"fiscalYear": { "type": "string" },
|
|
657
|
+
"totalRevenue": { "type": "number" },
|
|
658
|
+
"netIncome": { "type": "number" },
|
|
659
|
+
"segments": {
|
|
660
|
+
"type": "array",
|
|
661
|
+
"items": {
|
|
662
|
+
"type": "object",
|
|
663
|
+
"properties": {
|
|
664
|
+
"name": { "type": "string" },
|
|
665
|
+
"revenue": { "type": "number" },
|
|
666
|
+
"growthPercent": { "type": "number" }
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
},
|
|
672
|
+
"model": "max"
|
|
673
|
+
}'`,
|
|
674
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
675
|
+
|
|
676
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
677
|
+
|
|
678
|
+
const result = await client.document.extract(
|
|
679
|
+
{
|
|
680
|
+
url: "https://example.com/annual-report.pdf",
|
|
681
|
+
prompt: "Extract the company overview, fiscal year, revenue, net income, and key business segments",
|
|
682
|
+
schema: {
|
|
683
|
+
type: "object",
|
|
684
|
+
properties: {
|
|
685
|
+
companyName: { type: "string" },
|
|
686
|
+
fiscalYear: { type: "string" },
|
|
687
|
+
totalRevenue: { type: "number" },
|
|
688
|
+
netIncome: { type: "number" },
|
|
689
|
+
segments: {
|
|
690
|
+
type: "array",
|
|
691
|
+
items: {
|
|
692
|
+
type: "object",
|
|
693
|
+
properties: {
|
|
694
|
+
name: { type: "string" },
|
|
695
|
+
revenue: { type: "number" },
|
|
696
|
+
growthPercent: { type: "number" },
|
|
697
|
+
},
|
|
698
|
+
},
|
|
699
|
+
},
|
|
700
|
+
},
|
|
701
|
+
},
|
|
702
|
+
model: "max",
|
|
703
|
+
},
|
|
704
|
+
{ context: { documentId: "my-doc-123" } },
|
|
705
|
+
);
|
|
706
|
+
|
|
707
|
+
console.log(result.data);`,
|
|
708
|
+
python: `import requests
|
|
709
|
+
|
|
710
|
+
response = requests.post(
|
|
711
|
+
"https://global.pdfvector.com/api/document/extract",
|
|
712
|
+
headers={
|
|
713
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
714
|
+
"x-pdfvector-document-id": "my-doc-123",
|
|
715
|
+
},
|
|
716
|
+
json={
|
|
717
|
+
"url": "https://example.com/annual-report.pdf",
|
|
718
|
+
"prompt": "Extract the company overview, fiscal year, revenue, net income, and key business segments",
|
|
719
|
+
"schema": {
|
|
720
|
+
"type": "object",
|
|
721
|
+
"properties": {
|
|
722
|
+
"companyName": {"type": "string"},
|
|
723
|
+
"fiscalYear": {"type": "string"},
|
|
724
|
+
"totalRevenue": {"type": "number"},
|
|
725
|
+
"netIncome": {"type": "number"},
|
|
726
|
+
"segments": {
|
|
727
|
+
"type": "array",
|
|
728
|
+
"items": {
|
|
729
|
+
"type": "object",
|
|
730
|
+
"properties": {
|
|
731
|
+
"name": {"type": "string"},
|
|
732
|
+
"revenue": {"type": "number"},
|
|
733
|
+
"growthPercent": {"type": "number"},
|
|
734
|
+
},
|
|
735
|
+
},
|
|
736
|
+
},
|
|
737
|
+
},
|
|
738
|
+
},
|
|
739
|
+
"model": "max",
|
|
740
|
+
},
|
|
741
|
+
)
|
|
742
|
+
data = response.json()
|
|
743
|
+
print(data["data"])`,
|
|
744
|
+
response: `{
|
|
745
|
+
"documentId": "my-doc-123",
|
|
746
|
+
"data": {
|
|
747
|
+
"companyName": "Acme Corporation",
|
|
748
|
+
"fiscalYear": "2024",
|
|
749
|
+
"totalRevenue": 4200000000,
|
|
750
|
+
"netIncome": 820000000,
|
|
751
|
+
"segments": [
|
|
752
|
+
{ "name": "Cloud Services", "revenue": 2100000000, "growthPercent": 34 },
|
|
753
|
+
{ "name": "Enterprise Software", "revenue": 1400000000, "growthPercent": 18 },
|
|
754
|
+
{ "name": "Consulting", "revenue": 700000000, "growthPercent": 12 }
|
|
755
|
+
]
|
|
756
|
+
},
|
|
757
|
+
"model": "max",
|
|
758
|
+
"requestId": 44
|
|
759
|
+
}`
|
|
760
|
+
},
|
|
761
|
+
{
|
|
762
|
+
id: "identity-parse",
|
|
763
|
+
label: "Parse",
|
|
764
|
+
group: "Identity",
|
|
765
|
+
curl: `curl -X POST https://global.pdfvector.com/api/identity/parse \\
|
|
766
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
767
|
+
-H "Content-Type: application/json" \\
|
|
768
|
+
-H "x-pdfvector-document-id: passport-456" \\
|
|
769
|
+
-d '{
|
|
770
|
+
"url": "https://example.com/passport-scan.jpg",
|
|
771
|
+
"model": "max"
|
|
772
|
+
}'`,
|
|
773
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
774
|
+
|
|
775
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
776
|
+
|
|
777
|
+
const result = await client.identity.parse(
|
|
778
|
+
{ url: "https://example.com/passport-scan.jpg", model: "max" },
|
|
779
|
+
{ context: { documentId: "passport-456" } },
|
|
780
|
+
);
|
|
781
|
+
|
|
782
|
+
console.log(result.markdown);
|
|
783
|
+
console.log(\`Type: \${result.documentType}, Model: \${result.model}\`);`,
|
|
784
|
+
python: `import requests
|
|
785
|
+
|
|
786
|
+
response = requests.post(
|
|
787
|
+
"https://global.pdfvector.com/api/identity/parse",
|
|
788
|
+
headers={
|
|
789
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
790
|
+
"x-pdfvector-document-id": "passport-456",
|
|
791
|
+
},
|
|
792
|
+
json={
|
|
793
|
+
"url": "https://example.com/passport-scan.jpg",
|
|
794
|
+
"model": "max",
|
|
795
|
+
},
|
|
796
|
+
)
|
|
797
|
+
data = response.json()
|
|
798
|
+
print(data["markdown"])`,
|
|
799
|
+
response: `{
|
|
800
|
+
"documentId": "passport-456",
|
|
801
|
+
"markdown": "# Passport — John A. Smith\\n\\n**Full Name:** John Alexander Smith\\n**Nationality:** United States\\n**Date of Birth:** 1985-03-15\\n**Expiry Date:** 2029-07-22",
|
|
802
|
+
"pageCount": 1,
|
|
803
|
+
"model": "max",
|
|
804
|
+
"html": "<h1>Passport — John A. Smith</h1><p><strong>Full Name:</strong> John Alexander Smith</p><p><strong>Nationality:</strong> United States</p>",
|
|
805
|
+
"documentType": "passport",
|
|
806
|
+
"requestId": 42
|
|
807
|
+
}`
|
|
808
|
+
},
|
|
809
|
+
{
|
|
810
|
+
id: "identity-ask",
|
|
811
|
+
label: "Ask",
|
|
812
|
+
group: "Identity",
|
|
813
|
+
curl: `curl -X POST https://global.pdfvector.com/api/identity/ask \\
|
|
814
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
815
|
+
-H "Content-Type: application/json" \\
|
|
816
|
+
-H "x-pdfvector-document-id: passport-456" \\
|
|
817
|
+
-d '{
|
|
818
|
+
"url": "https://example.com/passport-scan.jpg",
|
|
819
|
+
"question": "What is the expiry date?",
|
|
820
|
+
"model": "max"
|
|
821
|
+
}'`,
|
|
822
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
823
|
+
|
|
824
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
825
|
+
|
|
826
|
+
const result = await client.identity.ask(
|
|
827
|
+
{
|
|
828
|
+
url: "https://example.com/passport-scan.jpg",
|
|
829
|
+
question: "What is the expiry date?",
|
|
830
|
+
model: "max",
|
|
831
|
+
},
|
|
832
|
+
{ context: { documentId: "passport-456" } },
|
|
833
|
+
);
|
|
834
|
+
|
|
835
|
+
console.log(result.markdown);`,
|
|
836
|
+
python: `import requests
|
|
837
|
+
|
|
838
|
+
response = requests.post(
|
|
839
|
+
"https://global.pdfvector.com/api/identity/ask",
|
|
840
|
+
headers={
|
|
841
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
842
|
+
"x-pdfvector-document-id": "passport-456",
|
|
843
|
+
},
|
|
844
|
+
json={
|
|
845
|
+
"url": "https://example.com/passport-scan.jpg",
|
|
846
|
+
"question": "What is the expiry date?",
|
|
847
|
+
"model": "max",
|
|
848
|
+
},
|
|
849
|
+
)
|
|
850
|
+
data = response.json()
|
|
851
|
+
print(data["markdown"])`,
|
|
852
|
+
response: `{
|
|
853
|
+
"documentId": "passport-456",
|
|
854
|
+
"markdown": "The expiry date on the passport is July 22, 2029.",
|
|
855
|
+
"model": "max",
|
|
856
|
+
"requestId": 43
|
|
857
|
+
}`
|
|
858
|
+
},
|
|
859
|
+
{
|
|
860
|
+
id: "identity-extract",
|
|
861
|
+
label: "Extract",
|
|
862
|
+
group: "Identity",
|
|
863
|
+
curl: `curl -X POST https://global.pdfvector.com/api/identity/extract \\
|
|
864
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
865
|
+
-H "Content-Type: application/json" \\
|
|
866
|
+
-H "x-pdfvector-document-id: passport-456" \\
|
|
867
|
+
-d '{
|
|
868
|
+
"url": "https://example.com/passport-scan.jpg",
|
|
869
|
+
"prompt": "Extract the full name, date of birth, nationality, passport number, and expiry date",
|
|
870
|
+
"schema": {
|
|
871
|
+
"type": "object",
|
|
872
|
+
"properties": {
|
|
873
|
+
"fullName": { "type": "string" },
|
|
874
|
+
"dateOfBirth": { "type": "string" },
|
|
875
|
+
"nationality": { "type": "string" },
|
|
876
|
+
"passportNumber": { "type": "string" },
|
|
877
|
+
"expiryDate": { "type": "string" }
|
|
878
|
+
}
|
|
879
|
+
},
|
|
880
|
+
"model": "max"
|
|
881
|
+
}'`,
|
|
882
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
883
|
+
|
|
884
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
885
|
+
|
|
886
|
+
const result = await client.identity.extract(
|
|
887
|
+
{
|
|
888
|
+
url: "https://example.com/passport-scan.jpg",
|
|
889
|
+
prompt: "Extract the full name, date of birth, nationality, passport number, and expiry date",
|
|
890
|
+
schema: {
|
|
891
|
+
type: "object",
|
|
892
|
+
properties: {
|
|
893
|
+
fullName: { type: "string" },
|
|
894
|
+
dateOfBirth: { type: "string" },
|
|
895
|
+
nationality: { type: "string" },
|
|
896
|
+
passportNumber: { type: "string" },
|
|
897
|
+
expiryDate: { type: "string" },
|
|
898
|
+
},
|
|
899
|
+
},
|
|
900
|
+
model: "max",
|
|
901
|
+
},
|
|
902
|
+
{ context: { documentId: "passport-456" } },
|
|
903
|
+
);
|
|
904
|
+
|
|
905
|
+
console.log(result.data);`,
|
|
906
|
+
python: `import requests
|
|
907
|
+
|
|
908
|
+
response = requests.post(
|
|
909
|
+
"https://global.pdfvector.com/api/identity/extract",
|
|
910
|
+
headers={
|
|
911
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
912
|
+
"x-pdfvector-document-id": "passport-456",
|
|
913
|
+
},
|
|
914
|
+
json={
|
|
915
|
+
"url": "https://example.com/passport-scan.jpg",
|
|
916
|
+
"prompt": "Extract the full name, date of birth, nationality, passport number, and expiry date",
|
|
917
|
+
"schema": {
|
|
918
|
+
"type": "object",
|
|
919
|
+
"properties": {
|
|
920
|
+
"fullName": {"type": "string"},
|
|
921
|
+
"dateOfBirth": {"type": "string"},
|
|
922
|
+
"nationality": {"type": "string"},
|
|
923
|
+
"passportNumber": {"type": "string"},
|
|
924
|
+
"expiryDate": {"type": "string"},
|
|
925
|
+
},
|
|
926
|
+
},
|
|
927
|
+
"model": "max",
|
|
928
|
+
},
|
|
929
|
+
)
|
|
930
|
+
data = response.json()
|
|
931
|
+
print(data["data"])`,
|
|
932
|
+
response: `{
|
|
933
|
+
"documentId": "passport-456",
|
|
934
|
+
"data": {
|
|
935
|
+
"fullName": "John Alexander Smith",
|
|
936
|
+
"dateOfBirth": "1985-03-15",
|
|
937
|
+
"nationality": "United States",
|
|
938
|
+
"passportNumber": "E12345678",
|
|
939
|
+
"expiryDate": "2029-07-22"
|
|
940
|
+
},
|
|
941
|
+
"model": "max",
|
|
942
|
+
"requestId": 44
|
|
943
|
+
}`
|
|
944
|
+
},
|
|
945
|
+
{
|
|
946
|
+
id: "invoice-parse",
|
|
947
|
+
label: "Parse",
|
|
948
|
+
group: "Invoice",
|
|
949
|
+
curl: `curl -X POST https://global.pdfvector.com/api/invoice/parse \\
|
|
950
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
951
|
+
-H "Content-Type: application/json" \\
|
|
952
|
+
-H "x-pdfvector-document-id: inv-2024-0892" \\
|
|
953
|
+
-d '{
|
|
954
|
+
"url": "https://example.com/supplier-invoice.pdf",
|
|
955
|
+
"model": "max"
|
|
956
|
+
}'`,
|
|
957
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
958
|
+
|
|
959
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
960
|
+
|
|
961
|
+
const result = await client.invoice.parse(
|
|
962
|
+
{ url: "https://example.com/supplier-invoice.pdf", model: "max" },
|
|
963
|
+
{ context: { documentId: "inv-2024-0892" } },
|
|
964
|
+
);
|
|
965
|
+
|
|
966
|
+
console.log(result.markdown);
|
|
967
|
+
console.log(\`Pages: \${result.pageCount}, Model: \${result.model}\`);`,
|
|
968
|
+
python: `import requests
|
|
969
|
+
|
|
970
|
+
response = requests.post(
|
|
971
|
+
"https://global.pdfvector.com/api/invoice/parse",
|
|
972
|
+
headers={
|
|
973
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
974
|
+
"x-pdfvector-document-id": "inv-2024-0892",
|
|
975
|
+
},
|
|
976
|
+
json={
|
|
977
|
+
"url": "https://example.com/supplier-invoice.pdf",
|
|
978
|
+
"model": "max",
|
|
979
|
+
},
|
|
980
|
+
)
|
|
981
|
+
data = response.json()
|
|
982
|
+
print(data["markdown"])`,
|
|
983
|
+
response: `{
|
|
984
|
+
"documentId": "inv-2024-0892",
|
|
985
|
+
"markdown": "# Invoice #INV-2024-0892\\n\\n**Vendor:** TechSupply Co.\\n**Date:** 2024-11-15\\n**Due Date:** 2024-12-15\\n\\n| Item | Qty | Price |\\n|------|-----|-------|\\n| Server Rack | 2 | $3,400.00 |\\n| Network Switch | 4 | $1,200.00 |\\n\\n**Total: $4,600.00**",
|
|
986
|
+
"pageCount": 1,
|
|
987
|
+
"model": "max",
|
|
988
|
+
"html": "<h1>Invoice #INV-2024-0892</h1><p><strong>Vendor:</strong> TechSupply Co.</p><table><tr><td>Server Rack</td><td>$3,400.00</td></tr></table>",
|
|
989
|
+
"requestId": 42
|
|
990
|
+
}`
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
id: "invoice-ask",
|
|
994
|
+
label: "Ask",
|
|
995
|
+
group: "Invoice",
|
|
996
|
+
curl: `curl -X POST https://global.pdfvector.com/api/invoice/ask \\
|
|
997
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
998
|
+
-H "Content-Type: application/json" \\
|
|
999
|
+
-H "x-pdfvector-document-id: inv-2024-0892" \\
|
|
1000
|
+
-d '{
|
|
1001
|
+
"url": "https://example.com/supplier-invoice.pdf",
|
|
1002
|
+
"question": "What is the total amount due?",
|
|
1003
|
+
"model": "max"
|
|
1004
|
+
}'`,
|
|
1005
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1006
|
+
|
|
1007
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1008
|
+
|
|
1009
|
+
const result = await client.invoice.ask(
|
|
1010
|
+
{
|
|
1011
|
+
url: "https://example.com/supplier-invoice.pdf",
|
|
1012
|
+
question: "What is the total amount due?",
|
|
1013
|
+
model: "max",
|
|
1014
|
+
},
|
|
1015
|
+
{ context: { documentId: "inv-2024-0892" } },
|
|
1016
|
+
);
|
|
1017
|
+
|
|
1018
|
+
console.log(result.markdown);`,
|
|
1019
|
+
python: `import requests
|
|
1020
|
+
|
|
1021
|
+
response = requests.post(
|
|
1022
|
+
"https://global.pdfvector.com/api/invoice/ask",
|
|
1023
|
+
headers={
|
|
1024
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
1025
|
+
"x-pdfvector-document-id": "inv-2024-0892",
|
|
1026
|
+
},
|
|
1027
|
+
json={
|
|
1028
|
+
"url": "https://example.com/supplier-invoice.pdf",
|
|
1029
|
+
"question": "What is the total amount due?",
|
|
1030
|
+
"model": "max",
|
|
1031
|
+
},
|
|
1032
|
+
)
|
|
1033
|
+
data = response.json()
|
|
1034
|
+
print(data["markdown"])`,
|
|
1035
|
+
response: `{
|
|
1036
|
+
"documentId": "inv-2024-0892",
|
|
1037
|
+
"markdown": "The total amount due on invoice #INV-2024-0892 is $4,600.00, with a payment due date of December 15, 2024.",
|
|
1038
|
+
"model": "max",
|
|
1039
|
+
"requestId": 43
|
|
1040
|
+
}`
|
|
1041
|
+
},
|
|
1042
|
+
{
|
|
1043
|
+
id: "invoice-extract",
|
|
1044
|
+
label: "Extract",
|
|
1045
|
+
group: "Invoice",
|
|
1046
|
+
curl: `curl -X POST https://global.pdfvector.com/api/invoice/extract \\
|
|
1047
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1048
|
+
-H "Content-Type: application/json" \\
|
|
1049
|
+
-H "x-pdfvector-document-id: inv-2024-0892" \\
|
|
1050
|
+
-d '{
|
|
1051
|
+
"url": "https://example.com/supplier-invoice.pdf",
|
|
1052
|
+
"prompt": "Extract vendor name, invoice number, date, total amount, and all line items",
|
|
1053
|
+
"schema": {
|
|
1054
|
+
"type": "object",
|
|
1055
|
+
"properties": {
|
|
1056
|
+
"vendor": { "type": "string" },
|
|
1057
|
+
"invoiceNumber": { "type": "string" },
|
|
1058
|
+
"date": { "type": "string" },
|
|
1059
|
+
"total": { "type": "number" },
|
|
1060
|
+
"lineItems": {
|
|
1061
|
+
"type": "array",
|
|
1062
|
+
"items": {
|
|
1063
|
+
"type": "object",
|
|
1064
|
+
"properties": {
|
|
1065
|
+
"description": { "type": "string" },
|
|
1066
|
+
"quantity": { "type": "number" },
|
|
1067
|
+
"unitPrice": { "type": "number" },
|
|
1068
|
+
"amount": { "type": "number" }
|
|
1069
|
+
}
|
|
1070
|
+
}
|
|
1071
|
+
}
|
|
1072
|
+
}
|
|
1073
|
+
},
|
|
1074
|
+
"model": "max"
|
|
1075
|
+
}'`,
|
|
1076
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1077
|
+
|
|
1078
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1079
|
+
|
|
1080
|
+
const result = await client.invoice.extract(
|
|
1081
|
+
{
|
|
1082
|
+
url: "https://example.com/supplier-invoice.pdf",
|
|
1083
|
+
prompt: "Extract vendor name, invoice number, date, total amount, and all line items",
|
|
1084
|
+
schema: {
|
|
1085
|
+
type: "object",
|
|
1086
|
+
properties: {
|
|
1087
|
+
vendor: { type: "string" },
|
|
1088
|
+
invoiceNumber: { type: "string" },
|
|
1089
|
+
date: { type: "string" },
|
|
1090
|
+
total: { type: "number" },
|
|
1091
|
+
lineItems: {
|
|
1092
|
+
type: "array",
|
|
1093
|
+
items: {
|
|
1094
|
+
type: "object",
|
|
1095
|
+
properties: {
|
|
1096
|
+
description: { type: "string" },
|
|
1097
|
+
quantity: { type: "number" },
|
|
1098
|
+
unitPrice: { type: "number" },
|
|
1099
|
+
amount: { type: "number" },
|
|
1100
|
+
},
|
|
1101
|
+
},
|
|
1102
|
+
},
|
|
1103
|
+
},
|
|
1104
|
+
},
|
|
1105
|
+
model: "max",
|
|
1106
|
+
},
|
|
1107
|
+
{ context: { documentId: "inv-2024-0892" } },
|
|
1108
|
+
);
|
|
1109
|
+
|
|
1110
|
+
console.log(result.data);`,
|
|
1111
|
+
python: `import requests
|
|
1112
|
+
|
|
1113
|
+
response = requests.post(
|
|
1114
|
+
"https://global.pdfvector.com/api/invoice/extract",
|
|
1115
|
+
headers={
|
|
1116
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
1117
|
+
"x-pdfvector-document-id": "inv-2024-0892",
|
|
1118
|
+
},
|
|
1119
|
+
json={
|
|
1120
|
+
"url": "https://example.com/supplier-invoice.pdf",
|
|
1121
|
+
"prompt": "Extract vendor name, invoice number, date, total amount, and all line items",
|
|
1122
|
+
"schema": {
|
|
1123
|
+
"type": "object",
|
|
1124
|
+
"properties": {
|
|
1125
|
+
"vendor": {"type": "string"},
|
|
1126
|
+
"invoiceNumber": {"type": "string"},
|
|
1127
|
+
"date": {"type": "string"},
|
|
1128
|
+
"total": {"type": "number"},
|
|
1129
|
+
"lineItems": {
|
|
1130
|
+
"type": "array",
|
|
1131
|
+
"items": {
|
|
1132
|
+
"type": "object",
|
|
1133
|
+
"properties": {
|
|
1134
|
+
"description": {"type": "string"},
|
|
1135
|
+
"quantity": {"type": "number"},
|
|
1136
|
+
"unitPrice": {"type": "number"},
|
|
1137
|
+
"amount": {"type": "number"},
|
|
1138
|
+
},
|
|
1139
|
+
},
|
|
1140
|
+
},
|
|
1141
|
+
},
|
|
1142
|
+
},
|
|
1143
|
+
"model": "max",
|
|
1144
|
+
},
|
|
1145
|
+
)
|
|
1146
|
+
data = response.json()
|
|
1147
|
+
print(data["data"])`,
|
|
1148
|
+
response: `{
|
|
1149
|
+
"documentId": "inv-2024-0892",
|
|
1150
|
+
"data": {
|
|
1151
|
+
"vendor": "TechSupply Co.",
|
|
1152
|
+
"invoiceNumber": "INV-2024-0892",
|
|
1153
|
+
"date": "2024-11-15",
|
|
1154
|
+
"total": 4600.00,
|
|
1155
|
+
"lineItems": [
|
|
1156
|
+
{ "description": "Server Rack", "quantity": 2, "unitPrice": 1700.00, "amount": 3400.00 },
|
|
1157
|
+
{ "description": "Network Switch", "quantity": 4, "unitPrice": 300.00, "amount": 1200.00 }
|
|
1158
|
+
]
|
|
1159
|
+
},
|
|
1160
|
+
"model": "max",
|
|
1161
|
+
"requestId": 44
|
|
1162
|
+
}`
|
|
1163
|
+
},
|
|
1164
|
+
{
|
|
1165
|
+
id: "bank-statement-parse",
|
|
1166
|
+
label: "Parse",
|
|
1167
|
+
group: "Bank Statement",
|
|
1168
|
+
curl: `curl -X POST https://global.pdfvector.com/api/bankStatement/parse \\
|
|
1169
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1170
|
+
-H "Content-Type: application/json" \\
|
|
1171
|
+
-H "x-pdfvector-document-id: stmt-nov-2024" \\
|
|
1172
|
+
-d '{
|
|
1173
|
+
"url": "https://example.com/monthly-statement.pdf",
|
|
1174
|
+
"model": "max"
|
|
1175
|
+
}'`,
|
|
1176
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1177
|
+
|
|
1178
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1179
|
+
|
|
1180
|
+
const result = await client.bankStatement.parse(
|
|
1181
|
+
{ url: "https://example.com/monthly-statement.pdf", model: "max" },
|
|
1182
|
+
{ context: { documentId: "stmt-nov-2024" } },
|
|
1183
|
+
);
|
|
1184
|
+
|
|
1185
|
+
console.log(result.markdown);
|
|
1186
|
+
console.log(\`Pages: \${result.pageCount}, Model: \${result.model}\`);`,
|
|
1187
|
+
python: `import requests
|
|
1188
|
+
|
|
1189
|
+
response = requests.post(
|
|
1190
|
+
"https://global.pdfvector.com/api/bankStatement/parse",
|
|
1191
|
+
headers={
|
|
1192
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
1193
|
+
"x-pdfvector-document-id": "stmt-nov-2024",
|
|
1194
|
+
},
|
|
1195
|
+
json={
|
|
1196
|
+
"url": "https://example.com/monthly-statement.pdf",
|
|
1197
|
+
"model": "max",
|
|
1198
|
+
},
|
|
1199
|
+
)
|
|
1200
|
+
data = response.json()
|
|
1201
|
+
print(data["markdown"])`,
|
|
1202
|
+
response: `{
|
|
1203
|
+
"documentId": "stmt-nov-2024",
|
|
1204
|
+
"markdown": "# Bank Statement — Chase Checking ****4821\\n\\n**Period:** Nov 1 – Nov 30, 2024\\n**Opening Balance:** $12,450.33\\n**Closing Balance:** $14,892.17\\n\\n| Date | Description | Amount |\\n|------|-------------|--------|\\n| 11/02 | Direct Deposit | +$5,200.00 |\\n| 11/05 | Rent Payment | -$2,100.00 |",
|
|
1205
|
+
"pageCount": 3,
|
|
1206
|
+
"model": "max",
|
|
1207
|
+
"html": "<h1>Bank Statement — Chase Checking ****4821</h1><table><tr><td>11/02</td><td>Direct Deposit</td><td>+$5,200.00</td></tr></table>",
|
|
1208
|
+
"requestId": 42
|
|
1209
|
+
}`
|
|
1210
|
+
},
|
|
1211
|
+
{
|
|
1212
|
+
id: "bank-statement-ask",
|
|
1213
|
+
label: "Ask",
|
|
1214
|
+
group: "Bank Statement",
|
|
1215
|
+
curl: `curl -X POST https://global.pdfvector.com/api/bankStatement/ask \\
|
|
1216
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1217
|
+
-H "Content-Type: application/json" \\
|
|
1218
|
+
-H "x-pdfvector-document-id: stmt-nov-2024" \\
|
|
1219
|
+
-d '{
|
|
1220
|
+
"url": "https://example.com/monthly-statement.pdf",
|
|
1221
|
+
"question": "What is the closing balance?",
|
|
1222
|
+
"model": "max"
|
|
1223
|
+
}'`,
|
|
1224
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1225
|
+
|
|
1226
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1227
|
+
|
|
1228
|
+
const result = await client.bankStatement.ask(
|
|
1229
|
+
{
|
|
1230
|
+
url: "https://example.com/monthly-statement.pdf",
|
|
1231
|
+
question: "What is the closing balance?",
|
|
1232
|
+
model: "max",
|
|
1233
|
+
},
|
|
1234
|
+
{ context: { documentId: "stmt-nov-2024" } },
|
|
1235
|
+
);
|
|
1236
|
+
|
|
1237
|
+
console.log(result.markdown);`,
|
|
1238
|
+
python: `import requests
|
|
1239
|
+
|
|
1240
|
+
response = requests.post(
|
|
1241
|
+
"https://global.pdfvector.com/api/bankStatement/ask",
|
|
1242
|
+
headers={
|
|
1243
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
1244
|
+
"x-pdfvector-document-id": "stmt-nov-2024",
|
|
1245
|
+
},
|
|
1246
|
+
json={
|
|
1247
|
+
"url": "https://example.com/monthly-statement.pdf",
|
|
1248
|
+
"question": "What is the closing balance?",
|
|
1249
|
+
"model": "max",
|
|
1250
|
+
},
|
|
1251
|
+
)
|
|
1252
|
+
data = response.json()
|
|
1253
|
+
print(data["markdown"])`,
|
|
1254
|
+
response: `{
|
|
1255
|
+
"documentId": "stmt-nov-2024",
|
|
1256
|
+
"markdown": "The closing balance for the statement period ending November 30, 2024 is $14,892.17.",
|
|
1257
|
+
"model": "max",
|
|
1258
|
+
"requestId": 43
|
|
1259
|
+
}`
|
|
1260
|
+
},
|
|
1261
|
+
{
|
|
1262
|
+
id: "bank-statement-extract",
|
|
1263
|
+
label: "Extract",
|
|
1264
|
+
group: "Bank Statement",
|
|
1265
|
+
curl: `curl -X POST https://global.pdfvector.com/api/bankStatement/extract \\
|
|
1266
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1267
|
+
-H "Content-Type: application/json" \\
|
|
1268
|
+
-H "x-pdfvector-document-id: stmt-nov-2024" \\
|
|
1269
|
+
-d '{
|
|
1270
|
+
"url": "https://example.com/monthly-statement.pdf",
|
|
1271
|
+
"prompt": "Extract account holder, opening balance, closing balance, statement period, and all transactions",
|
|
1272
|
+
"schema": {
|
|
1273
|
+
"type": "object",
|
|
1274
|
+
"properties": {
|
|
1275
|
+
"accountHolder": { "type": "string" },
|
|
1276
|
+
"openingBalance": { "type": "number" },
|
|
1277
|
+
"closingBalance": { "type": "number" },
|
|
1278
|
+
"statementPeriod": { "type": "string" },
|
|
1279
|
+
"transactions": {
|
|
1280
|
+
"type": "array",
|
|
1281
|
+
"items": {
|
|
1282
|
+
"type": "object",
|
|
1283
|
+
"properties": {
|
|
1284
|
+
"date": { "type": "string" },
|
|
1285
|
+
"description": { "type": "string" },
|
|
1286
|
+
"amount": { "type": "number" },
|
|
1287
|
+
"balance": { "type": "number" }
|
|
1288
|
+
}
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
}
|
|
1292
|
+
},
|
|
1293
|
+
"model": "max"
|
|
1294
|
+
}'`,
|
|
1295
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1296
|
+
|
|
1297
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1298
|
+
|
|
1299
|
+
const result = await client.bankStatement.extract(
|
|
1300
|
+
{
|
|
1301
|
+
url: "https://example.com/monthly-statement.pdf",
|
|
1302
|
+
prompt: "Extract account holder, opening balance, closing balance, statement period, and all transactions",
|
|
1303
|
+
schema: {
|
|
1304
|
+
type: "object",
|
|
1305
|
+
properties: {
|
|
1306
|
+
accountHolder: { type: "string" },
|
|
1307
|
+
openingBalance: { type: "number" },
|
|
1308
|
+
closingBalance: { type: "number" },
|
|
1309
|
+
statementPeriod: { type: "string" },
|
|
1310
|
+
transactions: {
|
|
1311
|
+
type: "array",
|
|
1312
|
+
items: {
|
|
1313
|
+
type: "object",
|
|
1314
|
+
properties: {
|
|
1315
|
+
date: { type: "string" },
|
|
1316
|
+
description: { type: "string" },
|
|
1317
|
+
amount: { type: "number" },
|
|
1318
|
+
balance: { type: "number" },
|
|
1319
|
+
},
|
|
1320
|
+
},
|
|
1321
|
+
},
|
|
1322
|
+
},
|
|
1323
|
+
},
|
|
1324
|
+
model: "max",
|
|
1325
|
+
},
|
|
1326
|
+
{ context: { documentId: "stmt-nov-2024" } },
|
|
1327
|
+
);
|
|
1328
|
+
|
|
1329
|
+
console.log(result.data);`,
|
|
1330
|
+
python: `import requests
|
|
1331
|
+
|
|
1332
|
+
response = requests.post(
|
|
1333
|
+
"https://global.pdfvector.com/api/bankStatement/extract",
|
|
1334
|
+
headers={
|
|
1335
|
+
"Authorization": "Bearer YOUR_API_KEY",
|
|
1336
|
+
"x-pdfvector-document-id": "stmt-nov-2024",
|
|
1337
|
+
},
|
|
1338
|
+
json={
|
|
1339
|
+
"url": "https://example.com/monthly-statement.pdf",
|
|
1340
|
+
"prompt": "Extract account holder, opening balance, closing balance, statement period, and all transactions",
|
|
1341
|
+
"schema": {
|
|
1342
|
+
"type": "object",
|
|
1343
|
+
"properties": {
|
|
1344
|
+
"accountHolder": {"type": "string"},
|
|
1345
|
+
"openingBalance": {"type": "number"},
|
|
1346
|
+
"closingBalance": {"type": "number"},
|
|
1347
|
+
"statementPeriod": {"type": "string"},
|
|
1348
|
+
"transactions": {
|
|
1349
|
+
"type": "array",
|
|
1350
|
+
"items": {
|
|
1351
|
+
"type": "object",
|
|
1352
|
+
"properties": {
|
|
1353
|
+
"date": {"type": "string"},
|
|
1354
|
+
"description": {"type": "string"},
|
|
1355
|
+
"amount": {"type": "number"},
|
|
1356
|
+
"balance": {"type": "number"},
|
|
1357
|
+
},
|
|
1358
|
+
},
|
|
1359
|
+
},
|
|
1360
|
+
},
|
|
1361
|
+
},
|
|
1362
|
+
"model": "max",
|
|
1363
|
+
},
|
|
1364
|
+
)
|
|
1365
|
+
data = response.json()
|
|
1366
|
+
print(data["data"])`,
|
|
1367
|
+
response: `{
|
|
1368
|
+
"documentId": "stmt-nov-2024",
|
|
1369
|
+
"data": {
|
|
1370
|
+
"accountHolder": "John A. Smith",
|
|
1371
|
+
"openingBalance": 12450.33,
|
|
1372
|
+
"closingBalance": 14892.17,
|
|
1373
|
+
"statementPeriod": "Nov 1 – Nov 30, 2024",
|
|
1374
|
+
"transactions": [
|
|
1375
|
+
{ "date": "2024-11-02", "description": "Direct Deposit - Employer", "amount": 5200.00, "balance": 17650.33 },
|
|
1376
|
+
{ "date": "2024-11-05", "description": "Rent Payment", "amount": -2100.00, "balance": 15550.33 },
|
|
1377
|
+
{ "date": "2024-11-12", "description": "Grocery Store", "amount": -187.43, "balance": 15362.90 },
|
|
1378
|
+
{ "date": "2024-11-18", "description": "Utility Bill", "amount": -245.73, "balance": 15117.17 }
|
|
1379
|
+
]
|
|
1380
|
+
},
|
|
1381
|
+
"model": "max",
|
|
1382
|
+
"requestId": 44
|
|
1383
|
+
}`
|
|
1384
|
+
},
|
|
1385
|
+
{
|
|
1386
|
+
id: "academic-search",
|
|
1387
|
+
label: "Search",
|
|
1388
|
+
group: "Academic",
|
|
1389
|
+
curl: `curl -X POST https://global.pdfvector.com/api/academic/search \\
|
|
1390
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1391
|
+
-H "Content-Type: application/json" \\
|
|
1392
|
+
-d '{
|
|
1393
|
+
"query": "transformer attention mechanism",
|
|
1394
|
+
"providers": ["semantic-scholar", "pubmed", "openalex", "europe-pmc"],
|
|
1395
|
+
"limit": 10,
|
|
1396
|
+
"offset": 0,
|
|
1397
|
+
"yearFrom": 2017,
|
|
1398
|
+
"yearTo": 2025,
|
|
1399
|
+
"fields": ["title", "authors", "year", "doi", "citationCount"]
|
|
1400
|
+
}'`,
|
|
1401
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1402
|
+
|
|
1403
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1404
|
+
|
|
1405
|
+
const result = await client.academic.search({
|
|
1406
|
+
query: "transformer attention mechanism",
|
|
1407
|
+
providers: ["semantic-scholar", "pubmed", "openalex", "europe-pmc"],
|
|
1408
|
+
limit: 10,
|
|
1409
|
+
offset: 0,
|
|
1410
|
+
yearFrom: 2017,
|
|
1411
|
+
yearTo: 2025,
|
|
1412
|
+
fields: ["title", "authors", "year", "doi", "totalCitations"],
|
|
1413
|
+
});
|
|
1414
|
+
|
|
1415
|
+
console.log(\`Found \${result.estimatedTotalResults} results\`);
|
|
1416
|
+
for (const paper of result.results) {
|
|
1417
|
+
console.log(\`\${paper.title} (\${paper.year})\`);
|
|
1418
|
+
}`,
|
|
1419
|
+
python: `import requests
|
|
1420
|
+
|
|
1421
|
+
response = requests.post(
|
|
1422
|
+
"https://global.pdfvector.com/api/academic/search",
|
|
1423
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
1424
|
+
json={
|
|
1425
|
+
"query": "transformer attention mechanism",
|
|
1426
|
+
"providers": ["semantic-scholar", "pubmed", "openalex", "europe-pmc"],
|
|
1427
|
+
"limit": 10,
|
|
1428
|
+
"offset": 0,
|
|
1429
|
+
"yearFrom": 2017,
|
|
1430
|
+
"yearTo": 2025,
|
|
1431
|
+
"fields": ["title", "authors", "year", "doi", "citationCount"],
|
|
1432
|
+
},
|
|
1433
|
+
)
|
|
1434
|
+
data = response.json()
|
|
1435
|
+
print(f"Found {data['estimatedTotalResults']} results")`,
|
|
1436
|
+
response: `{
|
|
1437
|
+
"estimatedTotalResults": 48293,
|
|
1438
|
+
"results": [
|
|
1439
|
+
{
|
|
1440
|
+
"doi": "10.48550/arXiv.1706.03762",
|
|
1441
|
+
"title": "Attention Is All You Need",
|
|
1442
|
+
"authors": [{"name": "Ashish Vaswani"}, {"name": "Noam Shazeer"}],
|
|
1443
|
+
"year": 2017,
|
|
1444
|
+
"totalCitations": 120843,
|
|
1445
|
+
"abstract": "The dominant sequence transduction models...",
|
|
1446
|
+
"provider": "semantic-scholar"
|
|
1447
|
+
},
|
|
1448
|
+
{
|
|
1449
|
+
"doi": "10.18653/v1/N19-1423",
|
|
1450
|
+
"title": "BERT: Pre-training of Deep Bidirectional Transformers",
|
|
1451
|
+
"authors": [{"name": "Jacob Devlin"}, {"name": "Ming-Wei Chang"}],
|
|
1452
|
+
"year": 2019,
|
|
1453
|
+
"totalCitations": 95421,
|
|
1454
|
+
"provider": "semantic-scholar"
|
|
1455
|
+
}
|
|
1456
|
+
],
|
|
1457
|
+
"requestId": 45
|
|
1458
|
+
}`
|
|
1459
|
+
},
|
|
1460
|
+
{
|
|
1461
|
+
id: "academic-fetch",
|
|
1462
|
+
label: "Fetch",
|
|
1463
|
+
group: "Academic",
|
|
1464
|
+
curl: `curl -X POST https://global.pdfvector.com/api/academic/fetch \\
|
|
1465
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1466
|
+
-H "Content-Type: application/json" \\
|
|
1467
|
+
-d '{
|
|
1468
|
+
"ids": ["10.1038/s41586-021-03819-2", "2303.08774", "PMID:33116299"],
|
|
1469
|
+
"fields": ["title", "authors", "year", "doi", "abstract", "citationCount"]
|
|
1470
|
+
}'`,
|
|
1471
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1472
|
+
|
|
1473
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1474
|
+
|
|
1475
|
+
const result = await client.academic.fetch({
|
|
1476
|
+
ids: ["10.1038/s41586-021-03819-2", "2303.08774", "PMID:33116299"],
|
|
1477
|
+
fields: ["title", "authors", "year", "doi", "abstract", "totalCitations"],
|
|
1478
|
+
});
|
|
1479
|
+
|
|
1480
|
+
for (const paper of result.results) {
|
|
1481
|
+
console.log(\`\${paper.title} — \${paper.detectedProvider}\`);
|
|
1482
|
+
}`,
|
|
1483
|
+
python: `import requests
|
|
1484
|
+
|
|
1485
|
+
response = requests.post(
|
|
1486
|
+
"https://global.pdfvector.com/api/academic/fetch",
|
|
1487
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
1488
|
+
json={
|
|
1489
|
+
"ids": ["10.1038/s41586-021-03819-2", "2303.08774", "PMID:33116299"],
|
|
1490
|
+
"fields": ["title", "authors", "year", "doi", "abstract", "citationCount"],
|
|
1491
|
+
},
|
|
1492
|
+
)
|
|
1493
|
+
for paper in response.json()["results"]:
|
|
1494
|
+
print(paper["title"])`,
|
|
1495
|
+
response: `{
|
|
1496
|
+
"results": [
|
|
1497
|
+
{
|
|
1498
|
+
"id": "10.1038/s41586-021-03819-2",
|
|
1499
|
+
"detectedProvider": "semantic-scholar",
|
|
1500
|
+
"doi": "10.1038/s41586-021-03819-2",
|
|
1501
|
+
"title": "Highly accurate protein structure prediction with AlphaFold",
|
|
1502
|
+
"authors": [{"name": "John Jumper"}, {"name": "Richard Evans"}],
|
|
1503
|
+
"year": 2021,
|
|
1504
|
+
"totalCitations": 28451,
|
|
1505
|
+
"url": "https://global.pdfvector.com/publications/doi:10.1038%2Fs41586-021-03819-2",
|
|
1506
|
+
"providerURL": "https://www.semanticscholar.org/paper/fcc0b70984..."
|
|
1507
|
+
},
|
|
1508
|
+
{
|
|
1509
|
+
"id": "2303.08774",
|
|
1510
|
+
"detectedProvider": "arxiv",
|
|
1511
|
+
"title": "GPT-4 Technical Report",
|
|
1512
|
+
"authors": [{"name": "OpenAI"}],
|
|
1513
|
+
"year": 2023,
|
|
1514
|
+
"url": "https://global.pdfvector.com/publications/arxiv:2303.08774",
|
|
1515
|
+
"providerURL": "https://arxiv.org/abs/2303.08774"
|
|
1516
|
+
}
|
|
1517
|
+
],
|
|
1518
|
+
"requestId": 46
|
|
1519
|
+
}`
|
|
1520
|
+
},
|
|
1521
|
+
{
|
|
1522
|
+
id: "academic-parse",
|
|
1523
|
+
label: "Parse",
|
|
1524
|
+
group: "Academic",
|
|
1525
|
+
curl: buildAcademicParseCurl(),
|
|
1526
|
+
typescript: buildAcademicParseTypeScript(),
|
|
1527
|
+
python: buildAcademicParsePython(),
|
|
1528
|
+
response: `{
|
|
1529
|
+
"id": "${arxivId}",
|
|
1530
|
+
"title": "Attention Is All You Need",
|
|
1531
|
+
"doi": "10.48550/arXiv.${arxivId}",
|
|
1532
|
+
"url": "https://global.pdfvector.com/publications/arxiv:${arxivId}",
|
|
1533
|
+
"providerURL": "https://arxiv.org/abs/${arxivId}",
|
|
1534
|
+
"pdfURL": "https://arxiv.org/pdf/${arxivId}",
|
|
1535
|
+
"detectedProvider": "arxiv",
|
|
1536
|
+
"markdown": "# Attention Is All You Need\\n\\nAshish Vaswani...",
|
|
1537
|
+
"pageCount": 15,
|
|
1538
|
+
"pages": [{ "pageNumber": 1, "markdown": "# Attention Is All You Need\\n\\nAshish Vaswani..." }],
|
|
1539
|
+
"model": "auto",
|
|
1540
|
+
"credits": 15,
|
|
1541
|
+
"requestId": 47
|
|
1542
|
+
}`
|
|
1543
|
+
},
|
|
1544
|
+
{
|
|
1545
|
+
id: "academic-find-citations",
|
|
1546
|
+
label: "Find Citations",
|
|
1547
|
+
group: "Academic",
|
|
1548
|
+
curl: `curl -X POST https://global.pdfvector.com/api/academic/findCitations \\
|
|
1549
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1550
|
+
-H "Content-Type: application/json" \\
|
|
1551
|
+
-d '{
|
|
1552
|
+
"paragraph": "Large language models have demonstrated remarkable few-shot learning capabilities across a wide range of NLP tasks. The scaling of transformer architectures to billions of parameters has led to emergent abilities not observed in smaller models.",
|
|
1553
|
+
"providers": ["semantic-scholar", "openalex"],
|
|
1554
|
+
"fields": ["title", "authors", "year", "doi", "citationCount"]
|
|
1555
|
+
}'`,
|
|
1556
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1557
|
+
|
|
1558
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1559
|
+
|
|
1560
|
+
const result = await client.academic.findCitations({
|
|
1561
|
+
paragraph: "Large language models have demonstrated remarkable few-shot learning capabilities across a wide range of NLP tasks. The scaling of transformer architectures to billions of parameters has led to emergent abilities not observed in smaller models.",
|
|
1562
|
+
providers: ["semantic-scholar", "openalex"],
|
|
1563
|
+
fields: ["title", "authors", "year", "doi", "totalCitations"],
|
|
1564
|
+
});
|
|
1565
|
+
|
|
1566
|
+
console.log(\`Found \${result.totalCitations} citations\`);
|
|
1567
|
+
for (const item of result.results) {
|
|
1568
|
+
console.log(\`"\${item.sentence}"\`);
|
|
1569
|
+
for (const cite of item.citations) {
|
|
1570
|
+
console.log(\` [\${cite.score}] \${cite.title}\`);
|
|
1571
|
+
}
|
|
1572
|
+
}`,
|
|
1573
|
+
python: `import requests
|
|
1574
|
+
|
|
1575
|
+
response = requests.post(
|
|
1576
|
+
"https://global.pdfvector.com/api/academic/findCitations",
|
|
1577
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
1578
|
+
json={
|
|
1579
|
+
"paragraph": "Large language models have demonstrated remarkable few-shot learning capabilities across a wide range of NLP tasks. The scaling of transformer architectures to billions of parameters has led to emergent abilities not observed in smaller models.",
|
|
1580
|
+
"providers": ["semantic-scholar", "openalex"],
|
|
1581
|
+
"fields": ["title", "authors", "year", "doi", "citationCount"],
|
|
1582
|
+
},
|
|
1583
|
+
)
|
|
1584
|
+
data = response.json()
|
|
1585
|
+
print(f"Found {data['totalCitations']} citations")`,
|
|
1586
|
+
response: `{
|
|
1587
|
+
"results": [
|
|
1588
|
+
{
|
|
1589
|
+
"sentence": "Deep learning has revolutionized NLP.",
|
|
1590
|
+
"citations": [
|
|
1591
|
+
{
|
|
1592
|
+
"score": 9,
|
|
1593
|
+
"doi": "10.1038/nature14539",
|
|
1594
|
+
"title": "Deep Learning",
|
|
1595
|
+
"authors": [{"name": "Ian Goodfellow"}, {"name": "Yoshua Bengio"}],
|
|
1596
|
+
"year": 2016,
|
|
1597
|
+
"totalCitations": 75000
|
|
1598
|
+
}
|
|
1599
|
+
]
|
|
1600
|
+
},
|
|
1601
|
+
{
|
|
1602
|
+
"sentence": "Transformer architectures have become the dominant approach for sequence modeling.",
|
|
1603
|
+
"citations": [
|
|
1604
|
+
{
|
|
1605
|
+
"score": 10,
|
|
1606
|
+
"doi": "10.48550/arXiv.1706.03762",
|
|
1607
|
+
"title": "Attention Is All You Need",
|
|
1608
|
+
"authors": [{"name": "Ashish Vaswani"}],
|
|
1609
|
+
"year": 2017,
|
|
1610
|
+
"totalCitations": 120843
|
|
1611
|
+
}
|
|
1612
|
+
]
|
|
1613
|
+
}
|
|
1614
|
+
],
|
|
1615
|
+
"sentenceCount": 2,
|
|
1616
|
+
"totalCitations": 2,
|
|
1617
|
+
"requestId": 47
|
|
1618
|
+
}`
|
|
1619
|
+
},
|
|
1620
|
+
{
|
|
1621
|
+
id: "academic-paper-graph",
|
|
1622
|
+
label: "Paper Graph",
|
|
1623
|
+
group: "Academic",
|
|
1624
|
+
curl: `curl -X POST https://global.pdfvector.com/api/academic/paperGraph \\
|
|
1625
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1626
|
+
-H "Content-Type: application/json" \\
|
|
1627
|
+
-d '{
|
|
1628
|
+
"id": "10.1038/nature12373",
|
|
1629
|
+
"citationsLimit": 20,
|
|
1630
|
+
"referencesLimit": 20,
|
|
1631
|
+
"fields": ["title", "authors", "year", "doi", "totalCitations"]
|
|
1632
|
+
}'`,
|
|
1633
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1634
|
+
|
|
1635
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1636
|
+
|
|
1637
|
+
const result = await client.academic.paperGraph({
|
|
1638
|
+
id: "10.1038/nature12373",
|
|
1639
|
+
citationsLimit: 20,
|
|
1640
|
+
referencesLimit: 20,
|
|
1641
|
+
fields: ["title", "authors", "year", "doi", "totalCitations"],
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
console.log(\`Paper: \${result.paper.title}\`);
|
|
1645
|
+
console.log(\`Citations: \${result.citations.length} of \${result.totalCitations}\`);
|
|
1646
|
+
console.log(\`References: \${result.references.length} of \${result.totalReferences}\`);
|
|
1647
|
+
|
|
1648
|
+
for (const cite of result.citations) {
|
|
1649
|
+
console.log(\` Cited by: \${cite.title} (\${cite.year})\`);
|
|
1650
|
+
}`,
|
|
1651
|
+
python: `import requests
|
|
1652
|
+
|
|
1653
|
+
response = requests.post(
|
|
1654
|
+
"https://global.pdfvector.com/api/academic/paperGraph",
|
|
1655
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
1656
|
+
json={
|
|
1657
|
+
"id": "10.1038/nature12373",
|
|
1658
|
+
"citationsLimit": 20,
|
|
1659
|
+
"referencesLimit": 20,
|
|
1660
|
+
"fields": ["title", "authors", "year", "doi", "totalCitations"],
|
|
1661
|
+
},
|
|
1662
|
+
)
|
|
1663
|
+
data = response.json()
|
|
1664
|
+
print(f"Paper: {data['paper']['title']}")
|
|
1665
|
+
print(f"Citations: {len(data['citations'])} of {data['totalCitations']}")`,
|
|
1666
|
+
response: `{
|
|
1667
|
+
"paper": {
|
|
1668
|
+
"doi": "10.1038/nature12373",
|
|
1669
|
+
"title": "Sequence-to-sequence models for data-to-text generation",
|
|
1670
|
+
"authors": [{"name": "Sam Wiseman"}, {"name": "Stuart Shieber"}],
|
|
1671
|
+
"year": 2017,
|
|
1672
|
+
"totalCitations": 842
|
|
1673
|
+
},
|
|
1674
|
+
"citations": [
|
|
1675
|
+
{
|
|
1676
|
+
"doi": "10.18653/v1/P19-1602",
|
|
1677
|
+
"title": "Data-to-Text Generation with Content Selection and Planning",
|
|
1678
|
+
"authors": [{"name": "Ratish Puduppully"}],
|
|
1679
|
+
"year": 2019,
|
|
1680
|
+
"totalCitations": 312
|
|
1681
|
+
},
|
|
1682
|
+
{
|
|
1683
|
+
"doi": "10.18653/v1/2020.acl-main.17",
|
|
1684
|
+
"title": "Bridging the Structural Gap Between Encoding and Decoding",
|
|
1685
|
+
"authors": [{"name": "Kaiqiang Song"}],
|
|
1686
|
+
"year": 2020,
|
|
1687
|
+
"totalCitations": 45
|
|
1688
|
+
}
|
|
1689
|
+
],
|
|
1690
|
+
"references": [
|
|
1691
|
+
{
|
|
1692
|
+
"doi": "10.48550/arXiv.1409.3215",
|
|
1693
|
+
"title": "Sequence to Sequence Learning with Neural Networks",
|
|
1694
|
+
"authors": [{"name": "Ilya Sutskever"}],
|
|
1695
|
+
"year": 2014,
|
|
1696
|
+
"totalCitations": 25891
|
|
1697
|
+
}
|
|
1698
|
+
],
|
|
1699
|
+
"totalCitations": 842,
|
|
1700
|
+
"totalReferences": 35,
|
|
1701
|
+
"requestId": 48
|
|
1702
|
+
}`
|
|
1703
|
+
},
|
|
1704
|
+
{
|
|
1705
|
+
id: "academic-similar-papers",
|
|
1706
|
+
label: "Similar Papers",
|
|
1707
|
+
group: "Academic",
|
|
1708
|
+
curl: `curl -X POST https://global.pdfvector.com/api/academic/similarPapers \\
|
|
1709
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1710
|
+
-H "Content-Type: application/json" \\
|
|
1711
|
+
-d '{
|
|
1712
|
+
"id": "10.1038/nature12373",
|
|
1713
|
+
"limit": 10,
|
|
1714
|
+
"includeEdges": false,
|
|
1715
|
+
"fields": ["title", "authors", "year", "doi", "totalCitations"]
|
|
1716
|
+
}'`,
|
|
1717
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1718
|
+
|
|
1719
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1720
|
+
|
|
1721
|
+
const result = await client.academic.similarPapers({
|
|
1722
|
+
id: "10.1038/nature12373",
|
|
1723
|
+
limit: 10,
|
|
1724
|
+
includeEdges: false,
|
|
1725
|
+
fields: ["title", "authors", "year", "doi", "totalCitations"],
|
|
1726
|
+
});
|
|
1727
|
+
|
|
1728
|
+
console.log(\`Seed: \${result.seed.title}\`);
|
|
1729
|
+
console.log(\`Found \${result.results.length} similar papers\`);
|
|
1730
|
+
|
|
1731
|
+
for (const item of result.results) {
|
|
1732
|
+
console.log(\` [\${item.similarity.toFixed(2)}] \${item.publication.title}\`);
|
|
1733
|
+
}`,
|
|
1734
|
+
python: `import requests
|
|
1735
|
+
|
|
1736
|
+
response = requests.post(
|
|
1737
|
+
"https://global.pdfvector.com/api/academic/similarPapers",
|
|
1738
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
1739
|
+
json={
|
|
1740
|
+
"id": "10.1038/nature12373",
|
|
1741
|
+
"limit": 10,
|
|
1742
|
+
"includeEdges": False,
|
|
1743
|
+
"fields": ["title", "authors", "year", "doi", "totalCitations"],
|
|
1744
|
+
},
|
|
1745
|
+
)
|
|
1746
|
+
data = response.json()
|
|
1747
|
+
print(f"Seed: {data['seed']['title']}")
|
|
1748
|
+
for item in data["results"]:
|
|
1749
|
+
print(f" [{item['similarity']:.2f}] {item['publication']['title']}")`,
|
|
1750
|
+
response: `{
|
|
1751
|
+
"seed": {
|
|
1752
|
+
"doi": "10.1038/nature12373",
|
|
1753
|
+
"title": "Sequence-to-sequence models for data-to-text generation",
|
|
1754
|
+
"authors": [{"name": "Sam Wiseman"}],
|
|
1755
|
+
"year": 2017,
|
|
1756
|
+
"totalCitations": 842
|
|
1757
|
+
},
|
|
1758
|
+
"results": [
|
|
1759
|
+
{
|
|
1760
|
+
"publication": {
|
|
1761
|
+
"doi": "10.18653/v1/P19-1602",
|
|
1762
|
+
"title": "Data-to-Text Generation with Content Selection and Planning",
|
|
1763
|
+
"authors": [{"name": "Ratish Puduppully"}],
|
|
1764
|
+
"year": 2019,
|
|
1765
|
+
"totalCitations": 312
|
|
1766
|
+
},
|
|
1767
|
+
"similarity": 0.94,
|
|
1768
|
+
"pageRank": 0.0023,
|
|
1769
|
+
"distance": 1
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
"publication": {
|
|
1773
|
+
"doi": "10.1162/tacl_a_00302",
|
|
1774
|
+
"title": "Neural Data-to-Text Generation: A Comparison between Pipeline and End-to-End Architectures",
|
|
1775
|
+
"authors": [{"name": "Thiago Castro Ferreira"}],
|
|
1776
|
+
"year": 2019,
|
|
1777
|
+
"totalCitations": 89
|
|
1778
|
+
},
|
|
1779
|
+
"similarity": 0.87,
|
|
1780
|
+
"pageRank": 0.0018,
|
|
1781
|
+
"distance": 1
|
|
1782
|
+
}
|
|
1783
|
+
],
|
|
1784
|
+
"requestId": 49
|
|
1785
|
+
}`
|
|
1786
|
+
},
|
|
1787
|
+
{
|
|
1788
|
+
id: "academic-search-grants",
|
|
1789
|
+
label: "Search Grants",
|
|
1790
|
+
group: "Academic",
|
|
1791
|
+
curl: `curl -X POST https://global.pdfvector.com/api/academic/searchGrants \\
|
|
1792
|
+
-H "Authorization: Bearer YOUR_API_KEY" \\
|
|
1793
|
+
-H "Content-Type: application/json" \\
|
|
1794
|
+
-d '{
|
|
1795
|
+
"query": "machine learning healthcare",
|
|
1796
|
+
"providers": ["grants-gov", "nih-reporter"],
|
|
1797
|
+
"limit": 5,
|
|
1798
|
+
"fundingMin": 50000,
|
|
1799
|
+
"deadlineFrom": "2026-01-01",
|
|
1800
|
+
"fields": ["title", "agency", "fundingAmountMin", "fundingAmountMax", "deadlineDate", "url"]
|
|
1801
|
+
}'`,
|
|
1802
|
+
typescript: `import { createClient } from "@pdfvector/client";
|
|
1803
|
+
|
|
1804
|
+
const client = createClient({ apiKey: "YOUR_API_KEY" });
|
|
1805
|
+
|
|
1806
|
+
const result = await client.academic.searchGrants({
|
|
1807
|
+
query: "machine learning healthcare",
|
|
1808
|
+
providers: ["grants-gov", "nih-reporter"],
|
|
1809
|
+
limit: 5,
|
|
1810
|
+
fundingMin: 50000,
|
|
1811
|
+
deadlineFrom: "2026-01-01",
|
|
1812
|
+
fields: ["title", "agency", "fundingAmountMin", "fundingAmountMax", "deadlineDate", "url"],
|
|
1813
|
+
});
|
|
1814
|
+
|
|
1815
|
+
console.log(\`Found \${result.estimatedTotalResults} grants\`);
|
|
1816
|
+
for (const grant of result.results) {
|
|
1817
|
+
console.log(\`\${grant.title} — \${grant.agency}\`);
|
|
1818
|
+
console.log(\` Funding: $\${grant.fundingAmountMin?.toLocaleString()} - $\${grant.fundingAmountMax?.toLocaleString()}\`);
|
|
1819
|
+
console.log(\` Deadline: \${grant.deadlineDate}\`);
|
|
1820
|
+
}`,
|
|
1821
|
+
python: `import requests
|
|
1822
|
+
|
|
1823
|
+
response = requests.post(
|
|
1824
|
+
"https://global.pdfvector.com/api/academic/searchGrants",
|
|
1825
|
+
headers={"Authorization": "Bearer YOUR_API_KEY"},
|
|
1826
|
+
json={
|
|
1827
|
+
"query": "machine learning healthcare",
|
|
1828
|
+
"providers": ["grants-gov", "nih-reporter"],
|
|
1829
|
+
"limit": 5,
|
|
1830
|
+
"fundingMin": 50000,
|
|
1831
|
+
"deadlineFrom": "2026-01-01",
|
|
1832
|
+
"fields": ["title", "agency", "fundingAmountMin", "fundingAmountMax", "deadlineDate", "url"],
|
|
1833
|
+
},
|
|
1834
|
+
)
|
|
1835
|
+
data = response.json()
|
|
1836
|
+
print(f"Found {data['estimatedTotalResults']} grants")
|
|
1837
|
+
for grant in data["results"]:
|
|
1838
|
+
print(f"{grant['title']} — {grant['agency']}")`,
|
|
1839
|
+
response: `{
|
|
1840
|
+
"estimatedTotalResults": 127,
|
|
1841
|
+
"results": [
|
|
1842
|
+
{
|
|
1843
|
+
"title": "Artificial Intelligence for Transforming Healthcare Delivery",
|
|
1844
|
+
"agency": "National Institutes of Health",
|
|
1845
|
+
"fundingAmountMin": 250000,
|
|
1846
|
+
"fundingAmountMax": 500000,
|
|
1847
|
+
"deadlineDate": "2026-06-15",
|
|
1848
|
+
"url": "https://grants.nih.gov/grants/guide/rfa-files/RFA-HL-25-001.html",
|
|
1849
|
+
"provider": "nih-reporter"
|
|
1850
|
+
},
|
|
1851
|
+
{
|
|
1852
|
+
"title": "Machine Learning Applications in Clinical Decision Support",
|
|
1853
|
+
"agency": "Department of Health and Human Services",
|
|
1854
|
+
"fundingAmountMin": 100000,
|
|
1855
|
+
"fundingAmountMax": 300000,
|
|
1856
|
+
"deadlineDate": "2026-03-31",
|
|
1857
|
+
"url": "https://www.grants.gov/search-results-detail/123456",
|
|
1858
|
+
"provider": "grants-gov"
|
|
1859
|
+
}
|
|
1860
|
+
],
|
|
1861
|
+
"requestId": 50
|
|
1862
|
+
}`
|
|
1863
|
+
}
|
|
1864
|
+
];
|
|
1865
|
+
function getCodeExample(id) {
|
|
1866
|
+
return publicApiCodeExamples.find((example) => example.id === id);
|
|
1867
|
+
}
|
|
1868
|
+
function getOpenApiCodeSamples(id) {
|
|
1869
|
+
const example = getCodeExample(id);
|
|
1870
|
+
if (!example) throw new Error(`Missing API code example for ${id}`);
|
|
1871
|
+
return [
|
|
1872
|
+
{
|
|
1873
|
+
lang: "cURL",
|
|
1874
|
+
source: example.curl
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
lang: "TypeScript",
|
|
1878
|
+
source: example.typescript
|
|
1879
|
+
},
|
|
1880
|
+
{
|
|
1881
|
+
lang: "Python",
|
|
1882
|
+
source: example.python
|
|
1883
|
+
}
|
|
1884
|
+
];
|
|
1885
|
+
}
|
|
1886
|
+
const documentParseOpenApiCodeSamples = getOpenApiCodeSamples("document-parse");
|
|
1887
|
+
const academicParseOpenApiCodeSamples = getOpenApiCodeSamples("academic-parse");
|
|
1888
|
+
// ../util/lib/contract/instance/router/academic/provider.ts
|
|
1889
|
+
const providerSchema = z.enum([
|
|
1890
|
+
"semantic-scholar",
|
|
1891
|
+
"pubmed",
|
|
1892
|
+
"arxiv",
|
|
1893
|
+
"google-scholar",
|
|
1894
|
+
"eric",
|
|
1895
|
+
"europe-pmc",
|
|
1896
|
+
"openalex",
|
|
1897
|
+
"crossref"
|
|
1898
|
+
], { message: "Invalid provider. Must be one of: semantic-scholar, pubmed, arxiv, google-scholar, eric, europe-pmc, openalex, crossref" });
|
|
1899
|
+
const grantProviderSchema = z.enum([
|
|
1900
|
+
"grants-gov",
|
|
1901
|
+
"nih-reporter",
|
|
1902
|
+
"cordis",
|
|
1903
|
+
"ukri"
|
|
1904
|
+
], { message: "Invalid provider. Must be one of: grants-gov, nih-reporter, cordis, ukri" });
|
|
1905
|
+
// ../util/lib/contract/instance/router/academic/fetch.ts
|
|
1906
|
+
const authorSchema$4 = z.object({
|
|
1907
|
+
name: z.string(),
|
|
1908
|
+
url: z.string().nullish()
|
|
1909
|
+
});
|
|
1910
|
+
const publicationSchema$3 = z.object({
|
|
1911
|
+
id: z.string().describe("Original input identifier"),
|
|
1912
|
+
detectedProvider: providerSchema.nullish().describe("Provider that returned this result"),
|
|
1913
|
+
doi: z.string().nullish(),
|
|
1914
|
+
title: z.string().nullish(),
|
|
1915
|
+
url: z.string().nullish(),
|
|
1916
|
+
providerURL: z.string().nullish(),
|
|
1917
|
+
authors: z.array(authorSchema$4).nullish(),
|
|
1918
|
+
date: z.string().nullish(),
|
|
1919
|
+
year: z.number().nullish(),
|
|
1920
|
+
totalCitations: z.number().nullish(),
|
|
1921
|
+
totalReferences: z.number().nullish(),
|
|
1922
|
+
abstract: z.string().nullish(),
|
|
1923
|
+
pdfURL: z.string().nullish(),
|
|
1924
|
+
provider: providerSchema.nullish(),
|
|
1925
|
+
providerData: z.record(z.string(), z.unknown()).nullish()
|
|
1926
|
+
});
|
|
1927
|
+
const fetchErrorSchema = z.object({
|
|
1928
|
+
id: z.string(),
|
|
1929
|
+
error: z.string(),
|
|
1930
|
+
code: z.string().nullish()
|
|
1931
|
+
});
|
|
1932
|
+
const requestExamples$21 = {
|
|
1933
|
+
"Fetch by DOI": {
|
|
1934
|
+
summary: "Fetch a paper by DOI",
|
|
1935
|
+
value: { ids: ["10.1038/nature12373"] }
|
|
1936
|
+
},
|
|
1937
|
+
"Fetch multiple IDs": {
|
|
1938
|
+
summary: "Fetch papers by mixed identifier types",
|
|
1939
|
+
value: { ids: [
|
|
1940
|
+
"10.1038/nature12373",
|
|
1941
|
+
"2301.08745",
|
|
1942
|
+
"33293753"
|
|
1943
|
+
] }
|
|
1944
|
+
},
|
|
1945
|
+
"Fetch ArXiv paper": {
|
|
1946
|
+
summary: "Fetch by ArXiv ID",
|
|
1947
|
+
value: { ids: ["2303.08774"] }
|
|
1948
|
+
}
|
|
1949
|
+
};
|
|
1950
|
+
const fetch = oc.input(z.object({
|
|
1951
|
+
ids: z.array(z.string({ message: "Each ID must be a string" }), { message: "ids is required and must be an array of strings" }).min(1, "ids must contain at least 1 identifier").max(100, "ids must contain at most 100 identifiers").describe("Publication identifiers to fetch. Supports DOI, PubMed ID, ArXiv ID, Semantic Scholar ID, ERIC ID, Europe PMC ID, OpenAlex ID."),
|
|
1952
|
+
fields: z.array(z.enum([
|
|
1953
|
+
"doi",
|
|
1954
|
+
"title",
|
|
1955
|
+
"url",
|
|
1956
|
+
"providerURL",
|
|
1957
|
+
"authors",
|
|
1958
|
+
"date",
|
|
1959
|
+
"year",
|
|
1960
|
+
"totalCitations",
|
|
1961
|
+
"totalReferences",
|
|
1962
|
+
"abstract",
|
|
1963
|
+
"pdfURL",
|
|
1964
|
+
"provider",
|
|
1965
|
+
"providerData"
|
|
1966
|
+
]), { message: "fields must be an array of valid publication field names" }).nullish().describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
1967
|
+
callback: z.object({
|
|
1968
|
+
url: z.url().describe("Webhook URL where results will be POSTed when processing completes"),
|
|
1969
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
1970
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
1971
|
+
})).output(z.object({
|
|
1972
|
+
results: z.array(publicationSchema$3),
|
|
1973
|
+
errors: z.array(fetchErrorSchema).nullish(),
|
|
1974
|
+
requestId: z.number().int()
|
|
1975
|
+
})).route({
|
|
1976
|
+
summary: "Fetch academic papers by ID",
|
|
1977
|
+
description: `Fetch specific academic publications by their unique identifiers with automatic provider detection and batch processing. Costs ${academicCreditCosts.academicFetch} credits per request.`,
|
|
1978
|
+
tags: ["Academic"],
|
|
1979
|
+
spec: (op) => {
|
|
1980
|
+
op.security = [{ bearerAuth: [] }];
|
|
1981
|
+
const reqBody = op.requestBody;
|
|
1982
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$21;
|
|
1983
|
+
op["x-codeSamples"] = getOpenApiCodeSamples("academic-fetch");
|
|
1984
|
+
return op;
|
|
1985
|
+
}
|
|
1986
|
+
});
|
|
1987
|
+
// ../util/lib/contract/instance/router/academic/find-citations.ts
|
|
1988
|
+
const authorSchema$3 = z.object({
|
|
1989
|
+
name: z.string(),
|
|
1990
|
+
url: z.string().nullish()
|
|
1991
|
+
});
|
|
1992
|
+
const scoredPublicationSchema = z.object({
|
|
1993
|
+
score: z.number().describe("Relevance score (0-10)"),
|
|
1994
|
+
doi: z.string().nullish(),
|
|
1995
|
+
title: z.string().nullish(),
|
|
1996
|
+
url: z.string().nullish(),
|
|
1997
|
+
providerURL: z.string().nullish(),
|
|
1998
|
+
authors: z.array(authorSchema$3).nullish(),
|
|
1999
|
+
date: z.string().nullish(),
|
|
2000
|
+
year: z.number().nullish(),
|
|
2001
|
+
totalCitations: z.number().nullish(),
|
|
2002
|
+
totalReferences: z.number().nullish(),
|
|
2003
|
+
abstract: z.string().nullish(),
|
|
2004
|
+
pdfURL: z.string().nullish(),
|
|
2005
|
+
provider: providerSchema.nullish(),
|
|
2006
|
+
providerData: z.record(z.string(), z.unknown()).nullish()
|
|
2007
|
+
});
|
|
2008
|
+
const sentenceCitationSchema = z.object({
|
|
2009
|
+
sentence: z.string(),
|
|
2010
|
+
citations: z.array(scoredPublicationSchema)
|
|
2011
|
+
});
|
|
2012
|
+
const requestExamples$20 = {
|
|
2013
|
+
"Find citations for a paragraph": {
|
|
2014
|
+
summary: "Find citations for a research paragraph",
|
|
2015
|
+
value: { paragraph: "Deep learning has revolutionized computer vision and natural language processing. Transformer architectures have become the dominant approach for sequence modeling tasks. Recent large language models demonstrate emergent capabilities not seen in smaller models." }
|
|
2016
|
+
},
|
|
2017
|
+
"Find citations with multiple providers": {
|
|
2018
|
+
summary: "Search across multiple databases",
|
|
2019
|
+
value: {
|
|
2020
|
+
paragraph: "CRISPR-Cas9 gene editing technology has transformed molecular biology. The ability to precisely modify DNA sequences has opened new avenues for treating genetic diseases.",
|
|
2021
|
+
providers: ["semantic-scholar", "pubmed"]
|
|
2022
|
+
}
|
|
2023
|
+
}
|
|
2024
|
+
};
|
|
2025
|
+
const findCitations = oc.input(z.object({
|
|
2026
|
+
paragraph: z.string({ message: "paragraph is required and must be a string" }).min(1, "paragraph must not be empty").max(5e3, "paragraph must be at most 5000 characters").describe("Text paragraph to find relevant academic citations for"),
|
|
2027
|
+
providers: z.array(providerSchema, { message: "providers must be an array of valid provider names" }).default(["semantic-scholar"]).describe("Academic databases to search for citations"),
|
|
2028
|
+
fields: z.array(z.enum([
|
|
2029
|
+
"doi",
|
|
2030
|
+
"title",
|
|
2031
|
+
"url",
|
|
2032
|
+
"providerURL",
|
|
2033
|
+
"authors",
|
|
2034
|
+
"date",
|
|
2035
|
+
"year",
|
|
2036
|
+
"totalCitations",
|
|
2037
|
+
"totalReferences",
|
|
2038
|
+
"abstract",
|
|
2039
|
+
"pdfURL",
|
|
2040
|
+
"provider",
|
|
2041
|
+
"providerData"
|
|
2042
|
+
]), { message: "fields must be an array of valid publication field names" }).nullish().describe("Specific citation fields to return. If omitted, returns all fields except providerData."),
|
|
2043
|
+
callback: z.object({
|
|
2044
|
+
url: z.url().describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2045
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2046
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
2047
|
+
})).output(z.object({
|
|
2048
|
+
results: z.array(sentenceCitationSchema),
|
|
2049
|
+
sentenceCount: z.number().int(),
|
|
2050
|
+
totalCitations: z.number().int(),
|
|
2051
|
+
errors: z.array(z.string()).nullish(),
|
|
2052
|
+
requestId: z.number().int()
|
|
2053
|
+
})).route({
|
|
2054
|
+
summary: "Find citations for a paragraph",
|
|
2055
|
+
description: `Find relevant academic citations for a paragraph by splitting it into sentences and scoring papers using semantic embedding similarity. Costs ${academicCreditCosts.academicFindCitationsPerSentence} credits per sentence.`,
|
|
2056
|
+
tags: ["Academic"],
|
|
2057
|
+
spec: (op) => {
|
|
2058
|
+
op.security = [{ bearerAuth: [] }];
|
|
2059
|
+
const reqBody = op.requestBody;
|
|
2060
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$20;
|
|
2061
|
+
op["x-codeSamples"] = getOpenApiCodeSamples("academic-find-citations");
|
|
2062
|
+
return op;
|
|
2063
|
+
}
|
|
2064
|
+
});
|
|
2065
|
+
// ../util/lib/contract/instance/router/academic/paper-graph.ts
|
|
2066
|
+
const authorSchema$2 = z.object({
|
|
2067
|
+
name: z.string(),
|
|
2068
|
+
url: z.string().nullish()
|
|
2069
|
+
});
|
|
2070
|
+
const publicationSchema$2 = z.object({
|
|
2071
|
+
doi: z.string().nullish(),
|
|
2072
|
+
title: z.string().nullish(),
|
|
2073
|
+
url: z.string().nullish(),
|
|
2074
|
+
providerURL: z.string().nullish(),
|
|
2075
|
+
authors: z.array(authorSchema$2).nullish(),
|
|
2076
|
+
date: z.string().nullish(),
|
|
2077
|
+
year: z.number().nullish(),
|
|
2078
|
+
totalCitations: z.number().nullish(),
|
|
2079
|
+
totalReferences: z.number().nullish(),
|
|
2080
|
+
abstract: z.string().nullish(),
|
|
2081
|
+
pdfURL: z.string().nullish(),
|
|
2082
|
+
provider: providerSchema.nullish(),
|
|
2083
|
+
providerData: z.record(z.string(), z.unknown()).nullish()
|
|
2084
|
+
});
|
|
2085
|
+
const requestExamples$19 = {
|
|
2086
|
+
"Get citations by DOI": {
|
|
2087
|
+
summary: "Get citations and references for a paper by DOI",
|
|
2088
|
+
value: {
|
|
2089
|
+
id: "10.1038/nature12373",
|
|
2090
|
+
citationsLimit: 20,
|
|
2091
|
+
referencesLimit: 20
|
|
2092
|
+
}
|
|
2093
|
+
},
|
|
2094
|
+
"Get citations by ArXiv ID": {
|
|
2095
|
+
summary: "Get citations and references for an ArXiv paper",
|
|
2096
|
+
value: {
|
|
2097
|
+
id: "2303.08774",
|
|
2098
|
+
citationsLimit: 50,
|
|
2099
|
+
referencesLimit: 50
|
|
2100
|
+
}
|
|
2101
|
+
},
|
|
2102
|
+
"Paginated citations": {
|
|
2103
|
+
summary: "Page through a paper's citations",
|
|
2104
|
+
value: {
|
|
2105
|
+
id: "10.1038/nature12373",
|
|
2106
|
+
citationsLimit: 20,
|
|
2107
|
+
citationsOffset: 20,
|
|
2108
|
+
referencesLimit: 0
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2111
|
+
};
|
|
2112
|
+
const paperGraph = oc.input(z.object({
|
|
2113
|
+
id: z.string({ message: "id is required and must be a string" }).min(1, "id must not be empty").max(500, "id must be at most 500 characters").describe("Paper identifier. Supports DOI, Semantic Scholar ID, ArXiv ID, PubMed ID, OpenAlex ID, or URL."),
|
|
2114
|
+
citationsLimit: z.number({ message: "citationsLimit must be a number" }).int("citationsLimit must be a whole number").min(0, "citationsLimit must be 0 or greater").max(1e3, "citationsLimit must be at most 1000").default(100).describe("Maximum number of citing papers to return"),
|
|
2115
|
+
referencesLimit: z.number({ message: "referencesLimit must be a number" }).int("referencesLimit must be a whole number").min(0, "referencesLimit must be 0 or greater").max(1e3, "referencesLimit must be at most 1000").default(100).describe("Maximum number of referenced papers to return"),
|
|
2116
|
+
citationsOffset: z.number({ message: "citationsOffset must be a number" }).int("citationsOffset must be a whole number").min(0, "citationsOffset must be 0 or greater").default(0).describe("Pagination offset for citations"),
|
|
2117
|
+
referencesOffset: z.number({ message: "referencesOffset must be a number" }).int("referencesOffset must be a whole number").min(0, "referencesOffset must be 0 or greater").default(0).describe("Pagination offset for references"),
|
|
2118
|
+
fields: z.array(z.enum([
|
|
2119
|
+
"doi",
|
|
2120
|
+
"title",
|
|
2121
|
+
"url",
|
|
2122
|
+
"providerURL",
|
|
2123
|
+
"authors",
|
|
2124
|
+
"date",
|
|
2125
|
+
"year",
|
|
2126
|
+
"totalCitations",
|
|
2127
|
+
"totalReferences",
|
|
2128
|
+
"abstract",
|
|
2129
|
+
"pdfURL",
|
|
2130
|
+
"provider",
|
|
2131
|
+
"providerData"
|
|
2132
|
+
]), { message: "fields must be an array of valid publication field names" }).nullish().describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
2133
|
+
callback: z.object({
|
|
2134
|
+
url: z.url().describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2135
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2136
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
2137
|
+
})).output(z.object({
|
|
2138
|
+
paper: publicationSchema$2,
|
|
2139
|
+
citations: z.array(publicationSchema$2),
|
|
2140
|
+
references: z.array(publicationSchema$2),
|
|
2141
|
+
totalCitations: z.number().int().nullish(),
|
|
2142
|
+
totalReferences: z.number().int().nullish(),
|
|
2143
|
+
requestId: z.number().int()
|
|
2144
|
+
})).route({
|
|
2145
|
+
summary: "Get paper citations and references",
|
|
2146
|
+
description: `Fetch a paper's citing papers and referenced papers as full publication objects with automatic provider detection and pagination support. Costs ${academicCreditCosts.academicPaperGraphMin}+ credits per request (scales with result count).`,
|
|
2147
|
+
tags: ["Academic"],
|
|
2148
|
+
spec: (op) => {
|
|
2149
|
+
op.security = [{ bearerAuth: [] }];
|
|
2150
|
+
const reqBody = op.requestBody;
|
|
2151
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$19;
|
|
2152
|
+
op["x-codeSamples"] = getOpenApiCodeSamples("academic-paper-graph");
|
|
2153
|
+
return op;
|
|
2154
|
+
}
|
|
2155
|
+
});
|
|
2156
|
+
// ../util/lib/contract/instance/fetchable-url-schema.ts
|
|
2157
|
+
const fetchableUrlSchema = z.url({
|
|
2158
|
+
protocol: /^https?$/,
|
|
2159
|
+
error: "URL must use http or https"
|
|
2160
|
+
});
|
|
2161
|
+
// ../util/lib/contract/instance/page-markdown-schema.ts
|
|
2162
|
+
const pageMarkdownSchema = z.object({
|
|
2163
|
+
pageNumber: z.number().int().min(1).describe("1-based page number in the source document"),
|
|
2164
|
+
markdown: z.string().describe("Extracted markdown content for this page")
|
|
2165
|
+
});
|
|
2166
|
+
// ../util/lib/contract/instance/pdfvector-model-schema.ts
|
|
2167
|
+
const pdfvectorModelSchema = z.enum([
|
|
2168
|
+
"nano",
|
|
2169
|
+
"mini",
|
|
2170
|
+
"pro",
|
|
2171
|
+
"max"
|
|
2172
|
+
], { message: "model must be one of: nano, mini, pro, max" });
|
|
2173
|
+
// ../util/lib/contract/instance/supported-mimes.ts
|
|
2174
|
+
/**
|
|
2175
|
+
* All MIME types accepted for file uploads across all API endpoints.
|
|
2176
|
+
* Single source of truth — imported by all contract schemas.
|
|
2177
|
+
*/
|
|
2178
|
+
const supportedFileMimes = [
|
|
2179
|
+
"application/pdf",
|
|
2180
|
+
"application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
2181
|
+
"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
2182
|
+
"application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
2183
|
+
"text/csv",
|
|
2184
|
+
"application/csv",
|
|
2185
|
+
"image/png",
|
|
2186
|
+
"image/jpeg",
|
|
2187
|
+
"image/tiff",
|
|
2188
|
+
"image/bmp",
|
|
2189
|
+
"image/heif",
|
|
2190
|
+
"image/heic",
|
|
2191
|
+
"text/plain",
|
|
2192
|
+
"text/markdown",
|
|
2193
|
+
"text/tab-separated-values",
|
|
2194
|
+
"text/xml",
|
|
2195
|
+
"application/xml",
|
|
2196
|
+
"application/rtf",
|
|
2197
|
+
"text/rtf",
|
|
2198
|
+
"text/html",
|
|
2199
|
+
"application/epub+zip",
|
|
2200
|
+
"application/vnd.oasis.opendocument.text",
|
|
2201
|
+
"application/vnd.oasis.opendocument.spreadsheet",
|
|
2202
|
+
"application/vnd.oasis.opendocument.presentation",
|
|
2203
|
+
"application/x-bibtex"
|
|
2204
|
+
];
|
|
2205
|
+
const supportedFileFormatsDescription = allSupportedFormatsShort;
|
|
2206
|
+
/**
|
|
2207
|
+
* Friendly validation error when an uploaded file's MIME type is not supported.
|
|
2208
|
+
* Lists the human-readable extensions instead of raw MIME types.
|
|
2209
|
+
*/
|
|
2210
|
+
const supportedFileMimeErrorMessage = `file must be a supported format: ${allSupportedFormatsShort}`;
|
|
2211
|
+
/**
|
|
2212
|
+
* Human-readable description of supported file types with extensions.
|
|
2213
|
+
* Used in route-level API descriptions.
|
|
2214
|
+
*/
|
|
2215
|
+
const supportedFileTypesLong = allSupportedFormatsLong;
|
|
2216
|
+
const formatNote = `\n\n${formatsByTierDescription}`;
|
|
2217
|
+
function fmtSize(bytes) {
|
|
2218
|
+
return `${bytes / 1048576}MB`;
|
|
2219
|
+
}
|
|
2220
|
+
function tierDesc(tier, credits, unit, extra) {
|
|
2221
|
+
const limit = tierLimits[tier];
|
|
2222
|
+
const limitStr = limit ? `Up to ${limit.maxPages} pages, ${fmtSize(limit.maxFileSize)}.` : "";
|
|
2223
|
+
return `- ${tier}: ${credits} ${unit}. ${extra}${limitStr ? ` ${limitStr}` : ""}`;
|
|
2224
|
+
}
|
|
2225
|
+
const autoLimit = tierLimits["auto"];
|
|
2226
|
+
if (!autoLimit) throw new Error("Missing auto tier limits");
|
|
2227
|
+
/** Model tier descriptions for document parse endpoints. */
|
|
2228
|
+
const documentParseModelDescription = `Model tier for parsing.
|
|
2229
|
+
|
|
2230
|
+
- auto (default): Intelligent fallback — credits based on the tier selected automatically. ${`Up to ${autoLimit.maxPages} pages, ${fmtSize(autoLimit.maxFileSize)}.`}\n${tierDesc("nano", documentParseCosts.nano, "credit/page", "Simple plain text documents.")}\n${tierDesc("mini", documentParseCosts.mini, "credits/page", "Documents with tables and structured content.")}\n${tierDesc("pro", documentParseCosts.pro, "credits/page", "Tables, handwritten text, figures, math, Arabic, image support.")}\n${tierDesc("max", documentParseCosts.max, "credits/page", "Full Pro capabilities + enhanced multilingual.")}` + formatNote;
|
|
2231
|
+
/** Model tier descriptions for document extract endpoints. */
|
|
2232
|
+
const documentExtractModelDescription = `Model tier for extracting structured data.
|
|
2233
|
+
|
|
2234
|
+
- auto (default): Automatically selects the best tier — credits based on the tier selected.
|
|
2235
|
+
- nano: ${documentAskExtractCosts.nano} credits/page. Fastest. Best for simple documents with straightforward schemas.\n- mini: ${documentAskExtractCosts.mini} credits/page. Balanced speed and accuracy. Moderately complex schemas.\n- pro: ${documentAskExtractCosts.pro} credits/page. High accuracy for complex documents with large or nested schemas.\n- max: ${documentAskExtractCosts.max} credits/page. Maximum accuracy. Best for difficult extractions requiring deep reasoning.` + formatNote;
|
|
2236
|
+
/** Model tier descriptions for document ask endpoints. */
|
|
2237
|
+
const documentAskModelDescription = `Model tier for answering the question.
|
|
2238
|
+
|
|
2239
|
+
- auto (default): Automatically selects the best tier — credits based on the tier selected.
|
|
2240
|
+
- nano: ${documentAskExtractCosts.nano} credits/page. Fastest. Best for simple questions about straightforward documents.\n- mini: ${documentAskExtractCosts.mini} credits/page. Balanced speed and accuracy. Moderately complex questions.\n- pro: ${documentAskExtractCosts.pro} credits/page. High accuracy for nuanced questions about complex documents.\n- max: ${documentAskExtractCosts.max} credits/page. Maximum accuracy. Best for difficult questions requiring deep reasoning.` + formatNote;
|
|
2241
|
+
/** Model tier descriptions for invoice/identity/bankStatement parse endpoints (pro/max/auto only). */
|
|
2242
|
+
const specializedParseModelDescription = (type) => `Model tier for parsing.
|
|
2243
|
+
|
|
2244
|
+
- auto (default): Intelligent fallback — credits based on the tier selected.
|
|
2245
|
+
- pro: ${specializedParseCosts.pro} credits/page. Extracts structured ${type} fields with standard accuracy.\n- max: ${specializedParseCosts.max} credits/page. Extracts structured ${type} fields with highest accuracy and fallback.`;
|
|
2246
|
+
/** Model tier descriptions for invoice/identity/bankStatement extract endpoints. */
|
|
2247
|
+
const specializedExtractModelDescription = `Model tier for extracting structured data.
|
|
2248
|
+
|
|
2249
|
+
- auto (default): Automatically selects the best tier — credits based on the tier selected.
|
|
2250
|
+
- nano: ${specializedAskExtractCosts.nano} credits/page. Fastest. Best for simple documents with straightforward schemas.\n- mini: ${specializedAskExtractCosts.mini} credits/page. Balanced speed and accuracy. Moderately complex schemas.\n- pro: ${specializedAskExtractCosts.pro} credits/page. High accuracy for complex documents with large or nested schemas.\n- max: ${specializedAskExtractCosts.max} credits/page. Maximum accuracy. Best for difficult extractions requiring deep reasoning.` + formatNote;
|
|
2251
|
+
/** Model tier descriptions for invoice/identity/bankStatement ask endpoints. */
|
|
2252
|
+
const specializedAskModelDescription = `Model tier for answering the question.
|
|
2253
|
+
|
|
2254
|
+
- auto (default): Automatically selects the best tier — credits based on the tier selected.
|
|
2255
|
+
- nano: ${specializedAskExtractCosts.nano} credits/page. Fastest. Best for simple questions about straightforward documents.\n- mini: ${specializedAskExtractCosts.mini} credits/page. Balanced speed and accuracy. Moderately complex questions.\n- pro: ${specializedAskExtractCosts.pro} credits/page. High accuracy for nuanced questions about complex documents.\n- max: ${specializedAskExtractCosts.max} credits/page. Maximum accuracy. Best for difficult questions requiring deep reasoning.` + formatNote;
|
|
2256
|
+
/** Output model description for parse results. */
|
|
2257
|
+
const outputModelDescription = "Model tier used to parse the document.\n\n- nano: Fastest, best for simple documents.\n- mini: Balanced speed and accuracy.\n- pro: High accuracy for complex documents.\n- max: Maximum accuracy with deep reasoning.";
|
|
2258
|
+
/** Output model description for extract results. */
|
|
2259
|
+
const outputExtractModelDescription = "Model tier used to extract the data.\n\n- nano: Fastest, best for simple documents.\n- mini: Balanced speed and accuracy.\n- pro: High accuracy for complex documents.\n- max: Maximum accuracy with deep reasoning.";
|
|
2260
|
+
/** Output model description for ask results. */
|
|
2261
|
+
const outputAskModelDescription = "Model tier used to answer the question.\n\n- nano: Fastest, best for simple questions.\n- mini: Balanced speed and accuracy.\n- pro: High accuracy for complex questions.\n- max: Maximum accuracy with deep reasoning.";
|
|
2262
|
+
// ../util/lib/contract/instance/router/academic/parse.ts
|
|
2263
|
+
const callbackSchema = z.object({
|
|
2264
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2265
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2266
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.");
|
|
2267
|
+
const parseInputSchema$4 = z.object({
|
|
2268
|
+
id: z.string({ message: "id must be a string" }).trim().min(1, "id must be a non-empty string").optional().describe("Publication identifier to resolve and parse. Supports DOI, PubMed ID, ArXiv ID, Semantic Scholar ID, ERIC ID, Europe PMC ID, OpenAlex ID."),
|
|
2269
|
+
url: fetchableUrlSchema.optional().describe("Publication URL to resolve and parse. Supports known provider URLs such as DOI, ArXiv, PubMed, Semantic Scholar, ERIC, Europe PMC, OpenAlex, Springer, Nature, bioRxiv, and medRxiv."),
|
|
2270
|
+
model: z.enum(["auto", ...pdfvectorModelSchema.options]).optional().default("auto").describe(documentParseModelDescription),
|
|
2271
|
+
includePages: z.boolean().optional().default(false).describe("Set to true to include page-separated markdown in the pages array. Existing markdown output is still returned as the full paper text."),
|
|
2272
|
+
callback: callbackSchema
|
|
2273
|
+
}).superRefine((input, ctx) => {
|
|
2274
|
+
if ((typeof input.id === "string" && input.id.length > 0) === (typeof input.url === "string" && input.url.length > 0)) ctx.addIssue({
|
|
2275
|
+
code: "custom",
|
|
2276
|
+
path: ["id"],
|
|
2277
|
+
message: "Provide exactly one of id or url"
|
|
2278
|
+
});
|
|
2279
|
+
});
|
|
2280
|
+
const parseOutputSchema$4 = z.object({
|
|
2281
|
+
id: z.string().describe("Original input identifier or URL"),
|
|
2282
|
+
title: z.string().nullish().describe("Publication title, if available"),
|
|
2283
|
+
doi: z.string().nullish().describe("Publication DOI, if available"),
|
|
2284
|
+
url: z.string().nullish().describe("PDF Vector publication URL, if available"),
|
|
2285
|
+
providerURL: z.string().nullish().describe("Provider publication page URL, if available"),
|
|
2286
|
+
pdfURL: z.string().describe("Resolved public PDF URL used for parsing"),
|
|
2287
|
+
detectedProvider: providerSchema.nullish().describe("Provider detected from the input identifier or URL"),
|
|
2288
|
+
markdown: z.string().describe("Extracted markdown content from the paper PDF"),
|
|
2289
|
+
pageCount: z.number().int().describe("Total number of pages in the paper PDF"),
|
|
2290
|
+
model: pdfvectorModelSchema.describe(outputModelDescription),
|
|
2291
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=1, mini=2, pro=4, max=8."),
|
|
2292
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
2293
|
+
html: z.string().optional().describe("Full HTML representation of the paper content. Only available when using the 'max' model."),
|
|
2294
|
+
pages: z.array(pageMarkdownSchema).optional().describe("Page-separated markdown content. Returned only when includePages is true.")
|
|
2295
|
+
});
|
|
2296
|
+
const requestExamples$18 = {
|
|
2297
|
+
"Parse ArXiv paper by ID": {
|
|
2298
|
+
summary: "Parse ArXiv paper by ID",
|
|
2299
|
+
value: {
|
|
2300
|
+
id: "1706.03762",
|
|
2301
|
+
model: "auto"
|
|
2302
|
+
}
|
|
2303
|
+
},
|
|
2304
|
+
"Parse paper by DOI URL": {
|
|
2305
|
+
summary: "Parse paper by DOI URL",
|
|
2306
|
+
value: {
|
|
2307
|
+
url: "https://doi.org/10.1038/nature12373",
|
|
2308
|
+
model: "pro"
|
|
2309
|
+
}
|
|
2310
|
+
},
|
|
2311
|
+
"Parse PubMed paper by ID": {
|
|
2312
|
+
summary: "Parse PubMed paper by ID",
|
|
2313
|
+
value: {
|
|
2314
|
+
id: "33116299",
|
|
2315
|
+
model: "auto"
|
|
2316
|
+
}
|
|
2317
|
+
},
|
|
2318
|
+
"Parse paper with page-separated output": {
|
|
2319
|
+
summary: "Parse paper with page-separated output",
|
|
2320
|
+
value: {
|
|
2321
|
+
id: "1706.03762",
|
|
2322
|
+
model: "auto",
|
|
2323
|
+
includePages: true
|
|
2324
|
+
}
|
|
2325
|
+
}
|
|
2326
|
+
};
|
|
2327
|
+
const parse$4 = oc.input(parseInputSchema$4).output(parseOutputSchema$4).route({
|
|
2328
|
+
summary: "Parse an academic paper to markdown",
|
|
2329
|
+
description: "Resolve an academic paper URL or identifier to a public PDF URL, parse the PDF, and return markdown using the same model tiers as document.parse. Returns NOT_FOUND when the paper cannot be found or no public PDF is available.",
|
|
2330
|
+
tags: ["Academic"],
|
|
2331
|
+
spec: (op) => {
|
|
2332
|
+
op.security = [{ bearerAuth: [] }];
|
|
2333
|
+
const reqBody = op.requestBody;
|
|
2334
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$18;
|
|
2335
|
+
op["x-codeSamples"] = academicParseOpenApiCodeSamples;
|
|
2336
|
+
return op;
|
|
2337
|
+
}
|
|
2338
|
+
});
|
|
2339
|
+
// ../util/lib/contract/instance/router/academic/search.ts
|
|
2340
|
+
const authorSchema$1 = z.object({
|
|
2341
|
+
name: z.string(),
|
|
2342
|
+
url: z.string().nullish()
|
|
2343
|
+
});
|
|
2344
|
+
const publicationSchema$1 = z.object({
|
|
2345
|
+
doi: z.string().nullish(),
|
|
2346
|
+
title: z.string().nullish(),
|
|
2347
|
+
url: z.string().nullish(),
|
|
2348
|
+
providerURL: z.string().nullish(),
|
|
2349
|
+
authors: z.array(authorSchema$1).nullish(),
|
|
2350
|
+
date: z.string().nullish(),
|
|
2351
|
+
year: z.number().nullish(),
|
|
2352
|
+
totalCitations: z.number().nullish(),
|
|
2353
|
+
totalReferences: z.number().nullish(),
|
|
2354
|
+
abstract: z.string().nullish(),
|
|
2355
|
+
pdfURL: z.string().nullish(),
|
|
2356
|
+
provider: providerSchema.nullish(),
|
|
2357
|
+
providerData: z.record(z.string(), z.unknown()).nullish()
|
|
2358
|
+
});
|
|
2359
|
+
const providerErrorSchema$1 = z.object({
|
|
2360
|
+
provider: providerSchema,
|
|
2361
|
+
message: z.string(),
|
|
2362
|
+
code: z.string().nullish(),
|
|
2363
|
+
details: z.record(z.string(), z.unknown()).nullish()
|
|
2364
|
+
});
|
|
2365
|
+
const requestExamples$17 = {
|
|
2366
|
+
"Search with default provider": {
|
|
2367
|
+
summary: "Search with Semantic Scholar",
|
|
2368
|
+
value: { query: "deep learning for natural language processing" }
|
|
2369
|
+
},
|
|
2370
|
+
"Search multiple providers": {
|
|
2371
|
+
summary: "Search across multiple databases",
|
|
2372
|
+
value: {
|
|
2373
|
+
query: "CRISPR gene editing",
|
|
2374
|
+
providers: [
|
|
2375
|
+
"semantic-scholar",
|
|
2376
|
+
"pubmed",
|
|
2377
|
+
"openalex"
|
|
2378
|
+
],
|
|
2379
|
+
limit: 10
|
|
2380
|
+
}
|
|
2381
|
+
},
|
|
2382
|
+
"Search with year filter": {
|
|
2383
|
+
summary: "Search recent papers",
|
|
2384
|
+
value: {
|
|
2385
|
+
query: "large language models",
|
|
2386
|
+
providers: ["semantic-scholar"],
|
|
2387
|
+
yearFrom: 2023,
|
|
2388
|
+
yearTo: 2026,
|
|
2389
|
+
limit: 20
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
};
|
|
2393
|
+
const search = oc.input(z.object({
|
|
2394
|
+
query: z.string({ message: "query is required and must be a string" }).min(1, "query must not be empty").max(400, "query must be at most 400 characters").describe("Search query string for academic papers"),
|
|
2395
|
+
providers: z.array(providerSchema, { message: "providers must be an array of valid provider names" }).default(["semantic-scholar"]).describe("Academic databases to search"),
|
|
2396
|
+
offset: z.number({ message: "offset must be a number" }).int("offset must be a whole number").min(0, "offset must be 0 or greater").default(0).describe("Results offset"),
|
|
2397
|
+
limit: z.number({ message: "limit must be a number" }).int("limit must be a whole number").min(1, "limit must be at least 1").max(100, "limit must be at most 100").default(20).describe("Results per provider"),
|
|
2398
|
+
yearFrom: z.number({ message: "yearFrom must be a number" }).int("yearFrom must be a whole number").min(1900, "yearFrom must be 1900 or later").max(2100, "yearFrom must be 2100 or earlier").nullish().describe("Filter papers published from this year"),
|
|
2399
|
+
yearTo: z.number({ message: "yearTo must be a number" }).int("yearTo must be a whole number").min(1900, "yearTo must be 1900 or later").max(2100, "yearTo must be 2100 or earlier").nullish().describe("Filter papers published up to this year"),
|
|
2400
|
+
fields: z.array(z.enum([
|
|
2401
|
+
"doi",
|
|
2402
|
+
"title",
|
|
2403
|
+
"url",
|
|
2404
|
+
"providerURL",
|
|
2405
|
+
"authors",
|
|
2406
|
+
"date",
|
|
2407
|
+
"year",
|
|
2408
|
+
"totalCitations",
|
|
2409
|
+
"totalReferences",
|
|
2410
|
+
"abstract",
|
|
2411
|
+
"pdfURL",
|
|
2412
|
+
"provider",
|
|
2413
|
+
"providerData"
|
|
2414
|
+
]), { message: "fields must be an array of valid publication field names" }).nullish().describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
2415
|
+
callback: z.object({
|
|
2416
|
+
url: z.url().describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2417
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2418
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
2419
|
+
})).output(z.object({
|
|
2420
|
+
estimatedTotalResults: z.number(),
|
|
2421
|
+
results: z.array(publicationSchema$1),
|
|
2422
|
+
errors: z.array(providerErrorSchema$1).nullish(),
|
|
2423
|
+
requestId: z.number().int()
|
|
2424
|
+
})).route({
|
|
2425
|
+
summary: "Search academic papers",
|
|
2426
|
+
description: `Search for academic publications across multiple databases with relevance ranking. Costs ${academicCreditCosts.academicSearch} credits per request.`,
|
|
2427
|
+
tags: ["Academic"],
|
|
2428
|
+
spec: (op) => {
|
|
2429
|
+
op.security = [{ bearerAuth: [] }];
|
|
2430
|
+
const reqBody = op.requestBody;
|
|
2431
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$17;
|
|
2432
|
+
op["x-codeSamples"] = getOpenApiCodeSamples("academic-search");
|
|
2433
|
+
return op;
|
|
2434
|
+
}
|
|
2435
|
+
});
|
|
2436
|
+
// ../util/lib/contract/instance/router/academic/search-grants.ts
|
|
2437
|
+
const grantSchema = z.object({
|
|
2438
|
+
sourceId: z.string().nullish(),
|
|
2439
|
+
title: z.string().nullish(),
|
|
2440
|
+
url: z.string().nullish(),
|
|
2441
|
+
agency: z.string().nullish(),
|
|
2442
|
+
program: z.string().nullish(),
|
|
2443
|
+
description: z.string().nullish(),
|
|
2444
|
+
eligibility: z.string().nullish(),
|
|
2445
|
+
fundingAmountMin: z.number().nullish(),
|
|
2446
|
+
fundingAmountMax: z.number().nullish(),
|
|
2447
|
+
currency: z.string().nullish(),
|
|
2448
|
+
deadlineDate: z.string().nullish(),
|
|
2449
|
+
openDate: z.string().nullish(),
|
|
2450
|
+
closeDate: z.string().nullish(),
|
|
2451
|
+
grantType: z.string().nullish(),
|
|
2452
|
+
region: z.string().nullish(),
|
|
2453
|
+
keywords: z.array(z.string()).nullish(),
|
|
2454
|
+
piName: z.string().nullish(),
|
|
2455
|
+
organizationName: z.string().nullish(),
|
|
2456
|
+
provider: grantProviderSchema.nullish(),
|
|
2457
|
+
providerData: z.record(z.string(), z.unknown()).nullish()
|
|
2458
|
+
});
|
|
2459
|
+
const providerErrorSchema = z.object({
|
|
2460
|
+
provider: grantProviderSchema,
|
|
2461
|
+
message: z.string(),
|
|
2462
|
+
code: z.string().nullish(),
|
|
2463
|
+
details: z.record(z.string(), z.unknown()).nullish()
|
|
2464
|
+
});
|
|
2465
|
+
const requestExamples$16 = {
|
|
2466
|
+
"Search all providers": {
|
|
2467
|
+
summary: "Search grants across all funding databases",
|
|
2468
|
+
value: { query: "machine learning healthcare" }
|
|
2469
|
+
},
|
|
2470
|
+
"Search with filters": {
|
|
2471
|
+
summary: "Search with funding and deadline filters",
|
|
2472
|
+
value: {
|
|
2473
|
+
query: "climate change research",
|
|
2474
|
+
providers: ["grants-gov", "cordis"],
|
|
2475
|
+
fundingMin: 5e4,
|
|
2476
|
+
fundingMax: 5e5,
|
|
2477
|
+
deadlineFrom: "2026-01-01",
|
|
2478
|
+
deadlineTo: "2026-12-31",
|
|
2479
|
+
limit: 20
|
|
2480
|
+
}
|
|
2481
|
+
},
|
|
2482
|
+
"Search specific provider": {
|
|
2483
|
+
summary: "Search NIH grants only",
|
|
2484
|
+
value: {
|
|
2485
|
+
query: "CRISPR gene therapy",
|
|
2486
|
+
providers: ["nih-reporter"],
|
|
2487
|
+
limit: 10
|
|
2488
|
+
}
|
|
2489
|
+
}
|
|
2490
|
+
};
|
|
2491
|
+
const searchGrants = oc.input(z.object({
|
|
2492
|
+
query: z.string({ message: "query is required and must be a string" }).min(1, "query must not be empty").max(400, "query must be at most 400 characters").describe("Search query string for grants"),
|
|
2493
|
+
providers: z.array(grantProviderSchema, { message: "providers must be an array of valid grant provider names" }).default([
|
|
2494
|
+
"grants-gov",
|
|
2495
|
+
"nih-reporter",
|
|
2496
|
+
"cordis",
|
|
2497
|
+
"ukri"
|
|
2498
|
+
]).describe("Grant databases to search. Defaults to all providers."),
|
|
2499
|
+
offset: z.number({ message: "offset must be a number" }).int("offset must be a whole number").min(0, "offset must be 0 or greater").default(0).describe("Results offset for pagination"),
|
|
2500
|
+
limit: z.number({ message: "limit must be a number" }).int("limit must be a whole number").min(1, "limit must be at least 1").max(50, "limit must be at most 50").default(10).describe("Maximum results per provider"),
|
|
2501
|
+
deadlineFrom: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "deadlineFrom must be in ISO date format (YYYY-MM-DD)").nullish().describe("Filter grants with deadlines from this date (ISO format, e.g. 2026-01-01)"),
|
|
2502
|
+
deadlineTo: z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "deadlineTo must be in ISO date format (YYYY-MM-DD)").nullish().describe("Filter grants with deadlines up to this date (ISO format, e.g. 2026-12-31)"),
|
|
2503
|
+
fundingMin: z.number({ message: "fundingMin must be a number" }).min(0, "fundingMin must be 0 or greater").nullish().describe("Minimum funding amount filter"),
|
|
2504
|
+
fundingMax: z.number({ message: "fundingMax must be a number" }).min(0, "fundingMax must be 0 or greater").nullish().describe("Maximum funding amount filter"),
|
|
2505
|
+
fields: z.array(z.enum([
|
|
2506
|
+
"sourceId",
|
|
2507
|
+
"title",
|
|
2508
|
+
"url",
|
|
2509
|
+
"agency",
|
|
2510
|
+
"program",
|
|
2511
|
+
"description",
|
|
2512
|
+
"eligibility",
|
|
2513
|
+
"fundingAmountMin",
|
|
2514
|
+
"fundingAmountMax",
|
|
2515
|
+
"currency",
|
|
2516
|
+
"deadlineDate",
|
|
2517
|
+
"openDate",
|
|
2518
|
+
"closeDate",
|
|
2519
|
+
"grantType",
|
|
2520
|
+
"region",
|
|
2521
|
+
"keywords",
|
|
2522
|
+
"piName",
|
|
2523
|
+
"organizationName",
|
|
2524
|
+
"provider",
|
|
2525
|
+
"providerData"
|
|
2526
|
+
]), { message: "fields must be an array of valid grant field names" }).nullish().describe("Specific grant fields to return. If omitted, returns all fields except providerData."),
|
|
2527
|
+
callback: z.object({
|
|
2528
|
+
url: z.url().describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2529
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2530
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body.")
|
|
2531
|
+
})).output(z.object({
|
|
2532
|
+
estimatedTotalResults: z.number(),
|
|
2533
|
+
results: z.array(grantSchema),
|
|
2534
|
+
errors: z.array(providerErrorSchema).nullish(),
|
|
2535
|
+
requestId: z.number().int()
|
|
2536
|
+
})).route({
|
|
2537
|
+
summary: "Search grants",
|
|
2538
|
+
description: `Search for research grants and funding opportunities across multiple databases (Grants.gov, NIH RePORTER, CORDIS, UKRI) with unified results, relevance ranking, and filtering by deadline and funding amount. Costs ${academicCreditCosts.grantSearch} credits per request.`,
|
|
2539
|
+
tags: ["Academic"],
|
|
2540
|
+
spec: (op) => {
|
|
2541
|
+
op.security = [{ bearerAuth: [] }];
|
|
2542
|
+
const reqBody = op.requestBody;
|
|
2543
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$16;
|
|
2544
|
+
op["x-codeSamples"] = getOpenApiCodeSamples("academic-search-grants");
|
|
2545
|
+
return op;
|
|
2546
|
+
}
|
|
2547
|
+
});
|
|
2548
|
+
// ../util/lib/contract/instance/router/academic/similar-papers.ts
|
|
2549
|
+
const authorSchema = z.object({
|
|
2550
|
+
name: z.string(),
|
|
2551
|
+
url: z.string().nullish()
|
|
2552
|
+
});
|
|
2553
|
+
const publicationSchema = z.object({
|
|
2554
|
+
doi: z.string().nullish(),
|
|
2555
|
+
title: z.string().nullish(),
|
|
2556
|
+
url: z.string().nullish(),
|
|
2557
|
+
providerURL: z.string().nullish(),
|
|
2558
|
+
authors: z.array(authorSchema).nullish(),
|
|
2559
|
+
date: z.string().nullish(),
|
|
2560
|
+
year: z.number().nullish(),
|
|
2561
|
+
totalCitations: z.number().nullish(),
|
|
2562
|
+
totalReferences: z.number().nullish(),
|
|
2563
|
+
abstract: z.string().nullish(),
|
|
2564
|
+
pdfURL: z.string().nullish(),
|
|
2565
|
+
provider: providerSchema.nullish(),
|
|
2566
|
+
providerData: z.record(z.string(), z.unknown()).nullish()
|
|
2567
|
+
});
|
|
2568
|
+
const similarPaperSchema = z.object({
|
|
2569
|
+
publication: publicationSchema,
|
|
2570
|
+
similarity: z.number().describe("Combined similarity score from citation network analysis"),
|
|
2571
|
+
pageRank: z.number().nullish().describe("Citation network importance score"),
|
|
2572
|
+
distance: z.number().int().nullish().describe("Graph distance from seed paper"),
|
|
2573
|
+
citingIds: z.array(z.string()).nullish().describe("OpenAlex IDs of papers in result set that cite this paper (only if includeEdges=true)"),
|
|
2574
|
+
citedByIds: z.array(z.string()).nullish().describe("OpenAlex IDs of papers in result set cited by this paper (only if includeEdges=true)")
|
|
2575
|
+
});
|
|
2576
|
+
const requestExamples$15 = {
|
|
2577
|
+
"Find similar papers by DOI": {
|
|
2578
|
+
summary: "Find papers similar to a given paper",
|
|
2579
|
+
value: {
|
|
2580
|
+
id: "10.1038/nature12373",
|
|
2581
|
+
limit: 20
|
|
2582
|
+
}
|
|
2583
|
+
},
|
|
2584
|
+
"Find similar with edges": {
|
|
2585
|
+
summary: "Find similar papers with citation graph edges",
|
|
2586
|
+
value: {
|
|
2587
|
+
id: "10.1038/nature12373",
|
|
2588
|
+
limit: 20,
|
|
2589
|
+
includeEdges: true
|
|
2590
|
+
}
|
|
2591
|
+
},
|
|
2592
|
+
"Find similar by OpenAlex ID": {
|
|
2593
|
+
summary: "Find similar papers using an OpenAlex ID",
|
|
2594
|
+
value: {
|
|
2595
|
+
id: "W2963403868",
|
|
2596
|
+
limit: 10
|
|
2597
|
+
}
|
|
2598
|
+
}
|
|
2599
|
+
};
|
|
2600
|
+
const similarPapers = oc.input(z.object({
|
|
2601
|
+
id: z.string({ message: "id is required and must be a string" }).min(1, "id must not be empty").max(500, "id must be at most 500 characters").describe("Seed paper identifier. Supports DOI, Semantic Scholar ID, ArXiv ID, PubMed ID, OpenAlex ID, or URL."),
|
|
2602
|
+
limit: z.number({ message: "limit must be a number" }).int("limit must be a whole number").min(1, "limit must be at least 1").max(100, "limit must be at most 100").default(30).describe("Maximum number of similar papers to return"),
|
|
2603
|
+
includeEdges: z.boolean({ message: "includeEdges must be a boolean" }).default(false).describe("Whether to include citing/cited_by edge data for graph construction"),
|
|
2604
|
+
fields: z.array(z.enum([
|
|
2605
|
+
"doi",
|
|
2606
|
+
"title",
|
|
2607
|
+
"url",
|
|
2608
|
+
"providerURL",
|
|
2609
|
+
"authors",
|
|
2610
|
+
"date",
|
|
2611
|
+
"year",
|
|
2612
|
+
"totalCitations",
|
|
2613
|
+
"totalReferences",
|
|
2614
|
+
"abstract",
|
|
2615
|
+
"pdfURL",
|
|
2616
|
+
"provider",
|
|
2617
|
+
"providerData"
|
|
2618
|
+
]), { message: "fields must be an array of valid publication field names" }).nullish().describe("Specific publication fields to return. If omitted, returns all fields except providerData."),
|
|
2619
|
+
callback: z.object({
|
|
2620
|
+
url: z.url().describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2621
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2622
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
2623
|
+
})).output(z.object({
|
|
2624
|
+
seed: publicationSchema,
|
|
2625
|
+
results: z.array(similarPaperSchema),
|
|
2626
|
+
requestId: z.number().int()
|
|
2627
|
+
})).route({
|
|
2628
|
+
summary: "Find similar papers",
|
|
2629
|
+
description: `Find papers similar to a seed paper using citation network analysis. Returns papers ranked by similarity with optional graph edge data for visualization. Costs ${academicCreditCosts.academicSimilarPapers} credits per request.`,
|
|
2630
|
+
tags: ["Academic"],
|
|
2631
|
+
spec: (op) => {
|
|
2632
|
+
op.security = [{ bearerAuth: [] }];
|
|
2633
|
+
const reqBody = op.requestBody;
|
|
2634
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$15;
|
|
2635
|
+
op["x-codeSamples"] = getOpenApiCodeSamples("academic-similar-papers");
|
|
2636
|
+
return op;
|
|
2637
|
+
}
|
|
2638
|
+
});
|
|
2639
|
+
// ../util/lib/contract/instance/router/academic/index.ts
|
|
2640
|
+
var academic_exports = /* @__PURE__ */ __exportAll({
|
|
2641
|
+
fetch: () => fetch,
|
|
2642
|
+
findCitations: () => findCitations,
|
|
2643
|
+
paperGraph: () => paperGraph,
|
|
2644
|
+
parse: () => parse$4,
|
|
2645
|
+
search: () => search,
|
|
2646
|
+
searchGrants: () => searchGrants,
|
|
2647
|
+
similarPapers: () => similarPapers
|
|
2648
|
+
});
|
|
2649
|
+
// ../util/lib/contract/instance/router/admin/get-environment.ts
|
|
2650
|
+
const getEnvironment = oc.route({
|
|
2651
|
+
summary: "Get instance server's environment",
|
|
2652
|
+
description: "Return all environment variables available to the instance server process",
|
|
2653
|
+
tags: ["Admin"],
|
|
2654
|
+
spec: (op) => {
|
|
2655
|
+
op.security = [{ bearerAuth: [] }];
|
|
2656
|
+
return op;
|
|
2657
|
+
}
|
|
2658
|
+
}).output(z.object({ environment: z.record(z.string(), z.string()) }));
|
|
2659
|
+
// ../util/lib/contract/instance/router/admin/get-free-usage-records.ts
|
|
2660
|
+
const freeUsageRecordSchema = z.object({
|
|
2661
|
+
id: z.number(),
|
|
2662
|
+
operation: z.string(),
|
|
2663
|
+
ip: z.string(),
|
|
2664
|
+
source: z.enum(apiSources).default("unknown"),
|
|
2665
|
+
model: z.string().nullable(),
|
|
2666
|
+
inputSource: z.string().nullable(),
|
|
2667
|
+
inputRef: z.string().nullable(),
|
|
2668
|
+
fileSize: z.number().nullable(),
|
|
2669
|
+
documentType: z.string().nullable(),
|
|
2670
|
+
pageCount: z.number().nullable(),
|
|
2671
|
+
error: z.string().nullable(),
|
|
2672
|
+
status: z.enum(usageStatuses),
|
|
2673
|
+
errorStage: z.enum(errorStages).nullable(),
|
|
2674
|
+
errorCode: z.string().nullable(),
|
|
2675
|
+
duration: z.number(),
|
|
2676
|
+
createdAt: z.number()
|
|
2677
|
+
});
|
|
2678
|
+
const getFreeUsageRecords = oc.route({
|
|
2679
|
+
summary: "Get free usage records",
|
|
2680
|
+
description: "Returns free usage records with id > cursor, ordered by id ascending",
|
|
2681
|
+
tags: ["Admin"],
|
|
2682
|
+
spec: (op) => {
|
|
2683
|
+
op.security = [{ bearerAuth: [] }];
|
|
2684
|
+
return op;
|
|
2685
|
+
}
|
|
2686
|
+
}).input(z.object({
|
|
2687
|
+
cursor: z.number().optional().default(0),
|
|
2688
|
+
limit: z.number().optional().default(1e3)
|
|
2689
|
+
})).output(z.object({
|
|
2690
|
+
records: z.array(freeUsageRecordSchema),
|
|
2691
|
+
hasMore: z.boolean()
|
|
2692
|
+
}));
|
|
2693
|
+
// ../util/lib/contract/instance/router/admin/get-provider-usage-records.ts
|
|
2694
|
+
const providerUsageRecordSchema = z.object({
|
|
2695
|
+
id: z.number(),
|
|
2696
|
+
apiUsageId: z.number().nullable(),
|
|
2697
|
+
operation: z.string(),
|
|
2698
|
+
phase: z.string(),
|
|
2699
|
+
provider: z.string(),
|
|
2700
|
+
service: z.string(),
|
|
2701
|
+
providerModel: z.string().nullable(),
|
|
2702
|
+
providerRegion: z.string().nullable(),
|
|
2703
|
+
providerResource: z.string().nullable(),
|
|
2704
|
+
documentType: z.string().nullable(),
|
|
2705
|
+
fileSize: z.number().nullable(),
|
|
2706
|
+
pageCount: z.number().nullable(),
|
|
2707
|
+
inputTokens: z.number().nullable(),
|
|
2708
|
+
uncachedInputTokens: z.number().nullable(),
|
|
2709
|
+
cachedInputTokens: z.number().nullable(),
|
|
2710
|
+
cacheWriteTokens: z.number().nullable(),
|
|
2711
|
+
outputTokens: z.number().nullable(),
|
|
2712
|
+
reasoningTokens: z.number().nullable(),
|
|
2713
|
+
totalTokens: z.number().nullable(),
|
|
2714
|
+
featuresJson: z.string().nullable(),
|
|
2715
|
+
status: z.enum(usageStatuses),
|
|
2716
|
+
error: z.string().nullable(),
|
|
2717
|
+
duration: z.number(),
|
|
2718
|
+
estimatedCostUsdMicro: z.number().nullable(),
|
|
2719
|
+
pricingVersion: z.string().nullable(),
|
|
2720
|
+
rawUsageJson: z.string().nullable(),
|
|
2721
|
+
createdAt: z.number()
|
|
2722
|
+
});
|
|
2723
|
+
const getProviderUsageRecords = oc.route({
|
|
2724
|
+
summary: "Get provider usage records",
|
|
2725
|
+
description: "Returns provider-level usage records with id > cursor, ordered by id ascending",
|
|
2726
|
+
tags: ["Admin"],
|
|
2727
|
+
spec: (op) => {
|
|
2728
|
+
op.security = [{ bearerAuth: [] }];
|
|
2729
|
+
return op;
|
|
2730
|
+
}
|
|
2731
|
+
}).input(z.object({
|
|
2732
|
+
cursor: z.number().optional().default(0),
|
|
2733
|
+
limit: z.number().optional().default(1e3)
|
|
2734
|
+
})).output(z.object({
|
|
2735
|
+
records: z.array(providerUsageRecordSchema),
|
|
2736
|
+
hasMore: z.boolean()
|
|
2737
|
+
}));
|
|
2738
|
+
// ../util/lib/contract/instance/router/admin/get-usage-records.ts
|
|
2739
|
+
const usageRecordSchema = z.object({
|
|
2740
|
+
id: z.number(),
|
|
2741
|
+
credits: z.number(),
|
|
2742
|
+
model: z.string().nullable(),
|
|
2743
|
+
inputSource: z.string(),
|
|
2744
|
+
inputRef: z.string().nullable(),
|
|
2745
|
+
fileSize: z.number(),
|
|
2746
|
+
documentType: z.string(),
|
|
2747
|
+
documentId: z.string().nullable(),
|
|
2748
|
+
error: z.string().nullable(),
|
|
2749
|
+
status: z.enum(usageStatuses),
|
|
2750
|
+
errorStage: z.enum(errorStages).nullable(),
|
|
2751
|
+
errorCode: z.string().nullable(),
|
|
2752
|
+
duration: z.number(),
|
|
2753
|
+
operation: z.string(),
|
|
2754
|
+
pageCount: z.number().nullable(),
|
|
2755
|
+
requestedModel: z.string(),
|
|
2756
|
+
actualModel: z.string().nullable(),
|
|
2757
|
+
apiKey: z.string().nullable(),
|
|
2758
|
+
workspaceId: z.number().nullable(),
|
|
2759
|
+
source: z.enum(apiSources).default("unknown"),
|
|
2760
|
+
createdAt: z.number()
|
|
2761
|
+
});
|
|
2762
|
+
const getUsageRecords = oc.route({
|
|
2763
|
+
summary: "Get usage records",
|
|
2764
|
+
description: "Returns usage records with id > cursor, ordered by id ascending",
|
|
2765
|
+
tags: ["Admin"],
|
|
2766
|
+
spec: (op) => {
|
|
2767
|
+
op.security = [{ bearerAuth: [] }];
|
|
2768
|
+
return op;
|
|
2769
|
+
}
|
|
2770
|
+
}).input(z.object({
|
|
2771
|
+
cursor: z.number().optional().default(0),
|
|
2772
|
+
limit: z.number().optional().default(1e3)
|
|
2773
|
+
})).output(z.object({
|
|
2774
|
+
records: z.array(usageRecordSchema),
|
|
2775
|
+
hasMore: z.boolean()
|
|
2776
|
+
}));
|
|
2777
|
+
// ../util/lib/contract/instance/router/admin/health-check.ts
|
|
2778
|
+
const adminOutputSchema$2 = z.object({ message: z.string() });
|
|
2779
|
+
const healthCheck = oc.route({
|
|
2780
|
+
summary: "Health check",
|
|
2781
|
+
description: "Check that the instance server and database are operational",
|
|
2782
|
+
tags: ["Admin"],
|
|
2783
|
+
spec: (op) => {
|
|
2784
|
+
op.security = [{ bearerAuth: [] }];
|
|
2785
|
+
return op;
|
|
2786
|
+
}
|
|
2787
|
+
}).output(adminOutputSchema$2);
|
|
2788
|
+
// ../util/lib/contract/instance/router/admin/set-domain.ts
|
|
2789
|
+
const adminOutputSchema$1 = z.object({ message: z.string() });
|
|
2790
|
+
const setDomainInputSchema = z.object({ domain: z.string().regex(/^([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/, "Must be a valid hostname (e.g. app.example.com)") });
|
|
2791
|
+
const setDomain = oc.route({
|
|
2792
|
+
summary: "Set instance server's domain",
|
|
2793
|
+
description: "Update the instance server's domain name",
|
|
2794
|
+
tags: ["Admin"],
|
|
2795
|
+
spec: (op) => {
|
|
2796
|
+
op.security = [{ bearerAuth: [] }];
|
|
2797
|
+
return op;
|
|
2798
|
+
}
|
|
2799
|
+
}).input(setDomainInputSchema).output(adminOutputSchema$1);
|
|
2800
|
+
// ../util/lib/contract/instance/router/admin/set-environment.ts
|
|
2801
|
+
const reservedKeys = /* @__PURE__ */ new Set([
|
|
2802
|
+
"NODE_ENV",
|
|
2803
|
+
"PDFVECTOR_LOCAL",
|
|
2804
|
+
"VITE_PDFVECTOR_LOCAL",
|
|
2805
|
+
"NEXT_PUBLIC_PDFVECTOR_LOCAL",
|
|
2806
|
+
"PDFVECTOR_RELEASES_REGION",
|
|
2807
|
+
"PDFVECTOR_RELEASES_S3_BUCKET",
|
|
2808
|
+
"PDFVECTOR_RELEASES_DYNAMODB_TABLE",
|
|
2809
|
+
"PDFVECTOR_INSTANCE_SERVER_DOMAIN",
|
|
2810
|
+
"PDFVECTOR_INSTANCE_SERVER_DATA_DIR"
|
|
2811
|
+
]);
|
|
2812
|
+
const setEnvironment = oc.route({
|
|
2813
|
+
summary: "Set instance server's environment",
|
|
2814
|
+
description: "Update instance environment variables, or remove them by passing null",
|
|
2815
|
+
tags: ["Admin"],
|
|
2816
|
+
spec: (op) => {
|
|
2817
|
+
op.security = [{ bearerAuth: [] }];
|
|
2818
|
+
return op;
|
|
2819
|
+
}
|
|
2820
|
+
}).input(z.object({ environment: z.record(z.string().regex(/^[A-Z_][A-Z0-9_]*$/, "Keys must be valid env var names (e.g. MY_VAR)"), z.union([z.string().regex(/^[^\0\n\r]*$/, "Values must not contain NULs or newlines"), z.null()])).refine((env) => Object.keys(env).length > 0, { message: "At least one environment variable is required" }).refine((env) => !Object.keys(env).some((key) => reservedKeys.has(key)), { message: `Cannot set reserved keys: ${[...reservedKeys].join(", ")}` }) })).output(z.object({ message: z.string() }));
|
|
2821
|
+
// ../util/lib/contract/instance/router/admin/set-version.ts
|
|
2822
|
+
const setVersionInputSchema = z.object({ version: z.union([z.string().regex(/^\d+\.\d+\.\d+$/, "Must be a valid semver (e.g. 1.2.3)"), z.literal("LATEST")]) });
|
|
2823
|
+
const adminOutputSchema = z.object({ message: z.string() });
|
|
2824
|
+
const setVersion = oc.route({
|
|
2825
|
+
summary: "Set instance server's version",
|
|
2826
|
+
description: "Update the instance server to a specific version",
|
|
2827
|
+
tags: ["Admin"],
|
|
2828
|
+
spec: (op) => {
|
|
2829
|
+
op.security = [{ bearerAuth: [] }];
|
|
2830
|
+
return op;
|
|
2831
|
+
}
|
|
2832
|
+
}).input(setVersionInputSchema).output(adminOutputSchema);
|
|
2833
|
+
// ../util/lib/contract/instance/router/admin/index.ts
|
|
2834
|
+
var admin_exports = /* @__PURE__ */ __exportAll({
|
|
2835
|
+
getEnvironment: () => getEnvironment,
|
|
2836
|
+
getFreeUsageRecords: () => getFreeUsageRecords,
|
|
2837
|
+
getProviderUsageRecords: () => getProviderUsageRecords,
|
|
2838
|
+
getUsageRecords: () => getUsageRecords,
|
|
2839
|
+
healthCheck: () => healthCheck,
|
|
2840
|
+
setDomain: () => setDomain,
|
|
2841
|
+
setEnvironment: () => setEnvironment,
|
|
2842
|
+
setVersion: () => setVersion
|
|
2843
|
+
});
|
|
2844
|
+
// ../util/lib/contract/instance/router/authenticate/validate-credential.ts
|
|
2845
|
+
const inputSchema$3 = z.object({}).optional();
|
|
2846
|
+
const outputSchema$4 = z.object({
|
|
2847
|
+
status: z.string().describe("Server status indicator"),
|
|
2848
|
+
version: z.string().describe("Server version"),
|
|
2849
|
+
timestamp: z.string().describe("Current server timestamp in ISO 8601 format")
|
|
2850
|
+
});
|
|
2851
|
+
const validateCredential = oc.route({
|
|
2852
|
+
summary: "Validate API credential",
|
|
2853
|
+
description: "Verify that the API key is valid and the server is reachable. Returns basic server information.",
|
|
2854
|
+
tags: ["Authenticate"],
|
|
2855
|
+
spec: (op) => {
|
|
2856
|
+
op.security = [{ bearerAuth: [] }];
|
|
2857
|
+
return op;
|
|
2858
|
+
}
|
|
2859
|
+
}).input(inputSchema$3).output(outputSchema$4);
|
|
2860
|
+
// ../util/lib/contract/instance/router/authenticate/index.ts
|
|
2861
|
+
var authenticate_exports = /* @__PURE__ */ __exportAll({ validateCredential: () => validateCredential });
|
|
2862
|
+
// ../util/lib/contract/instance/router/bankStatement/get-default-spec.ts
|
|
2863
|
+
function getDefaultSpec$3(op, requestExamples) {
|
|
2864
|
+
op["security"] = [{ bearerAuth: [] }];
|
|
2865
|
+
const params = op["parameters"] ?? [];
|
|
2866
|
+
params.push({
|
|
2867
|
+
name: "x-pdfvector-document-id",
|
|
2868
|
+
in: "header",
|
|
2869
|
+
required: false,
|
|
2870
|
+
schema: {
|
|
2871
|
+
type: "string",
|
|
2872
|
+
default: "my-doc-123"
|
|
2873
|
+
},
|
|
2874
|
+
description: "Optional document ID to associate with this request. Returned in the response and saved for usage tracking."
|
|
2875
|
+
});
|
|
2876
|
+
op["parameters"] = params;
|
|
2877
|
+
const reqBody = op["requestBody"];
|
|
2878
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples;
|
|
2879
|
+
return op;
|
|
2880
|
+
}
|
|
2881
|
+
// ../util/lib/contract/instance/router/bankStatement/ask.ts
|
|
2882
|
+
const specializedModelSchema$5 = z.enum(["auto", ...pdfvectorModelSchema.options]).default("auto");
|
|
2883
|
+
const askInputSchema$3 = z.object({
|
|
2884
|
+
url: fetchableUrlSchema.optional().describe("URL of the bank statement file to fetch and parse"),
|
|
2885
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
2886
|
+
base64: z.string().optional().describe("Base64-encoded bank statement file content"),
|
|
2887
|
+
question: z.string().min(4, "question must be at least 4 characters").describe("The question to answer about the bank statement"),
|
|
2888
|
+
model: specializedModelSchema$5.describe(specializedAskModelDescription),
|
|
2889
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
2890
|
+
callback: z.object({
|
|
2891
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2892
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2893
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
2894
|
+
});
|
|
2895
|
+
const askOutputSchema$3 = z.object({
|
|
2896
|
+
markdown: z.string().describe("The answer to the question"),
|
|
2897
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
2898
|
+
model: pdfvectorModelSchema.describe(outputAskModelDescription),
|
|
2899
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=6, mini=10, pro=14, max=18."),
|
|
2900
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
2901
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
2902
|
+
});
|
|
2903
|
+
const requestExamples$14 = { "Ask from URL": {
|
|
2904
|
+
summary: "Ask from URL",
|
|
2905
|
+
value: {
|
|
2906
|
+
url: "https://example.com/bank-statement.pdf",
|
|
2907
|
+
question: "What is the ending balance?"
|
|
2908
|
+
}
|
|
2909
|
+
} };
|
|
2910
|
+
const ask$3 = oc.route({
|
|
2911
|
+
summary: "Ask a question about a bank statement",
|
|
2912
|
+
description: `Parse a bank statement and answer a question about its content using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
2913
|
+
tags: ["Bank Statement"],
|
|
2914
|
+
spec: (op) => {
|
|
2915
|
+
const spec = getDefaultSpec$3(op, requestExamples$14);
|
|
2916
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("bank-statement-ask");
|
|
2917
|
+
return spec;
|
|
2918
|
+
}
|
|
2919
|
+
}).input(askInputSchema$3).output(askOutputSchema$3);
|
|
2920
|
+
// ../util/lib/contract/instance/json-schema-input.ts
|
|
2921
|
+
const schemaObject = z.record(z.string(), z.unknown(), { error: "Schema must be a JSON object" });
|
|
2922
|
+
const jsonSchemaInput = z.union([schemaObject, z.string().transform((str, ctx) => {
|
|
2923
|
+
try {
|
|
2924
|
+
const trimmed = str.startsWith("\"") && str.endsWith("\"") ? str.slice(1, -1) : str;
|
|
2925
|
+
return JSON.parse(trimmed);
|
|
2926
|
+
} catch {
|
|
2927
|
+
ctx.addIssue({
|
|
2928
|
+
code: "custom",
|
|
2929
|
+
message: "Invalid JSON string for schema"
|
|
2930
|
+
});
|
|
2931
|
+
return z.NEVER;
|
|
2932
|
+
}
|
|
2933
|
+
}).pipe(schemaObject)]);
|
|
2934
|
+
// ../util/lib/contract/instance/router/bankStatement/extract.ts
|
|
2935
|
+
const specializedModelSchema$4 = z.enum(["auto", ...pdfvectorModelSchema.options]).default("auto");
|
|
2936
|
+
const extractInputSchema$3 = z.object({
|
|
2937
|
+
url: fetchableUrlSchema.optional().describe("URL of the bank statement file to fetch and parse"),
|
|
2938
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
2939
|
+
base64: z.string().optional().describe("Base64-encoded bank statement file content"),
|
|
2940
|
+
prompt: z.string().min(4, "prompt must be at least 4 characters").describe("The prompt instructing the AI how to extract data from the bank statement"),
|
|
2941
|
+
schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the bank statement. Can be a JSON object or a JSON string."),
|
|
2942
|
+
model: specializedModelSchema$4.describe(specializedExtractModelDescription),
|
|
2943
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
2944
|
+
callback: z.object({
|
|
2945
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
2946
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
2947
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
2948
|
+
});
|
|
2949
|
+
const extractOutputSchema$3 = z.object({
|
|
2950
|
+
data: z.unknown().refine((val) => val != null && (typeof val !== "object" || Object.keys(val).length > 0), { message: "Extracted data must not be empty" }).describe("Extracted structured data matching the provided JSON Schema"),
|
|
2951
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
2952
|
+
model: pdfvectorModelSchema.describe(outputExtractModelDescription),
|
|
2953
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=6, mini=10, pro=14, max=18."),
|
|
2954
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
2955
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
2956
|
+
});
|
|
2957
|
+
const requestExamples$13 = { "Extract from URL": {
|
|
2958
|
+
summary: "Extract from URL",
|
|
2959
|
+
value: {
|
|
2960
|
+
url: "https://example.com/bank-statement.pdf",
|
|
2961
|
+
prompt: "Extract the account number, statement period, and transactions",
|
|
2962
|
+
schema: JSON.stringify({
|
|
2963
|
+
type: "object",
|
|
2964
|
+
properties: {
|
|
2965
|
+
accountNumber: { type: "string" },
|
|
2966
|
+
statementPeriod: { type: "string" },
|
|
2967
|
+
transactions: {
|
|
2968
|
+
type: "array",
|
|
2969
|
+
items: {
|
|
2970
|
+
type: "object",
|
|
2971
|
+
properties: {
|
|
2972
|
+
date: { type: "string" },
|
|
2973
|
+
description: { type: "string" },
|
|
2974
|
+
amount: { type: "number" }
|
|
2975
|
+
}
|
|
2976
|
+
}
|
|
2977
|
+
}
|
|
2978
|
+
},
|
|
2979
|
+
required: ["accountNumber", "statementPeriod"]
|
|
2980
|
+
})
|
|
2981
|
+
}
|
|
2982
|
+
} };
|
|
2983
|
+
const extract$3 = oc.route({
|
|
2984
|
+
summary: "Extract structured data from a bank statement",
|
|
2985
|
+
description: `Parse a bank statement and extract structured data matching a provided JSON Schema using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
2986
|
+
tags: ["Bank Statement"],
|
|
2987
|
+
spec: (op) => {
|
|
2988
|
+
const spec = getDefaultSpec$3(op, requestExamples$13);
|
|
2989
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("bank-statement-extract");
|
|
2990
|
+
return spec;
|
|
2991
|
+
}
|
|
2992
|
+
}).input(extractInputSchema$3).output(extractOutputSchema$3);
|
|
2993
|
+
// ../util/lib/contract/instance/router/bankStatement/parse.ts
|
|
2994
|
+
const specializedParseModelSchema$2 = z.enum([
|
|
2995
|
+
"pro",
|
|
2996
|
+
"max",
|
|
2997
|
+
"auto"
|
|
2998
|
+
], { message: "model must be one of: pro, max, auto" }).default("auto");
|
|
2999
|
+
const parseInputSchema$3 = z.object({
|
|
3000
|
+
url: fetchableUrlSchema.optional().describe("URL of the bank statement file to fetch and parse"),
|
|
3001
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3002
|
+
base64: z.string().optional().describe("Base64-encoded bank statement file content"),
|
|
3003
|
+
model: specializedParseModelSchema$2.describe(specializedParseModelDescription("bank statement")),
|
|
3004
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3005
|
+
callback: z.object({
|
|
3006
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3007
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3008
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3009
|
+
});
|
|
3010
|
+
const parseOutputSchema$3 = z.object({
|
|
3011
|
+
markdown: z.string().describe("Extracted text content from the bank statement"),
|
|
3012
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3013
|
+
model: z.enum(["pro", "max"]).describe("Model tier used to parse the bank statement"),
|
|
3014
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: pro=6, max=10."),
|
|
3015
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3016
|
+
html: z.string().optional().describe("Full HTML representation of the document content. Only available when using the 'max' model. Preserves rich formatting, tables, selection marks, and visual layout that cannot be fully represented in markdown."),
|
|
3017
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3018
|
+
});
|
|
3019
|
+
const requestExamples$12 = {
|
|
3020
|
+
"Parse from URL": {
|
|
3021
|
+
summary: "Parse from URL",
|
|
3022
|
+
value: { url: "https://example.com/bank-statement.pdf" }
|
|
3023
|
+
},
|
|
3024
|
+
"Parse from base64": {
|
|
3025
|
+
summary: "Parse from base64",
|
|
3026
|
+
value: { base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==" }
|
|
3027
|
+
},
|
|
3028
|
+
"Parse from file upload": {
|
|
3029
|
+
summary: "Parse from file upload",
|
|
3030
|
+
value: { file: "(binary)" }
|
|
3031
|
+
}
|
|
3032
|
+
};
|
|
3033
|
+
const parse$3 = oc.route({
|
|
3034
|
+
summary: "Parse a bank statement",
|
|
3035
|
+
description: `Extract text and structured data from a bank statement. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3036
|
+
tags: ["Bank Statement"],
|
|
3037
|
+
spec: (op) => {
|
|
3038
|
+
const spec = getDefaultSpec$3(op, requestExamples$12);
|
|
3039
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("bank-statement-parse");
|
|
3040
|
+
return spec;
|
|
3041
|
+
}
|
|
3042
|
+
}).input(parseInputSchema$3).output(parseOutputSchema$3);
|
|
3043
|
+
// ../util/lib/contract/instance/router/bankStatement/index.ts
|
|
3044
|
+
var bankStatement_exports = /* @__PURE__ */ __exportAll({
|
|
3045
|
+
ask: () => ask$3,
|
|
3046
|
+
extract: () => extract$3,
|
|
3047
|
+
parse: () => parse$3
|
|
3048
|
+
});
|
|
3049
|
+
// ../util/lib/contract/instance/router/document/get-default-spec.ts
|
|
3050
|
+
function getDefaultSpec$2(op, requestExamples) {
|
|
3051
|
+
op["security"] = [{ bearerAuth: [] }];
|
|
3052
|
+
const params = op["parameters"] ?? [];
|
|
3053
|
+
params.push({
|
|
3054
|
+
name: "x-pdfvector-document-id",
|
|
3055
|
+
in: "header",
|
|
3056
|
+
required: false,
|
|
3057
|
+
schema: {
|
|
3058
|
+
type: "string",
|
|
3059
|
+
default: "my-doc-123"
|
|
3060
|
+
},
|
|
3061
|
+
description: "Optional document ID to associate with this request. Returned in the response and saved for usage tracking."
|
|
3062
|
+
});
|
|
3063
|
+
op["parameters"] = params;
|
|
3064
|
+
const reqBody = op["requestBody"];
|
|
3065
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples;
|
|
3066
|
+
return op;
|
|
3067
|
+
}
|
|
3068
|
+
// ../util/lib/contract/instance/router/document/ask.ts
|
|
3069
|
+
const askInputSchema$2 = z.object({
|
|
3070
|
+
url: fetchableUrlSchema.optional().describe("URL of the document file to fetch and parse"),
|
|
3071
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3072
|
+
base64: z.string().optional().describe("Base64-encoded document file content"),
|
|
3073
|
+
question: z.string().min(4, "question must be at least 4 characters").describe("The question to answer about the document"),
|
|
3074
|
+
model: z.enum(["auto", ...pdfvectorModelSchema.options]).optional().default("auto").describe(documentAskModelDescription),
|
|
3075
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3076
|
+
callback: z.object({
|
|
3077
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3078
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3079
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3080
|
+
});
|
|
3081
|
+
const askOutputSchema$2 = z.object({
|
|
3082
|
+
markdown: z.string().describe("The answer to the question"),
|
|
3083
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3084
|
+
model: pdfvectorModelSchema.describe(outputAskModelDescription),
|
|
3085
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=2, mini=4, pro=8, max=16."),
|
|
3086
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3087
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3088
|
+
}).meta({ examples: [{
|
|
3089
|
+
markdown: "The study found that viral shedding peaked during the first week of symptoms, with the highest viral loads detected in throat swabs.",
|
|
3090
|
+
pageCount: 12,
|
|
3091
|
+
model: "mini",
|
|
3092
|
+
credits: 48,
|
|
3093
|
+
requestId: 1
|
|
3094
|
+
}] });
|
|
3095
|
+
const requestExamples$11 = {
|
|
3096
|
+
"Ask from URL": {
|
|
3097
|
+
summary: "Ask from URL",
|
|
3098
|
+
value: {
|
|
3099
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3100
|
+
question: "What are the main findings of this study?"
|
|
3101
|
+
}
|
|
3102
|
+
},
|
|
3103
|
+
"Ask from base64": {
|
|
3104
|
+
summary: "Ask from base64",
|
|
3105
|
+
value: {
|
|
3106
|
+
base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
|
|
3107
|
+
question: "What is the content of this document?"
|
|
3108
|
+
}
|
|
3109
|
+
},
|
|
3110
|
+
"Ask from file upload": {
|
|
3111
|
+
summary: "Ask from file upload",
|
|
3112
|
+
value: {
|
|
3113
|
+
file: "(binary)",
|
|
3114
|
+
question: "Summarize this document"
|
|
3115
|
+
}
|
|
3116
|
+
},
|
|
3117
|
+
"Ask with lightweight models (nano)": {
|
|
3118
|
+
summary: "Ask with lightweight models (nano)",
|
|
3119
|
+
value: {
|
|
3120
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3121
|
+
question: "What is the title of this paper?",
|
|
3122
|
+
model: "nano"
|
|
3123
|
+
}
|
|
3124
|
+
},
|
|
3125
|
+
"Ask with powerful models (max)": {
|
|
3126
|
+
summary: "Ask with powerful models (max)",
|
|
3127
|
+
value: {
|
|
3128
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3129
|
+
question: "Provide a detailed analysis of the methodology used in this study.",
|
|
3130
|
+
model: "max"
|
|
3131
|
+
}
|
|
3132
|
+
}
|
|
3133
|
+
};
|
|
3134
|
+
const ask$2 = oc.route({
|
|
3135
|
+
summary: "Ask a question about a document",
|
|
3136
|
+
description: `Parse a document and answer a question about its content using AI. Supports ${supportedFileTypesLong}. Files up to 1000 pages and up to 500MB in size. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3137
|
+
tags: ["Document"],
|
|
3138
|
+
spec: (op) => {
|
|
3139
|
+
const spec = getDefaultSpec$2(op, requestExamples$11);
|
|
3140
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("document-ask");
|
|
3141
|
+
return spec;
|
|
3142
|
+
}
|
|
3143
|
+
}).input(askInputSchema$2).output(askOutputSchema$2);
|
|
3144
|
+
// ../util/lib/contract/instance/router/document/extract.ts
|
|
3145
|
+
const extractInputSchema$2 = z.object({
|
|
3146
|
+
url: fetchableUrlSchema.optional().describe("URL of the document file to fetch and parse"),
|
|
3147
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3148
|
+
base64: z.string().optional().describe("Base64-encoded document file content"),
|
|
3149
|
+
prompt: z.string().min(4, "prompt must be at least 4 characters").describe("The prompt instructing the AI how to extract data from the document"),
|
|
3150
|
+
schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the document. Can be a JSON object or a JSON string."),
|
|
3151
|
+
model: z.enum(["auto", ...pdfvectorModelSchema.options]).optional().default("auto").describe(documentExtractModelDescription),
|
|
3152
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3153
|
+
callback: z.object({
|
|
3154
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3155
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3156
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3157
|
+
});
|
|
3158
|
+
const extractOutputSchema$2 = z.object({
|
|
3159
|
+
data: z.unknown().refine((val) => val != null && (typeof val !== "object" || Object.keys(val).length > 0), { message: "Extracted data must not be empty" }).describe("Extracted structured data matching the provided JSON Schema"),
|
|
3160
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3161
|
+
model: pdfvectorModelSchema.describe(outputExtractModelDescription),
|
|
3162
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=2, mini=4, pro=8, max=16."),
|
|
3163
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3164
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3165
|
+
}).meta({ examples: [{
|
|
3166
|
+
data: {
|
|
3167
|
+
title: "Virological assessment of hospitalized patients with COVID-2019",
|
|
3168
|
+
authors: ["Roman Wölfel", "Victor M. Corman"],
|
|
3169
|
+
year: 2020
|
|
3170
|
+
},
|
|
3171
|
+
pageCount: 12,
|
|
3172
|
+
model: "mini",
|
|
3173
|
+
credits: 48,
|
|
3174
|
+
requestId: 1
|
|
3175
|
+
}] });
|
|
3176
|
+
const requestExamples$10 = {
|
|
3177
|
+
"Extract from URL": {
|
|
3178
|
+
summary: "Extract from URL",
|
|
3179
|
+
value: {
|
|
3180
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3181
|
+
prompt: "Extract the title, authors, and publication year from this research paper",
|
|
3182
|
+
schema: JSON.stringify({
|
|
3183
|
+
type: "object",
|
|
3184
|
+
properties: {
|
|
3185
|
+
title: { type: "string" },
|
|
3186
|
+
authors: {
|
|
3187
|
+
type: "array",
|
|
3188
|
+
items: { type: "string" }
|
|
3189
|
+
},
|
|
3190
|
+
year: { type: "number" }
|
|
3191
|
+
},
|
|
3192
|
+
required: [
|
|
3193
|
+
"title",
|
|
3194
|
+
"authors",
|
|
3195
|
+
"year"
|
|
3196
|
+
]
|
|
3197
|
+
})
|
|
3198
|
+
}
|
|
3199
|
+
},
|
|
3200
|
+
"Extract from base64": {
|
|
3201
|
+
summary: "Extract from base64",
|
|
3202
|
+
value: {
|
|
3203
|
+
base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
|
|
3204
|
+
prompt: "Extract the main content from this document",
|
|
3205
|
+
schema: JSON.stringify({
|
|
3206
|
+
type: "object",
|
|
3207
|
+
properties: { content: { type: "string" } },
|
|
3208
|
+
required: ["content"]
|
|
3209
|
+
})
|
|
3210
|
+
}
|
|
3211
|
+
},
|
|
3212
|
+
"Extract from file upload": {
|
|
3213
|
+
summary: "Extract from file upload",
|
|
3214
|
+
value: {
|
|
3215
|
+
file: "(binary)",
|
|
3216
|
+
prompt: "Extract the title and summary from this document",
|
|
3217
|
+
schema: JSON.stringify({
|
|
3218
|
+
type: "object",
|
|
3219
|
+
properties: {
|
|
3220
|
+
title: { type: "string" },
|
|
3221
|
+
summary: { type: "string" }
|
|
3222
|
+
},
|
|
3223
|
+
required: ["title", "summary"]
|
|
3224
|
+
})
|
|
3225
|
+
}
|
|
3226
|
+
}
|
|
3227
|
+
};
|
|
3228
|
+
const extract$2 = oc.route({
|
|
3229
|
+
summary: "Extract structured data from a document",
|
|
3230
|
+
description: `Parse a document and extract structured data matching a provided JSON Schema using AI. Supports ${supportedFileTypesLong}. Files up to 1000 pages and up to 500MB in size. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3231
|
+
tags: ["Document"],
|
|
3232
|
+
spec: (op) => {
|
|
3233
|
+
const spec = getDefaultSpec$2(op, requestExamples$10);
|
|
3234
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("document-extract");
|
|
3235
|
+
return spec;
|
|
3236
|
+
}
|
|
3237
|
+
}).input(extractInputSchema$2).output(extractOutputSchema$2);
|
|
3238
|
+
// ../util/lib/contract/instance/router/document/parse.ts
|
|
3239
|
+
const parseInputSchema$2 = z.object({
|
|
3240
|
+
url: fetchableUrlSchema.optional().describe("URL of the document file to fetch and parse"),
|
|
3241
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3242
|
+
base64: z.string().optional().describe("Base64-encoded document file content"),
|
|
3243
|
+
model: z.enum(["auto", ...pdfvectorModelSchema.options]).optional().default("auto").describe(documentParseModelDescription),
|
|
3244
|
+
includePages: z.union([z.boolean(), z.enum(["true", "false"]).transform((value) => value === "true")]).optional().default(false).describe("Set to true to include page-separated markdown in the pages array. Existing markdown output is still returned as the full document text."),
|
|
3245
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3246
|
+
callback: z.object({
|
|
3247
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3248
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3249
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3250
|
+
});
|
|
3251
|
+
const parseOutputSchema$2 = z.object({
|
|
3252
|
+
documentFormat: z.enum([
|
|
3253
|
+
"pdf",
|
|
3254
|
+
"docx",
|
|
3255
|
+
"xlsx",
|
|
3256
|
+
"pptx",
|
|
3257
|
+
"odt",
|
|
3258
|
+
"ods",
|
|
3259
|
+
"odp",
|
|
3260
|
+
"txt",
|
|
3261
|
+
"md",
|
|
3262
|
+
"html",
|
|
3263
|
+
"csv",
|
|
3264
|
+
"tsv",
|
|
3265
|
+
"xml",
|
|
3266
|
+
"json",
|
|
3267
|
+
"rtf",
|
|
3268
|
+
"vtt"
|
|
3269
|
+
]).optional().describe("Detected native document format when supplied by the parser."),
|
|
3270
|
+
pageUnit: z.enum([
|
|
3271
|
+
"page",
|
|
3272
|
+
"sheet",
|
|
3273
|
+
"slide",
|
|
3274
|
+
"chunk"
|
|
3275
|
+
]).optional().describe("Billing/output unit: physical PDF page, worksheet, slide, or logical text chunk of at most 4000 Unicode characters; not a rendered Office page."),
|
|
3276
|
+
warnings: z.array(z.string().max(1e3)).max(100).optional().describe("Extraction limitations and best-effort accuracy warnings when supplied by the parser."),
|
|
3277
|
+
markdown: z.string().describe("Extracted text content from the document"),
|
|
3278
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3279
|
+
model: pdfvectorModelSchema.describe(outputModelDescription),
|
|
3280
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=1, mini=2, pro=4, max=8."),
|
|
3281
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3282
|
+
html: z.string().optional().describe("Full HTML representation of the document content. Only available when using the 'max' model. Preserves rich formatting, tables, selection marks, and visual layout that cannot be fully represented in markdown."),
|
|
3283
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body"),
|
|
3284
|
+
pages: z.array(pageMarkdownSchema).optional().describe("Page-separated markdown content. Returned only when includePages is true.")
|
|
3285
|
+
});
|
|
3286
|
+
const requestExamples$9 = {
|
|
3287
|
+
"Parse from URL": {
|
|
3288
|
+
summary: "Parse from URL",
|
|
3289
|
+
value: { url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link" }
|
|
3290
|
+
},
|
|
3291
|
+
"Parse from base64": {
|
|
3292
|
+
summary: "Parse from base64",
|
|
3293
|
+
value: { base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==" }
|
|
3294
|
+
},
|
|
3295
|
+
"Parse from file upload": {
|
|
3296
|
+
summary: "Parse from file upload",
|
|
3297
|
+
value: { file: "(binary)" }
|
|
3298
|
+
},
|
|
3299
|
+
"Parse with simple PDF (nano)": {
|
|
3300
|
+
summary: "Parse with simple PDF (nano)",
|
|
3301
|
+
value: {
|
|
3302
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3303
|
+
model: "nano"
|
|
3304
|
+
}
|
|
3305
|
+
},
|
|
3306
|
+
"Parse with page-separated output": {
|
|
3307
|
+
summary: "Parse with page-separated output",
|
|
3308
|
+
value: {
|
|
3309
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3310
|
+
includePages: true
|
|
3311
|
+
}
|
|
3312
|
+
},
|
|
3313
|
+
"Parse with small complex documents (pro)": {
|
|
3314
|
+
summary: "Parse with small complex documents (pro)",
|
|
3315
|
+
value: {
|
|
3316
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3317
|
+
model: "pro"
|
|
3318
|
+
}
|
|
3319
|
+
},
|
|
3320
|
+
"Parse with large complex documents (max)": {
|
|
3321
|
+
summary: "Parse with large complex documents (max)",
|
|
3322
|
+
value: {
|
|
3323
|
+
url: "https://drive.google.com/file/d/13T04Yk20OwBNIDyvJJ3XlUg9WfOsmbjm/view?usp=share_link",
|
|
3324
|
+
model: "max"
|
|
3325
|
+
}
|
|
3326
|
+
}
|
|
3327
|
+
};
|
|
3328
|
+
const parse$2 = oc.route({
|
|
3329
|
+
summary: "Parse a document",
|
|
3330
|
+
description: `Extract text and page count from a document. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3331
|
+
tags: ["Document"],
|
|
3332
|
+
spec: (op) => {
|
|
3333
|
+
const spec = getDefaultSpec$2(op, requestExamples$9);
|
|
3334
|
+
spec["x-codeSamples"] = documentParseOpenApiCodeSamples;
|
|
3335
|
+
return spec;
|
|
3336
|
+
}
|
|
3337
|
+
}).input(parseInputSchema$2).output(parseOutputSchema$2);
|
|
3338
|
+
// ../util/lib/contract/instance/router/document/index.ts
|
|
3339
|
+
var document_exports = /* @__PURE__ */ __exportAll({
|
|
3340
|
+
ask: () => ask$2,
|
|
3341
|
+
extract: () => extract$2,
|
|
3342
|
+
parse: () => parse$2
|
|
3343
|
+
});
|
|
3344
|
+
// ../util/lib/contract/instance/router/free/bank-statement-parse.ts
|
|
3345
|
+
const inputSchema$2 = z.object({
|
|
3346
|
+
url: fetchableUrlSchema.optional().describe("URL of the bank statement file to fetch and parse"),
|
|
3347
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Bank statement file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3348
|
+
base64: z.string().optional().describe("Base64-encoded bank statement file content")
|
|
3349
|
+
});
|
|
3350
|
+
const outputSchema$3 = z.object({
|
|
3351
|
+
markdown: z.string().describe("Extracted text content from the bank statement"),
|
|
3352
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3353
|
+
model: z.enum(["pro", "max"]).describe("Model tier used to parse the bank statement"),
|
|
3354
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3355
|
+
html: z.string().optional().describe("Full HTML representation of the document content")
|
|
3356
|
+
});
|
|
3357
|
+
const requestExamples$8 = {
|
|
3358
|
+
"Parse from URL": {
|
|
3359
|
+
summary: "Parse from URL",
|
|
3360
|
+
value: { url: "https://raw.githubusercontent.com/aws-samples/textract-bank-statement-processor/main/Statement20230428.pdf" }
|
|
3361
|
+
},
|
|
3362
|
+
"Parse from base64": {
|
|
3363
|
+
summary: "Parse from base64",
|
|
3364
|
+
value: { base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==" }
|
|
3365
|
+
},
|
|
3366
|
+
"Parse from file upload": {
|
|
3367
|
+
summary: "Parse from file upload",
|
|
3368
|
+
value: { file: "(binary)" }
|
|
3369
|
+
}
|
|
3370
|
+
};
|
|
3371
|
+
const responseExample$3 = {
|
|
3372
|
+
markdown: "## Bank Statement\n\n### Account Information\n\n| Field | Value |\n|-------|-------|\n| Bank Name | Example Bank |\n| Account Number | ****1234 |\n| Statement Start Date | 2023-03-01 |\n| Statement End Date | 2023-03-31 |\n| Beginning Balance | $5,432.10 |\n| Ending Balance | $4,891.55 |\n\n### Transactions\n\n| Date | Description | Deposit Amount | Withdrawal Amount |\n| --- | --- | --- | --- |\n| 2023-03-05 | Direct Deposit - Payroll | $3,200.00 | |\n| 2023-03-08 | Online Transfer Out | | $500.00 |\n| 2023-03-15 | Grocery Store | | $142.35 |",
|
|
3373
|
+
pageCount: 2,
|
|
3374
|
+
model: "max",
|
|
3375
|
+
requestId: 42,
|
|
3376
|
+
html: "<p>Full HTML content...</p>"
|
|
3377
|
+
};
|
|
3378
|
+
const bankStatementParse = oc.route({
|
|
3379
|
+
summary: "Free: Parse a bank statement",
|
|
3380
|
+
description: `Extract text and structured data from a bank statement. Supports ${supportedFileTypesLong}. Free tier: max 5 pages, max 5 MB. Rate limited to 5 requests per IP per day.`,
|
|
3381
|
+
tags: ["Free"],
|
|
3382
|
+
spec: (op) => {
|
|
3383
|
+
op.security = [];
|
|
3384
|
+
const reqBody = op.requestBody;
|
|
3385
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$8;
|
|
3386
|
+
const okResponse = op.responses?.["200"];
|
|
3387
|
+
if (okResponse?.content) for (const mediaType of Object.values(okResponse.content)) mediaType["example"] = responseExample$3;
|
|
3388
|
+
return op;
|
|
3389
|
+
}
|
|
3390
|
+
}).input(inputSchema$2).output(outputSchema$3);
|
|
3391
|
+
// ../util/lib/contract/instance/router/free/generate-schema.ts
|
|
3392
|
+
const inputSchema$1 = z.object({ instruction: z.string().min(10, "Instruction must be at least 10 characters").max(2e3, "Instruction must be at most 2000 characters").describe("Describe the data you want to extract, e.g. 'Extract vendor name, total amount, and line items from an invoice'") });
|
|
3393
|
+
const outputSchema$2 = z.object({
|
|
3394
|
+
schema: z.record(z.string(), z.unknown()).describe("Generated JSON Schema for structured data extraction"),
|
|
3395
|
+
requestId: z.number().int().describe("Unique request identifier for this API call")
|
|
3396
|
+
});
|
|
3397
|
+
const requestExamples$7 = {
|
|
3398
|
+
"Invoice extraction": {
|
|
3399
|
+
summary: "Generate schema for invoice extraction",
|
|
3400
|
+
value: { instruction: "Extract vendor name, total amount, invoice date, and line items from an invoice" }
|
|
3401
|
+
},
|
|
3402
|
+
"Resume parsing": {
|
|
3403
|
+
summary: "Generate schema for resume parsing",
|
|
3404
|
+
value: { instruction: "Extract name, email, phone number, work experience, and education from a resume" }
|
|
3405
|
+
},
|
|
3406
|
+
"Receipt data": {
|
|
3407
|
+
summary: "Generate schema for receipt data",
|
|
3408
|
+
value: { instruction: "Extract store name, date, items purchased with prices, subtotal, tax, and total from a receipt" }
|
|
3409
|
+
}
|
|
3410
|
+
};
|
|
3411
|
+
const responseExample$2 = {
|
|
3412
|
+
schema: {
|
|
3413
|
+
type: "object",
|
|
3414
|
+
description: "Extracted data from an invoice document.",
|
|
3415
|
+
properties: {
|
|
3416
|
+
vendor_name: {
|
|
3417
|
+
type: "string",
|
|
3418
|
+
description: "The name of the vendor or supplier."
|
|
3419
|
+
},
|
|
3420
|
+
total_amount: {
|
|
3421
|
+
type: "number",
|
|
3422
|
+
description: "The total amount due on the invoice."
|
|
3423
|
+
},
|
|
3424
|
+
invoice_date: {
|
|
3425
|
+
type: "string",
|
|
3426
|
+
description: "The date the invoice was issued (YYYY-MM-DD)."
|
|
3427
|
+
},
|
|
3428
|
+
line_items: {
|
|
3429
|
+
type: "array",
|
|
3430
|
+
description: "Individual items listed on the invoice.",
|
|
3431
|
+
items: {
|
|
3432
|
+
type: "object",
|
|
3433
|
+
properties: {
|
|
3434
|
+
description: {
|
|
3435
|
+
type: "string",
|
|
3436
|
+
description: "Description of the item."
|
|
3437
|
+
},
|
|
3438
|
+
quantity: {
|
|
3439
|
+
type: "number",
|
|
3440
|
+
description: "Quantity ordered."
|
|
3441
|
+
},
|
|
3442
|
+
unit_price: {
|
|
3443
|
+
type: "number",
|
|
3444
|
+
description: "Price per unit."
|
|
3445
|
+
},
|
|
3446
|
+
total: {
|
|
3447
|
+
type: "number",
|
|
3448
|
+
description: "Total price for this line item."
|
|
3449
|
+
}
|
|
3450
|
+
},
|
|
3451
|
+
required: [
|
|
3452
|
+
"description",
|
|
3453
|
+
"quantity",
|
|
3454
|
+
"unit_price",
|
|
3455
|
+
"total"
|
|
3456
|
+
],
|
|
3457
|
+
additionalProperties: false
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
},
|
|
3461
|
+
required: [
|
|
3462
|
+
"vendor_name",
|
|
3463
|
+
"total_amount",
|
|
3464
|
+
"invoice_date",
|
|
3465
|
+
"line_items"
|
|
3466
|
+
],
|
|
3467
|
+
additionalProperties: false
|
|
3468
|
+
},
|
|
3469
|
+
requestId: 42
|
|
3470
|
+
};
|
|
3471
|
+
const generateSchema = oc.route({
|
|
3472
|
+
summary: "Free: Generate a JSON Schema",
|
|
3473
|
+
description: "Generate a JSON Schema from a natural language instruction. Use the resulting schema with the /extract endpoints to pull structured data from documents. Rate limited to 10 requests per IP per day.",
|
|
3474
|
+
tags: ["Free"],
|
|
3475
|
+
spec: (op) => {
|
|
3476
|
+
op.security = [];
|
|
3477
|
+
const reqBody = op.requestBody;
|
|
3478
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$7;
|
|
3479
|
+
const okResponse = op.responses?.["200"];
|
|
3480
|
+
if (okResponse?.content) for (const mediaType of Object.values(okResponse.content)) mediaType["example"] = responseExample$2;
|
|
3481
|
+
return op;
|
|
3482
|
+
}
|
|
3483
|
+
}).input(inputSchema$1).output(outputSchema$2);
|
|
3484
|
+
// ../util/lib/contract/instance/router/free/publication-pdf-url.ts
|
|
3485
|
+
const inputSchema = z.object({ ids: z.array(z.string().min(1, "Each ID must be a non-empty string"), { message: "ids is required and must be an array of strings" }).min(1, "ids must contain at least 1 identifier").max(20, "ids must contain at most 20 identifiers").describe("Publication identifiers: DOI (e.g. 10.1371/journal.pone.0185809), PubMed ID (e.g. 33116299), ArXiv ID (e.g. 1706.03762), or other supported format") });
|
|
3486
|
+
const resultSchema = z.object({
|
|
3487
|
+
id: z.string().describe("The input publication identifier"),
|
|
3488
|
+
pdfUrl: z.string().optional().describe("Direct URL to the publication PDF, if available"),
|
|
3489
|
+
title: z.string().optional().describe("Title of the publication")
|
|
3490
|
+
});
|
|
3491
|
+
const outputSchema$1 = z.object({
|
|
3492
|
+
results: z.array(resultSchema).describe("Results for each input ID"),
|
|
3493
|
+
requestId: z.number().int().describe("Unique request identifier for this API call")
|
|
3494
|
+
});
|
|
3495
|
+
const requestExamples$6 = {
|
|
3496
|
+
"Single ArXiv ID": {
|
|
3497
|
+
summary: "Get PDF URL for an ArXiv paper",
|
|
3498
|
+
value: { ids: ["1706.03762"] }
|
|
3499
|
+
},
|
|
3500
|
+
"Multiple IDs": {
|
|
3501
|
+
summary: "Batch lookup with mixed identifier types",
|
|
3502
|
+
value: { ids: [
|
|
3503
|
+
"1706.03762",
|
|
3504
|
+
"33116299",
|
|
3505
|
+
"10.1371/journal.pone.0185809"
|
|
3506
|
+
] }
|
|
3507
|
+
},
|
|
3508
|
+
"Single PubMed ID": {
|
|
3509
|
+
summary: "Get PDF URL for a PubMed paper",
|
|
3510
|
+
value: { ids: ["33116299"] }
|
|
3511
|
+
}
|
|
3512
|
+
};
|
|
3513
|
+
const responseExample$1 = {
|
|
3514
|
+
results: [{
|
|
3515
|
+
id: "1706.03762",
|
|
3516
|
+
pdfUrl: "https://arxiv.org/pdf/1706.03762v7",
|
|
3517
|
+
title: "Attention Is All You Need"
|
|
3518
|
+
}, {
|
|
3519
|
+
id: "33116299",
|
|
3520
|
+
pdfUrl: "https://www.nature.com/articles/s41586-020-2901-9.pdf",
|
|
3521
|
+
title: "Identification of SARS-CoV-2 inhibitors using lung and colonic organoids"
|
|
3522
|
+
}],
|
|
3523
|
+
requestId: 42
|
|
3524
|
+
};
|
|
3525
|
+
const publicationPdfUrl = oc.route({
|
|
3526
|
+
summary: "Free: Get publication PDF URL",
|
|
3527
|
+
description: "Look up publications by DOI, PubMed ID, ArXiv ID, or other identifiers and return their PDF URLs if available. Accepts up to 20 IDs per request. Rate limited to 20 requests per IP per day.",
|
|
3528
|
+
tags: ["Free"],
|
|
3529
|
+
spec: (op) => {
|
|
3530
|
+
op.security = [];
|
|
3531
|
+
const reqBody = op.requestBody;
|
|
3532
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples$6;
|
|
3533
|
+
const okResponse = op.responses?.["200"];
|
|
3534
|
+
if (okResponse?.content) for (const mediaType of Object.values(okResponse.content)) mediaType["example"] = responseExample$1;
|
|
3535
|
+
return op;
|
|
3536
|
+
}
|
|
3537
|
+
}).input(inputSchema).output(outputSchema$1);
|
|
3538
|
+
// ../util/lib/contract/instance/router/free/rate-limit-status.ts
|
|
3539
|
+
const limitSchema = z.object({
|
|
3540
|
+
limit: z.number().int().describe("Maximum requests allowed per day"),
|
|
3541
|
+
used: z.number().int().describe("Requests used today"),
|
|
3542
|
+
remaining: z.number().int().describe("Requests remaining today")
|
|
3543
|
+
});
|
|
3544
|
+
const outputSchema = z.object({
|
|
3545
|
+
bankStatementParse: limitSchema.describe("Bank statement parse limits"),
|
|
3546
|
+
generateSchema: limitSchema.describe("JSON schema generator limits"),
|
|
3547
|
+
publicationPdfUrl: limitSchema.describe("Publication PDF URL lookup limits")
|
|
3548
|
+
});
|
|
3549
|
+
const responseExample = {
|
|
3550
|
+
bankStatementParse: {
|
|
3551
|
+
limit: 5,
|
|
3552
|
+
used: 2,
|
|
3553
|
+
remaining: 3
|
|
3554
|
+
},
|
|
3555
|
+
generateSchema: {
|
|
3556
|
+
limit: 10,
|
|
3557
|
+
used: 0,
|
|
3558
|
+
remaining: 10
|
|
3559
|
+
},
|
|
3560
|
+
publicationPdfUrl: {
|
|
3561
|
+
limit: 20,
|
|
3562
|
+
used: 5,
|
|
3563
|
+
remaining: 15
|
|
3564
|
+
}
|
|
3565
|
+
};
|
|
3566
|
+
const rateLimitStatus = oc.route({
|
|
3567
|
+
method: "GET",
|
|
3568
|
+
summary: "Free: Get rate limit status",
|
|
3569
|
+
description: "Check the remaining rate limit for all free API endpoints. Limits are per IP and reset daily at midnight UTC.",
|
|
3570
|
+
tags: ["Free"],
|
|
3571
|
+
spec: (op) => {
|
|
3572
|
+
op.security = [];
|
|
3573
|
+
const okResponse = op.responses?.["200"];
|
|
3574
|
+
if (okResponse?.content) for (const mediaType of Object.values(okResponse.content)) mediaType["example"] = responseExample;
|
|
3575
|
+
return op;
|
|
3576
|
+
}
|
|
3577
|
+
}).output(outputSchema);
|
|
3578
|
+
// ../util/lib/contract/instance/router/free/index.ts
|
|
3579
|
+
var free_exports = /* @__PURE__ */ __exportAll({
|
|
3580
|
+
bankStatementParse: () => bankStatementParse,
|
|
3581
|
+
generateSchema: () => generateSchema,
|
|
3582
|
+
publicationPdfUrl: () => publicationPdfUrl,
|
|
3583
|
+
rateLimitStatus: () => rateLimitStatus
|
|
3584
|
+
});
|
|
3585
|
+
// ../util/lib/contract/instance/router/identity/get-default-spec.ts
|
|
3586
|
+
function getDefaultSpec$1(op, requestExamples) {
|
|
3587
|
+
op["security"] = [{ bearerAuth: [] }];
|
|
3588
|
+
const params = op["parameters"] ?? [];
|
|
3589
|
+
params.push({
|
|
3590
|
+
name: "x-pdfvector-document-id",
|
|
3591
|
+
in: "header",
|
|
3592
|
+
required: false,
|
|
3593
|
+
schema: {
|
|
3594
|
+
type: "string",
|
|
3595
|
+
default: "my-doc-123"
|
|
3596
|
+
},
|
|
3597
|
+
description: "Optional document ID to associate with this request. Returned in the response and saved for usage tracking."
|
|
3598
|
+
});
|
|
3599
|
+
op["parameters"] = params;
|
|
3600
|
+
const reqBody = op["requestBody"];
|
|
3601
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples;
|
|
3602
|
+
return op;
|
|
3603
|
+
}
|
|
3604
|
+
// ../util/lib/contract/instance/router/identity/ask.ts
|
|
3605
|
+
const specializedModelSchema$3 = z.enum(["auto", ...pdfvectorModelSchema.options]).default("auto");
|
|
3606
|
+
const askInputSchema$1 = z.object({
|
|
3607
|
+
url: fetchableUrlSchema.optional().describe("URL of the identity document file to fetch and parse"),
|
|
3608
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Identity document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3609
|
+
base64: z.string().optional().describe("Base64-encoded identity document file content"),
|
|
3610
|
+
question: z.string().min(4, "question must be at least 4 characters").describe("The question to answer about the identity document"),
|
|
3611
|
+
model: specializedModelSchema$3.describe(specializedAskModelDescription),
|
|
3612
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3613
|
+
callback: z.object({
|
|
3614
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3615
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3616
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3617
|
+
});
|
|
3618
|
+
const askOutputSchema$1 = z.object({
|
|
3619
|
+
markdown: z.string().describe("The answer to the question"),
|
|
3620
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3621
|
+
model: pdfvectorModelSchema.describe(outputAskModelDescription),
|
|
3622
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=6, mini=10, pro=14, max=18."),
|
|
3623
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3624
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3625
|
+
});
|
|
3626
|
+
const requestExamples$5 = {
|
|
3627
|
+
"Ask from URL": {
|
|
3628
|
+
summary: "Ask from URL",
|
|
3629
|
+
value: {
|
|
3630
|
+
url: "https://example.com/identity-document.pdf",
|
|
3631
|
+
question: "What is the name on this identity document?"
|
|
3632
|
+
}
|
|
3633
|
+
},
|
|
3634
|
+
"Ask from base64": {
|
|
3635
|
+
summary: "Ask from base64",
|
|
3636
|
+
value: {
|
|
3637
|
+
base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==",
|
|
3638
|
+
question: "What is the document number?"
|
|
3639
|
+
}
|
|
3640
|
+
}
|
|
3641
|
+
};
|
|
3642
|
+
const ask$1 = oc.route({
|
|
3643
|
+
summary: "Ask a question about an identity document",
|
|
3644
|
+
description: `Parse an identity document and answer a question about its content using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3645
|
+
tags: ["Identity"],
|
|
3646
|
+
spec: (op) => {
|
|
3647
|
+
const spec = getDefaultSpec$1(op, requestExamples$5);
|
|
3648
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("identity-ask");
|
|
3649
|
+
return spec;
|
|
3650
|
+
}
|
|
3651
|
+
}).input(askInputSchema$1).output(askOutputSchema$1);
|
|
3652
|
+
// ../util/lib/contract/instance/router/identity/extract.ts
|
|
3653
|
+
const specializedModelSchema$2 = z.enum(["auto", ...pdfvectorModelSchema.options]).default("auto");
|
|
3654
|
+
const extractInputSchema$1 = z.object({
|
|
3655
|
+
url: fetchableUrlSchema.optional().describe("URL of the identity document file to fetch and parse"),
|
|
3656
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Identity document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3657
|
+
base64: z.string().optional().describe("Base64-encoded identity document file content"),
|
|
3658
|
+
prompt: z.string().min(4, "prompt must be at least 4 characters").describe("The prompt instructing the AI how to extract data from the identity document"),
|
|
3659
|
+
schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the identity document. Can be a JSON object or a JSON string."),
|
|
3660
|
+
model: specializedModelSchema$2.describe(specializedExtractModelDescription),
|
|
3661
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3662
|
+
callback: z.object({
|
|
3663
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3664
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3665
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3666
|
+
});
|
|
3667
|
+
const extractOutputSchema$1 = z.object({
|
|
3668
|
+
data: z.unknown().refine((val) => val != null && (typeof val !== "object" || Object.keys(val).length > 0), { message: "Extracted data must not be empty" }).describe("Extracted structured data matching the provided JSON Schema"),
|
|
3669
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3670
|
+
model: pdfvectorModelSchema.describe(outputExtractModelDescription),
|
|
3671
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=6, mini=10, pro=14, max=18."),
|
|
3672
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3673
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3674
|
+
});
|
|
3675
|
+
const requestExamples$4 = { "Extract from URL": {
|
|
3676
|
+
summary: "Extract from URL",
|
|
3677
|
+
value: {
|
|
3678
|
+
url: "https://example.com/identity-document.pdf",
|
|
3679
|
+
prompt: "Extract the name, date of birth, and document number",
|
|
3680
|
+
schema: JSON.stringify({
|
|
3681
|
+
type: "object",
|
|
3682
|
+
properties: {
|
|
3683
|
+
name: { type: "string" },
|
|
3684
|
+
dateOfBirth: { type: "string" },
|
|
3685
|
+
documentNumber: { type: "string" }
|
|
3686
|
+
},
|
|
3687
|
+
required: [
|
|
3688
|
+
"name",
|
|
3689
|
+
"dateOfBirth",
|
|
3690
|
+
"documentNumber"
|
|
3691
|
+
]
|
|
3692
|
+
})
|
|
3693
|
+
}
|
|
3694
|
+
} };
|
|
3695
|
+
const extract$1 = oc.route({
|
|
3696
|
+
summary: "Extract structured data from an identity document",
|
|
3697
|
+
description: `Parse an identity document and extract structured data matching a provided JSON Schema using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3698
|
+
tags: ["Identity"],
|
|
3699
|
+
spec: (op) => {
|
|
3700
|
+
const spec = getDefaultSpec$1(op, requestExamples$4);
|
|
3701
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("identity-extract");
|
|
3702
|
+
return spec;
|
|
3703
|
+
}
|
|
3704
|
+
}).input(extractInputSchema$1).output(extractOutputSchema$1);
|
|
3705
|
+
// ../util/lib/contract/instance/router/identity/parse.ts
|
|
3706
|
+
const specializedParseModelSchema$1 = z.enum([
|
|
3707
|
+
"pro",
|
|
3708
|
+
"max",
|
|
3709
|
+
"auto"
|
|
3710
|
+
], { message: "model must be one of: pro, max, auto" }).default("auto");
|
|
3711
|
+
const parseInputSchema$1 = z.object({
|
|
3712
|
+
url: fetchableUrlSchema.optional().describe("URL of the identity document file to fetch and parse"),
|
|
3713
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Identity document file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3714
|
+
base64: z.string().optional().describe("Base64-encoded identity document file content"),
|
|
3715
|
+
model: specializedParseModelSchema$1.describe(specializedParseModelDescription("identity document")),
|
|
3716
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3717
|
+
callback: z.object({
|
|
3718
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3719
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3720
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3721
|
+
});
|
|
3722
|
+
const parseOutputSchema$1 = z.object({
|
|
3723
|
+
markdown: z.string().describe("Extracted text content from the identity document"),
|
|
3724
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3725
|
+
model: z.enum(["pro", "max"]).describe("Model tier used to parse the identity document"),
|
|
3726
|
+
documentType: z.string().optional().describe("Detected identity document type (e.g., passport, driver's license)"),
|
|
3727
|
+
html: z.string().optional().describe("Full HTML representation of the document content. Only available when using the 'max' model. Preserves rich formatting, tables, selection marks, and visual layout that cannot be fully represented in markdown."),
|
|
3728
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: pro=6, max=10."),
|
|
3729
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3730
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3731
|
+
});
|
|
3732
|
+
const requestExamples$3 = {
|
|
3733
|
+
"Parse from URL": {
|
|
3734
|
+
summary: "Parse from URL",
|
|
3735
|
+
value: { url: "https://example.com/identity-document.pdf" }
|
|
3736
|
+
},
|
|
3737
|
+
"Parse from base64": {
|
|
3738
|
+
summary: "Parse from base64",
|
|
3739
|
+
value: { base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==" }
|
|
3740
|
+
},
|
|
3741
|
+
"Parse from file upload": {
|
|
3742
|
+
summary: "Parse from file upload",
|
|
3743
|
+
value: { file: "(binary)" }
|
|
3744
|
+
}
|
|
3745
|
+
};
|
|
3746
|
+
const parse$1 = oc.route({
|
|
3747
|
+
summary: "Parse an identity document",
|
|
3748
|
+
description: `Extract text and structured data from an identity document. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3749
|
+
tags: ["Identity"],
|
|
3750
|
+
spec: (op) => {
|
|
3751
|
+
const spec = getDefaultSpec$1(op, requestExamples$3);
|
|
3752
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("identity-parse");
|
|
3753
|
+
return spec;
|
|
3754
|
+
}
|
|
3755
|
+
}).input(parseInputSchema$1).output(parseOutputSchema$1);
|
|
3756
|
+
// ../util/lib/contract/instance/router/identity/index.ts
|
|
3757
|
+
var identity_exports = /* @__PURE__ */ __exportAll({
|
|
3758
|
+
ask: () => ask$1,
|
|
3759
|
+
extract: () => extract$1,
|
|
3760
|
+
parse: () => parse$1
|
|
3761
|
+
});
|
|
3762
|
+
// ../util/lib/contract/instance/router/invoice/get-default-spec.ts
|
|
3763
|
+
function getDefaultSpec(op, requestExamples) {
|
|
3764
|
+
op["security"] = [{ bearerAuth: [] }];
|
|
3765
|
+
const params = op["parameters"] ?? [];
|
|
3766
|
+
params.push({
|
|
3767
|
+
name: "x-pdfvector-document-id",
|
|
3768
|
+
in: "header",
|
|
3769
|
+
required: false,
|
|
3770
|
+
schema: {
|
|
3771
|
+
type: "string",
|
|
3772
|
+
default: "my-doc-123"
|
|
3773
|
+
},
|
|
3774
|
+
description: "Optional document ID to associate with this request. Returned in the response and saved for usage tracking."
|
|
3775
|
+
});
|
|
3776
|
+
op["parameters"] = params;
|
|
3777
|
+
const reqBody = op["requestBody"];
|
|
3778
|
+
if (reqBody?.content) for (const mediaType of Object.values(reqBody.content)) mediaType["examples"] = requestExamples;
|
|
3779
|
+
return op;
|
|
3780
|
+
}
|
|
3781
|
+
// ../util/lib/contract/instance/router/invoice/ask.ts
|
|
3782
|
+
const specializedModelSchema$1 = z.enum(["auto", ...pdfvectorModelSchema.options]).default("auto");
|
|
3783
|
+
const askInputSchema = z.object({
|
|
3784
|
+
url: fetchableUrlSchema.optional().describe("URL of the invoice file to fetch and parse"),
|
|
3785
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Invoice file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3786
|
+
base64: z.string().optional().describe("Base64-encoded invoice file content"),
|
|
3787
|
+
question: z.string().min(4, "question must be at least 4 characters").describe("The question to answer about the invoice"),
|
|
3788
|
+
model: specializedModelSchema$1.describe(specializedAskModelDescription),
|
|
3789
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3790
|
+
callback: z.object({
|
|
3791
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3792
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3793
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3794
|
+
});
|
|
3795
|
+
const askOutputSchema = z.object({
|
|
3796
|
+
markdown: z.string().describe("The answer to the question"),
|
|
3797
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3798
|
+
model: pdfvectorModelSchema.describe(outputAskModelDescription),
|
|
3799
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=6, mini=10, pro=14, max=18."),
|
|
3800
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3801
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3802
|
+
});
|
|
3803
|
+
const requestExamples$2 = { "Ask from URL": {
|
|
3804
|
+
summary: "Ask from URL",
|
|
3805
|
+
value: {
|
|
3806
|
+
url: "https://example.com/invoice.pdf",
|
|
3807
|
+
question: "What is the total amount on this invoice?"
|
|
3808
|
+
}
|
|
3809
|
+
} };
|
|
3810
|
+
const ask = oc.route({
|
|
3811
|
+
summary: "Ask a question about an invoice",
|
|
3812
|
+
description: `Parse an invoice and answer a question about its content using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3813
|
+
tags: ["Invoice"],
|
|
3814
|
+
spec: (op) => {
|
|
3815
|
+
const spec = getDefaultSpec(op, requestExamples$2);
|
|
3816
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("invoice-ask");
|
|
3817
|
+
return spec;
|
|
3818
|
+
}
|
|
3819
|
+
}).input(askInputSchema).output(askOutputSchema);
|
|
3820
|
+
// ../util/lib/contract/instance/router/invoice/extract.ts
|
|
3821
|
+
const specializedModelSchema = z.enum(["auto", ...pdfvectorModelSchema.options]).default("auto");
|
|
3822
|
+
const extractInputSchema = z.object({
|
|
3823
|
+
url: fetchableUrlSchema.optional().describe("URL of the invoice file to fetch and parse"),
|
|
3824
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Invoice file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3825
|
+
base64: z.string().optional().describe("Base64-encoded invoice file content"),
|
|
3826
|
+
prompt: z.string().min(4, "prompt must be at least 4 characters").describe("The prompt instructing the AI how to extract data from the invoice"),
|
|
3827
|
+
schema: jsonSchemaInput.describe("JSON Schema describing the structure of the data to extract from the invoice. Can be a JSON object or a JSON string."),
|
|
3828
|
+
model: specializedModelSchema.describe(specializedExtractModelDescription),
|
|
3829
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3830
|
+
callback: z.object({
|
|
3831
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3832
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3833
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3834
|
+
});
|
|
3835
|
+
const extractOutputSchema = z.object({
|
|
3836
|
+
data: z.unknown().refine((val) => val != null && (typeof val !== "object" || Object.keys(val).length > 0), { message: "Extracted data must not be empty" }).describe("Extracted structured data matching the provided JSON Schema"),
|
|
3837
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3838
|
+
model: pdfvectorModelSchema.describe(outputExtractModelDescription),
|
|
3839
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: nano=6, mini=10, pro=14, max=18."),
|
|
3840
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3841
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3842
|
+
});
|
|
3843
|
+
const requestExamples$1 = { "Extract from URL": {
|
|
3844
|
+
summary: "Extract from URL",
|
|
3845
|
+
value: {
|
|
3846
|
+
url: "https://example.com/invoice.pdf",
|
|
3847
|
+
prompt: "Extract the vendor name, total amount, and line items",
|
|
3848
|
+
schema: JSON.stringify({
|
|
3849
|
+
type: "object",
|
|
3850
|
+
properties: {
|
|
3851
|
+
vendorName: { type: "string" },
|
|
3852
|
+
totalAmount: { type: "number" },
|
|
3853
|
+
lineItems: {
|
|
3854
|
+
type: "array",
|
|
3855
|
+
items: {
|
|
3856
|
+
type: "object",
|
|
3857
|
+
properties: {
|
|
3858
|
+
description: { type: "string" },
|
|
3859
|
+
amount: { type: "number" }
|
|
3860
|
+
}
|
|
3861
|
+
}
|
|
3862
|
+
}
|
|
3863
|
+
},
|
|
3864
|
+
required: ["vendorName", "totalAmount"]
|
|
3865
|
+
})
|
|
3866
|
+
}
|
|
3867
|
+
} };
|
|
3868
|
+
const extract = oc.route({
|
|
3869
|
+
summary: "Extract structured data from an invoice",
|
|
3870
|
+
description: `Parse an invoice and extract structured data matching a provided JSON Schema using AI. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3871
|
+
tags: ["Invoice"],
|
|
3872
|
+
spec: (op) => {
|
|
3873
|
+
const spec = getDefaultSpec(op, requestExamples$1);
|
|
3874
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("invoice-extract");
|
|
3875
|
+
return spec;
|
|
3876
|
+
}
|
|
3877
|
+
}).input(extractInputSchema).output(extractOutputSchema);
|
|
3878
|
+
// ../util/lib/contract/instance/router/invoice/parse.ts
|
|
3879
|
+
const specializedParseModelSchema = z.enum([
|
|
3880
|
+
"pro",
|
|
3881
|
+
"max",
|
|
3882
|
+
"auto"
|
|
3883
|
+
], { message: "model must be one of: pro, max, auto" }).default("auto");
|
|
3884
|
+
const parseInputSchema = z.object({
|
|
3885
|
+
url: fetchableUrlSchema.optional().describe("URL of the invoice file to fetch and parse"),
|
|
3886
|
+
file: z.file().mime([...supportedFileMimes], supportedFileMimeErrorMessage).optional().describe(`Invoice file upload via multipart form-data (${supportedFileFormatsDescription})`),
|
|
3887
|
+
base64: z.string().optional().describe("Base64-encoded invoice file content"),
|
|
3888
|
+
model: specializedParseModelSchema.describe(specializedParseModelDescription("invoice")),
|
|
3889
|
+
documentId: z.string().trim().min(1).max(512).optional().describe("Optional external document ID for usage attribution. The x-pdfvector-document-id header takes precedence when both are provided."),
|
|
3890
|
+
callback: z.object({
|
|
3891
|
+
url: fetchableUrlSchema.describe("Webhook URL where results will be POSTed when processing completes"),
|
|
3892
|
+
type: z.string().optional().describe("Callback type identifier (e.g. 'zapier')")
|
|
3893
|
+
}).optional().describe("Optional webhook callback for async processing. When provided, the server returns 202 immediately and POSTs the full response payload to the callback URL when processing completes. On error, the callback receives a POST with X-Pdfvector-Callback-Failed: true header and error details in the body. Useful for long-running operations that may exceed client timeout limits.")
|
|
3894
|
+
});
|
|
3895
|
+
const parseOutputSchema = z.object({
|
|
3896
|
+
markdown: z.string().describe("Extracted text content from the invoice"),
|
|
3897
|
+
pageCount: z.number().int().describe("Total number of pages in the document"),
|
|
3898
|
+
model: z.enum(["pro", "max"]).describe("Model tier used to parse the invoice"),
|
|
3899
|
+
credits: z.number().int().describe("Number of credits consumed by this API call. Cost per page: pro=6, max=10."),
|
|
3900
|
+
requestId: z.number().int().describe("Unique request identifier for this API call"),
|
|
3901
|
+
html: z.string().optional().describe("Full HTML representation of the document content. Only available when using the 'max' model. Preserves rich formatting, tables, selection marks, and visual layout that cannot be fully represented in markdown."),
|
|
3902
|
+
documentId: z.string().optional().describe("Document ID if provided via x-pdfvector-document-id header or request body")
|
|
3903
|
+
});
|
|
3904
|
+
const requestExamples = {
|
|
3905
|
+
"Parse from URL": {
|
|
3906
|
+
summary: "Parse from URL",
|
|
3907
|
+
value: { url: "https://example.com/invoice.pdf" }
|
|
3908
|
+
},
|
|
3909
|
+
"Parse from base64": {
|
|
3910
|
+
summary: "Parse from base64",
|
|
3911
|
+
value: { base64: "JVBERi0xLjAKMSAwIG9iajw8L1R5cGUvQ2F0YWxvZy9QYWdlcyAyIDAgUj4+ZW5kb2JqIDIgMCBvYmo8PC9UeXBlL1BhZ2VzL0tpZHNbMyAwIFJdL0NvdW50IDE+PmVuZG9iaiAzIDAgb2JqPDwvVHlwZS9QYWdlL01lZGlhQm94WzAgMCAzIDNdL1BhcmVudCAyIDAgUj4+ZW5kb2JqCnhyZWYKMCA0CjAwMDAwMDAwMDAgNjU1MzUgZiAKMDAwMDAwMDAwOSAwMDAwMCBuIAowMDAwMDAwMDU4IDAwMDAwIG4gCjAwMDAwMDAxMTUgMDAwMDAgbiAKdHJhaWxlcjw8L1NpemUgNC9Sb290IDEgMCBSPj4Kc3RhcnR4cmVmCjE5MAolJUVPRg==" }
|
|
3912
|
+
},
|
|
3913
|
+
"Parse from file upload": {
|
|
3914
|
+
summary: "Parse from file upload",
|
|
3915
|
+
value: { file: "(binary)" }
|
|
3916
|
+
}
|
|
3917
|
+
};
|
|
3918
|
+
const parse = oc.route({
|
|
3919
|
+
summary: "Parse an invoice",
|
|
3920
|
+
description: `Extract text and structured data from an invoice. Supports ${supportedFileTypesLong}. Provide the document via file upload, a public URL, or a base64-encoded string.`,
|
|
3921
|
+
tags: ["Invoice"],
|
|
3922
|
+
spec: (op) => {
|
|
3923
|
+
const spec = getDefaultSpec(op, requestExamples);
|
|
3924
|
+
spec["x-codeSamples"] = getOpenApiCodeSamples("invoice-parse");
|
|
3925
|
+
return spec;
|
|
3926
|
+
}
|
|
3927
|
+
}).input(parseInputSchema).output(parseOutputSchema);
|
|
3928
|
+
// ../util/lib/contract/instance/router/invoice/index.ts
|
|
3929
|
+
var invoice_exports = /* @__PURE__ */ __exportAll({
|
|
3930
|
+
ask: () => ask,
|
|
3931
|
+
extract: () => extract,
|
|
3932
|
+
parse: () => parse
|
|
3933
|
+
});
|
|
3934
|
+
// ../util/lib/contract/instance/router/index.ts
|
|
3935
|
+
var router_exports = /* @__PURE__ */ __exportAll({
|
|
3936
|
+
academic: () => academic_exports,
|
|
3937
|
+
admin: () => admin_exports,
|
|
3938
|
+
authenticate: () => authenticate_exports,
|
|
3939
|
+
bankStatement: () => bankStatement_exports,
|
|
3940
|
+
document: () => document_exports,
|
|
3941
|
+
free: () => free_exports,
|
|
3942
|
+
identity: () => identity_exports,
|
|
3943
|
+
invoice: () => invoice_exports
|
|
3944
|
+
});
|
|
3945
|
+
export { router_exports as contract, pdfvectorModelSchema };
|