SDK API Reference
Auto-generated TypeScript API reference for @cleverrouter/sdk. Source of truth is the JSDoc in packages/sdk/src.
Auto-generated
Diese Seite wird aus den JSDoc-Kommentaren in packages/sdk/src/ via TypeDoc
generiert. Bitte nicht direkt editieren — Updates am Code aendern automatisch
diese Seite beim naechsten bun run docs:api.
@cleverrouter/sdk
Classes
CleverRouter
Defined in: packages/sdk/src/index.ts:212
Constructors
Constructor
new CleverRouter(config): CleverRouter;Defined in: packages/sdk/src/index.ts:226
Parameters
| Parameter | Type |
|---|---|
config | CleverRouterConfig |
Returns
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
<a id="cache"></a> cache | readonly | TrackedCache | null | packages/sdk/src/index.ts:218 |
<a id="config"></a> config | readonly | Required<Pick<CleverRouterConfig, "apiKey" | "baseURL">> & Omit<CleverRouterConfig, "apiKey" | "baseURL"> | packages/sdk/src/index.ts:213 |
<a id="defaulttimeoutms"></a> defaultTimeoutMs | readonly | number | packages/sdk/src/index.ts:216 |
<a id="retry"></a> retry | readonly | RetryConfig | null | packages/sdk/src/index.ts:215 |
<a id="telemetry"></a> telemetry | readonly | TelemetryReporter | packages/sdk/src/index.ts:217 |
Accessors
batches
Get Signature
get batches(): object;Defined in: packages/sdk/src/index.ts:646
Batches-Namespace — Async-Batch-Inference. JSONL-Input via files.create(),
dann hier batches.create() aufrufen. getOutput() ist ein AsyncIterable
pro JSONL-Zeile.
Example
const batch = await cr.batches.create({
input_file_id: f.id,
endpoint: '/v1/chat/completions',
completion_window: '24h',
});
for await (const row of cr.batches.getOutput(batch.id)) {
console.log(row.custom_id, row.response?.body);
}Returns
| Name | Type | Description | Defined in |
|---|---|---|---|
cancel() | (id, opts?) => Promise<BatchObject> | - | packages/sdk/src/index.ts:674 |
create() | (opts) => Promise<BatchObject> | - | packages/sdk/src/index.ts:649 |
getOutput() | (id, opts?) => AsyncIterable<T> | Streamt das Output-File als JSONL-Iterator. Wirft CRError wenn der Batch noch nicht completed ist (409) oder kein Output-File hat. | packages/sdk/src/index.ts:686 |
list() | (opts?) => Promise<BatchList> | - | packages/sdk/src/index.ts:660 |
retrieve() | (id, opts?) => Promise<BatchObject> | - | packages/sdk/src/index.ts:667 |
files
Get Signature
get files(): object;Defined in: packages/sdk/src/index.ts:582
Files-Namespace — Upload/Download/Delete fuer Batch-Inference-Inputs.
Example
const f = await cr.files.create({ name: 'in.jsonl', type: 'application/jsonl', data: jsonlBuffer });
const batch = await cr.batches.create({ input_file_id: f.id, endpoint: '/v1/chat/completions' });Returns
object
| Name | Type | Defined in |
|---|---|---|
content() | (id, opts?) => Promise<Response> | packages/sdk/src/index.ts:610 |
create() | (input, opts?) => Promise<FileObject> | packages/sdk/src/index.ts:585 |
delete() | (id, opts?) => Promise<{ deleted: true; id: string; }> | packages/sdk/src/index.ts:618 |
list() | (opts?) => Promise<FileList> | packages/sdk/src/index.ts:595 |
retrieve() | (id, opts?) => Promise<FileObject> | packages/sdk/src/index.ts:603 |
webhooks
Get Signature
get webhooks(): object;Defined in: packages/sdk/src/index.ts:710
Webhooks-Namespace — Stripe-Style Webhook-Registry fuer Batch-Events.
Example
const hook = await cr.webhooks.create({ url: 'https://app.example/hook', events: ['batch.completed'] });
console.log(hook.secret); // einmalig — sicher speichernReturns
object
| Name | Type | Defined in |
|---|---|---|
create() | (opts) => Promise<WebhookObject> | packages/sdk/src/index.ts:720 |
list() | (opts?) => Promise<WebhookList> | packages/sdk/src/index.ts:713 |
retrieve() | (id, opts?) => Promise<WebhookObject> | packages/sdk/src/index.ts:731 |
revoke() | (id, opts?) => Promise<{ deleted: true; id: string; }> | packages/sdk/src/index.ts:738 |
test() | (id, opts?) => Promise<{ delivered: boolean; id: string; response_status: number | null; }> | packages/sdk/src/index.ts:746 |
Methods
chat()
chat(req, opts?): Promise<ChatCompletionResponse>;Defined in: packages/sdk/src/index.ts:402
Chat-Completion (non-stream) via direkten Gateway-Call.
Fuer Tools+Vision+Reasoning weiterhin cr.openai() empfohlen, dieser
Helper ist fuer typed Quickshots ohne OpenAI-SDK-Dependency.
Parameters
| Parameter | Type | Description |
|---|---|---|
req | ChatCompletionRequest | Chat-Request mit model + messages. |
opts? | RequestOptions | Provider-Pin, Strategy, AbortSignal, Timeout. |
Returns
Promise<ChatCompletionResponse>
Vollstaendige Chat-Completion-Response.
Throws
Subtypen je nach Gateway-Status.
Example
const res = await cr.chat({
model: 'mistral/mistral-small-3.2',
messages: [{ role: 'user', content: 'Hi.' }],
});
console.log(res.choices[0].message.content);embed()
embed(input, opts?): Promise<EmbeddingResponse>;Defined in: packages/sdk/src/index.ts:471
Typed Embedding-Call. Default-Model: cohere/embed-v4.
Parameters
| Parameter | Type | Description |
|---|---|---|
input | string | string[] | Einzelner String oder Batch (string[]). |
opts | EmbeddingOpts & RequestOptions | Modell, encoding_format, dimensions, plus RequestOptions. |
Returns
Promise<EmbeddingResponse>
Embedding-Response (Vektor pro Input).
Throws
Subtypen je nach Gateway-Status.
Example
const res = await cr.embed(['hello', 'world'], {
model: 'cohere/embed-v4',
encoding_format: 'float',
});headers()
headers(opts?): Record<string, string>;Defined in: packages/sdk/src/index.ts:329
Headers für einen einzelnen Request (Provider-Pin, Strategy).
Parameters
| Parameter | Type |
|---|---|
opts? | RequestOptions |
Returns
Record<string, string>
listModels()
listModels(opts?): Promise<ModelInfo[]>;Defined in: packages/sdk/src/index.ts:360
Holt das Live-Modell-Verzeichnis vom Gateway.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts? | object & RequestOptions | Filter { kind } plus optional signal, timeoutMs, provider, strategy. |
Returns
Promise<ModelInfo[]>
Liste der verfuegbaren Modelle.
Throws
401 — Key fehlt/ungueltig.
Throws
429 — Rate-Limit ueberschritten.
Throws
502/503 — Gateway oder Upstream down.
Throws
408 — Client-Timeout.
Example
const embeddings = await cr.listModels({ kind: 'embedding' });
console.log(embeddings.map((m) => m.id));model()
model<M>(id): M;Defined in: packages/sdk/src/index.ts:302
Typed Modell-Liste — gibt einen string zurueck, der vom Gateway erkannt wird.
Type Parameters
| Type Parameter |
|---|
M extends CleverRouterModel |
Parameters
| Parameter | Type |
|---|---|
id | M |
Returns
M
modelsByClass()
modelsByClass(klass): readonly CleverRouterModel[];Defined in: packages/sdk/src/index.ts:324
Liefert alle Modelle einer Klasse als Liste.
Parameters
| Parameter | Type |
|---|---|
klass | ModelClass |
Returns
readonly CleverRouterModel[]
openai()
openai(overrides?): OpenAI;Defined in: packages/sdk/src/index.ts:284
Erzeugt einen OpenAI-SDK-Client der gegen CleverRouter spricht.
Provider-Pin und Strategy aus der Client-Config werden als
defaultHeaders durchgereicht; pro Call ueberschreibbar via overrides.
Parameters
| Parameter | Type | Description |
|---|---|---|
overrides? | Partial<ClientOptions> & object | Optionale OpenAI-Client-Optionen plus provider/strategy-Shortcut. |
Returns
OpenAI
Ein vorkonfigurierter OpenAI-Client.
Example
const completion = await cr.openai().chat.completions.create({
model: 'mistral/mistral-small-3.2',
messages: [{ role: 'user', content: 'Hi.' }],
});pickByClass()
pickByClass(klass): CleverRouterModel;Defined in: packages/sdk/src/index.ts:312
Wahl-Helper fuer Modell-Klassen. Erste Wahl pro Klasse.
Parameters
| Parameter | Type | Description |
|---|---|---|
klass | ModelClass | Eine ModelClass. Erlaubte Werte siehe MODEL_CLASSES. |
Returns
Throws
wenn die Klasse unbekannt ist — Message listet die existierenden Klassen.
rerank()
rerank(opts): Promise<RerankResponse>;Defined in: packages/sdk/src/index.ts:523
Typed Rerank-Call. Default-Model: cohere/rerank-v3-5.
Parameters
| Parameter | Type | Description |
|---|---|---|
opts | RerankOpts & RequestOptions | query, documents, top_n, optional Modell + RequestOptions. |
Returns
Promise<RerankResponse>
Rerank-Response mit sortierten Indizes + relevance_score.
Throws
400 — query oder documents leer / top_n invalide.
Throws
Andere Gateway-Status.
Example
const res = await cr.rerank({
query: 'EU GDPR',
documents: ['a', 'b', 'c'],
top_n: 2,
});resetStats()
resetStats(): void;Defined in: packages/sdk/src/index.ts:786
Setzt die internen Counter zurueck (Tests + Bench-Runs).
Returns
void
stats()
stats(): object;Defined in: packages/sdk/src/index.ts:775
Aggregierte Counter ueber Cache-Hits/Misses, Total-Calls und ungefaehre gesparte Kosten durch den Embeddings-Cache.
costSaved ist eine Schaetzung (0.05 EUR / 1k tokens, 1 Token ≈ 4 chars).
Wenn kein Cache konfiguriert ist, sind cacheHits/cacheMisses = 0.
Returns
object
| Name | Type | Defined in |
|---|---|---|
cacheHits | number | packages/sdk/src/index.ts:775 |
cacheMisses | number | packages/sdk/src/index.ts:775 |
costSaved | number | packages/sdk/src/index.ts:775 |
totalRequests | number | packages/sdk/src/index.ts:775 |
Example
const cr = createCleverRouter({ apiKey, cache: { embeddings: { ttlSec: 86400 } } });
await cr.embed(['hi', 'hi']);
console.log(cr.stats()); // { cacheHits: 1, cacheMisses: 1, totalRequests: 2, costSaved: 0.000... }stream()
stream(req, opts?): AsyncIterable<ChatStreamChunk>;Defined in: packages/sdk/src/index.ts:433
Streaming-Chat — AsyncIterable<ChatStreamChunk> mit Reconnect-on-Drop.
Reconnect-Versuche: bis zu 2, mit Last-Event-ID-Header.
Parameters
| Parameter | Type | Description |
|---|---|---|
req | StreamOpts | Chat-Request (Stream wird intern erzwungen). |
opts? | RequestOptions | Provider-Pin, Strategy, AbortSignal. |
Returns
AsyncIterable<ChatStreamChunk>
AsyncIterable von Chat-Stream-Chunks.
Throws
Wenn der Initial-Request fehlschlaegt; im Iterator selber bei abruptem EOF.
Example
const stream = cr.stream({
model: 'mistral/mistral-small-3.2',
messages: [{ role: 'user', content: 'Stream a haiku.' }],
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? '');
}transcribe()
transcribe(file, opts?): Promise<TranscriptionResponse>;Defined in: packages/sdk/src/index.ts:555
Typed Audio-Transcription. Default-Model: systran/faster-whisper-large-v3.
Akzeptiert File, Blob oder { name, type, data } mit ArrayBuffer | Uint8Array | Blob.
Parameters
| Parameter | Type | Description |
|---|---|---|
file | TranscribeInput | Audio-Input. |
opts | TranscribeOpts & RequestOptions | Sprache, response_format, timestamp_granularities + RequestOptions. |
Returns
Promise<TranscriptionResponse>
Transkription je nach response_format (JSON, verbose JSON, plain text).
Throws
Subtypen je nach Gateway-Status.
Example
import { readFileSync } from 'node:fs';
const res = await cr.transcribe(
{ name: 'audio.mp3', type: 'audio/mpeg', data: readFileSync('./audio.mp3') },
{ language: 'en', response_format: 'verbose_json' },
);CRAuthError
Defined in: packages/sdk/src/errors.ts:29
401 — API-Key ungueltig oder fehlt.
Extends
Constructors
Constructor
new CRAuthError(
message,
code?,
requestId?): CRAuthError;Defined in: packages/sdk/src/errors.ts:30
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
code | string | 'unauthorized' |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="stack"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
CRBudgetExceededError
Defined in: packages/sdk/src/errors.ts:64
402 — Budget des Workspaces ueberschritten.
Extends
Constructors
Constructor
new CRBudgetExceededError(
message,
code?,
requestId?): CRBudgetExceededError;Defined in: packages/sdk/src/errors.ts:65
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
code | string | 'budget_exceeded' |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-1"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-1"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message-1"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-1"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-1"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="stack-1"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-1"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit-1"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
CRError
Defined in: packages/sdk/src/errors.ts:9
Basis-Error fuer alle CleverRouter-spezifischen Fehler.
Extends
Error
Extended by
CRAuthErrorCRRateLimitErrorCRModelNotFoundErrorCRModelDeprecatedErrorCRBudgetExceededErrorCRProviderDownErrorCRValidationErrorCRTimeoutError
Constructors
Constructor
new CRError(
message,
status,
code,
requestId?): CRError;Defined in: packages/sdk/src/errors.ts:14
Parameters
| Parameter | Type |
|---|---|
message | string |
status | number |
code | string |
requestId? | string |
Returns
Overrides
Error.constructorProperties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-2"></a> cause? | public | unknown | The cause of the error. | Error.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-2"></a> code | public | string | - | - | packages/sdk/src/errors.ts:11 |
<a id="message-2"></a> message | public | string | - | Error.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-2"></a> name | public | string | - | Error.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-2"></a> requestId? | public | string | - | - | packages/sdk/src/errors.ts:12 |
<a id="stack-2"></a> stack? | public | string | - | Error.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-2"></a> status | public | number | - | - | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit-2"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | Error.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceCall Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceCall Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceCall Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Error.captureStackTraceisError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Error.isErrorCall Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Error.isErrorprepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTraceCall Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Error.prepareStackTraceCRModelDeprecatedError
Defined in: packages/sdk/src/errors.ts:56
410 — Modell wurde deprecated und ist abgeschaltet.
Extends
Constructors
Constructor
new CRModelDeprecatedError(
message,
code?,
requestId?): CRModelDeprecatedError;Defined in: packages/sdk/src/errors.ts:57
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
code | string | 'model_deprecated' |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-3"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-3"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message-3"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-3"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-3"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="stack-3"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-3"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit-3"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
CRModelNotFoundError
Defined in: packages/sdk/src/errors.ts:48
404 — Modell-ID unbekannt.
Extends
Constructors
Constructor
new CRModelNotFoundError(
message,
code?,
requestId?): CRModelNotFoundError;Defined in: packages/sdk/src/errors.ts:49
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
code | string | 'model_not_found' |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-4"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-4"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message-4"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-4"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-4"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="stack-4"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-4"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit-4"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
CRProviderDownError
Defined in: packages/sdk/src/errors.ts:72
502/503/504 — Upstream-Provider antwortet nicht oder Gateway-Timeout.
Extends
Constructors
Constructor
new CRProviderDownError(
message,
status?,
code?,
requestId?): CRProviderDownError;Defined in: packages/sdk/src/errors.ts:73
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
status | 502 | 503 | 504 | 502 |
code | string | 'provider_down' |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-5"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-5"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message-5"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-5"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-5"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="stack-5"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-5"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit-5"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
CRRateLimitError
Defined in: packages/sdk/src/errors.ts:37
429 — Rate-Limit erreicht. retryAfterSec falls Header gesetzt war.
Extends
Constructors
Constructor
new CRRateLimitError(
message,
code?,
retryAfterSec?,
requestId?): CRRateLimitError;Defined in: packages/sdk/src/errors.ts:40
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
code | string | 'rate_limit_exceeded' |
retryAfterSec? | number | undefined |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-6"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-6"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message-6"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-6"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-6"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="retryaftersec"></a> retryAfterSec? | public | number | - | - | packages/sdk/src/errors.ts:38 |
<a id="stack-6"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-6"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit-6"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
CRTimeoutError
Defined in: packages/sdk/src/errors.ts:88
Request hat das Timeout ueberschritten (clientseitig via AbortController).
Extends
Constructors
Constructor
new CRTimeoutError(
message,
timeoutMs,
code?,
requestId?): CRTimeoutError;Defined in: packages/sdk/src/errors.ts:90
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
timeoutMs | number | undefined |
code | string | 'timeout' |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-7"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-7"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message-7"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-7"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-7"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="stack-7"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-7"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="timeoutms"></a> timeoutMs | public | number | - | - | packages/sdk/src/errors.ts:89 |
<a id="stacktracelimit-7"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
CRValidationError
Defined in: packages/sdk/src/errors.ts:80
400 — Request-Body ist ungueltig.
Extends
Constructors
Constructor
new CRValidationError(
message,
code?,
requestId?): CRValidationError;Defined in: packages/sdk/src/errors.ts:81
Parameters
| Parameter | Type | Default value |
|---|---|---|
message | string | undefined |
code | string | 'validation_error' |
requestId? | string | undefined |
Returns
Overrides
Properties
| Property | Modifier | Type | Description | Inherited from | Defined in |
|---|---|---|---|---|---|
<a id="cause-8"></a> cause? | public | unknown | The cause of the error. | CRError.cause | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es2022.error.d.ts:26 |
<a id="code-8"></a> code | public | string | - | CRError.code | packages/sdk/src/errors.ts:11 |
<a id="message-8"></a> message | public | string | - | CRError.message | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1077 |
<a id="name-8"></a> name | public | string | - | CRError.name | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1076 |
<a id="requestid-8"></a> requestId? | public | string | - | CRError.requestId | packages/sdk/src/errors.ts:12 |
<a id="stack-8"></a> stack? | public | string | - | CRError.stack | node_modules/.bun/typescript@5.9.3/node_modules/typescript/lib/lib.es5.d.ts:1078 |
<a id="status-8"></a> status | public | number | - | CRError.status | packages/sdk/src/errors.ts:10 |
<a id="stacktracelimit-8"></a> stackTraceLimit | static | number | The Error.stackTraceLimit property specifies the number of stack frames collected by a stack trace (whether generated by new Error().stack or Error.captureStackTrace(obj)). The default value is 10 but may be set to any valid JavaScript number. Changes will affect any stack trace captured after the value has been changed. If set to a non-number value, or set to a negative number, stack traces will not capture any frames. | CRError.stackTraceLimit | node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:68 |
Methods
captureStackTrace()
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:52
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1042
Create .stack property on a target object
Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
Call Signature
static captureStackTrace(targetObject, constructorOpt?): void;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:51
Creates a .stack property on targetObject, which when accessed returns
a string representing the location in the code at which
Error.captureStackTrace() was called.
const myObject = {};
Error.captureStackTrace(myObject);
myObject.stack; // Similar to `new Error().stack`The first line of the trace will be prefixed with
${myObject.name}: ${myObject.message}.
The optional constructorOpt argument accepts a function. If given, all frames
above constructorOpt, including constructorOpt, will be omitted from the
generated stack trace.
The constructorOpt argument is useful for hiding implementation
details of error generation from the user. For instance:
function a() {
b();
}
function b() {
c();
}
function c() {
// Create an error without stack trace to avoid calculating the stack trace twice.
const { stackTraceLimit } = Error;
Error.stackTraceLimit = 0;
const error = new Error();
Error.stackTraceLimit = stackTraceLimit;
// Capture the stack trace above function b
Error.captureStackTrace(error, b); // Neither function c, nor b is included in the stack trace
throw error;
}
a();Parameters
| Parameter | Type |
|---|---|
targetObject | object |
constructorOpt? | Function |
Returns
void
Inherited from
isError()
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.14/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
Call Signature
static isError(value): value is Error;Defined in: node_modules/.bun/bun-types@1.3.13/node_modules/bun-types/globals.d.ts:1037
Check if a value is an instance of Error
Parameters
| Parameter | Type | Description |
|---|---|---|
value | unknown | The value to check |
Returns
value is Error
True if the value is an instance of Error, false otherwise
Inherited from
prepareStackTrace()
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@20.19.40/node_modules/@types/node/globals.d.ts:56
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
Call Signature
static prepareStackTrace(err, stackTraces): any;Defined in: node_modules/.bun/@types+node@25.6.2/node_modules/@types/node/globals.d.ts:55
Parameters
| Parameter | Type |
|---|---|
err | Error |
stackTraces | CallSite[] |
Returns
any
See
https://v8.dev/docs/stack-trace-api#customizing-stack-traces
Inherited from
MemoryCache
Defined in: packages/sdk/src/cache.ts:54
In-Memory-Cache mit Lazy-Expiry. Pro Prozess. Kein Eviction-Limit — fuer SDK-Default ausreichend, weil Embedding-Inputs typischerweise < 10k unique Strings pro Prozess sind. Wer mehr braucht: RedisCache nutzen.
Implements
Constructors
Constructor
new MemoryCache(): MemoryCache;Returns
Methods
clear()
clear(): void;Defined in: packages/sdk/src/cache.ts:77
Test-Helper: alle Eintraege loeschen.
Returns
void
delete()
delete(key): Promise<void>;Defined in: packages/sdk/src/cache.ts:72
Loescht einen Eintrag.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<void>
Implementation of
get()
get(key): Promise<unknown>;Defined in: packages/sdk/src/cache.ts:57
Holt einen Wert. Liefert undefined bei Miss oder Ablauf.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<unknown>
Implementation of
set()
set(
key,
value,
ttlSec): Promise<void>;Defined in: packages/sdk/src/cache.ts:67
Schreibt einen Wert mit TTL (in Sekunden).
Parameters
| Parameter | Type |
|---|---|
key | string |
value | unknown |
ttlSec | number |
Returns
Promise<void>
Implementation of
size()
size(): number;Defined in: packages/sdk/src/cache.ts:82
Anzahl aktiver Eintraege (inkl. ggf. abgelaufener — Lazy-Expiry).
Returns
number
RedisCache
Defined in: packages/sdk/src/cache.ts:110
Implements
Constructors
Constructor
new RedisCache(redis, keyPrefix?): RedisCache;Defined in: packages/sdk/src/cache.ts:111
Parameters
| Parameter | Type | Default value |
|---|---|---|
redis | RedisLike | undefined |
keyPrefix | string | 'cleverrouter:cache:' |
Returns
Methods
delete()
delete(key): Promise<void>;Defined in: packages/sdk/src/cache.ts:138
Loescht einen Eintrag.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<void>
Implementation of
get()
get(key): Promise<unknown>;Defined in: packages/sdk/src/cache.ts:116
Holt einen Wert. Liefert undefined bei Miss oder Ablauf.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<unknown>
Implementation of
set()
set(
key,
value,
ttlSec): Promise<void>;Defined in: packages/sdk/src/cache.ts:126
Schreibt einen Wert mit TTL (in Sekunden).
Parameters
| Parameter | Type |
|---|---|
key | string |
value | unknown |
ttlSec | number |
Returns
Promise<void>
Implementation of
TrackedCache
Defined in: packages/sdk/src/cache.ts:147
Wrapper um einen CacheStore mit Stats-Tracking + per-Namespace-Trennung.
Vom Client intern gehalten — User sieht nur das via cr.stats().
Constructors
Constructor
new TrackedCache(cfg?): TrackedCache;Defined in: packages/sdk/src/cache.ts:153
Parameters
| Parameter | Type |
|---|---|
cfg? | CacheConfig |
Returns
Properties
| Property | Modifier | Type | Defined in |
|---|---|---|---|
<a id="embeddingsttl"></a> embeddingsTtl | readonly | number | packages/sdk/src/cache.ts:150 |
<a id="modelsttl"></a> modelsTtl | readonly | number | packages/sdk/src/cache.ts:151 |
<a id="store"></a> store | readonly | CacheStore | packages/sdk/src/cache.ts:149 |
Methods
get()
get<T>(namespace, key): Promise<T | undefined>;Defined in: packages/sdk/src/cache.ts:160
Liest aus dem Cache. Trackt Hit/Miss.
Type Parameters
| Type Parameter |
|---|
T |
Parameters
| Parameter | Type |
|---|---|
namespace | string |
key | string |
Returns
Promise<T | undefined>
getStats()
getStats(): CacheStats;Defined in: packages/sdk/src/cache.ts:178
Returns
resetStats()
resetStats(): void;Defined in: packages/sdk/src/cache.ts:182
Returns
void
set()
set(
namespace,
key,
value,
ttlSec): Promise<void>;Defined in: packages/sdk/src/cache.ts:172
Schreibt in den Cache. ttlSec=0 = no-op.
Parameters
| Parameter | Type |
|---|---|
namespace | string |
key | string |
value | unknown |
ttlSec | number |
Returns
Promise<void>
Interfaces
BatchList
Defined in: packages/sdk/src/batches.ts:49
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="data"></a> data | BatchObject[] | packages/sdk/src/batches.ts:51 |
<a id="object"></a> object | "list" | packages/sdk/src/batches.ts:50 |
BatchObject
Defined in: packages/sdk/src/batches.ts:25
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="cancelled_at"></a> cancelled_at | number | null | packages/sdk/src/batches.ts:45 |
<a id="completed_at"></a> completed_at | number | null | packages/sdk/src/batches.ts:42 |
<a id="completion_window"></a> completion_window | string | packages/sdk/src/batches.ts:33 |
<a id="created_at"></a> created_at | number | packages/sdk/src/batches.ts:39 |
<a id="endpoint"></a> endpoint | BatchEndpoint | packages/sdk/src/batches.ts:28 |
<a id="error_file_id"></a> error_file_id | string | null | packages/sdk/src/batches.ts:32 |
<a id="expired_at"></a> expired_at | number | null | packages/sdk/src/batches.ts:44 |
<a id="expires_at"></a> expires_at | number | packages/sdk/src/batches.ts:46 |
<a id="failed_at"></a> failed_at | number | null | packages/sdk/src/batches.ts:43 |
<a id="finalizing_at"></a> finalizing_at | number | null | packages/sdk/src/batches.ts:41 |
<a id="id"></a> id | string | packages/sdk/src/batches.ts:26 |
<a id="in_progress_at"></a> in_progress_at | number | null | packages/sdk/src/batches.ts:40 |
<a id="input_file_id"></a> input_file_id | string | packages/sdk/src/batches.ts:30 |
<a id="last_error"></a> last_error | string | null | packages/sdk/src/batches.ts:38 |
<a id="metadata"></a> metadata | Record<string, unknown> | null | packages/sdk/src/batches.ts:37 |
<a id="object-1"></a> object | "batch" | packages/sdk/src/batches.ts:27 |
<a id="output_file_id"></a> output_file_id | string | null | packages/sdk/src/batches.ts:31 |
<a id="provider"></a> provider | "bedrock" | "scaleway" | "tensorix" | packages/sdk/src/batches.ts:34 |
<a id="provider_job_id"></a> provider_job_id | string | null | packages/sdk/src/batches.ts:35 |
<a id="request_counts"></a> request_counts | BatchRequestCounts | packages/sdk/src/batches.ts:36 |
<a id="status-9"></a> status | BatchStatus | packages/sdk/src/batches.ts:29 |
BatchRequestCounts
Defined in: packages/sdk/src/batches.ts:19
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="completed"></a> completed | number | packages/sdk/src/batches.ts:21 |
<a id="failed"></a> failed | number | packages/sdk/src/batches.ts:22 |
<a id="total"></a> total | number | packages/sdk/src/batches.ts:20 |
CacheConfig
Defined in: packages/sdk/src/cache.ts:36
Konfig pro Endpoint-Typ. ttlSec = 0 deaktiviert den Cache fuer den Typ.
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="embeddings"></a> embeddings? | object | - | packages/sdk/src/cache.ts:37 |
embeddings.ttlSec | number | - | packages/sdk/src/cache.ts:37 |
<a id="models"></a> models? | object | Default: 6h (21600). 0 = aus. | packages/sdk/src/cache.ts:39 |
models.ttlSec | number | - | packages/sdk/src/cache.ts:39 |
<a id="store-1"></a> store? | CacheStore | Optional eigener Store. Default: MemoryCache(). | packages/sdk/src/cache.ts:41 |
CacheStats
Defined in: packages/sdk/src/cache.ts:27
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="hits"></a> hits | number | packages/sdk/src/cache.ts:28 |
<a id="misses"></a> misses | number | packages/sdk/src/cache.ts:29 |
<a id="sets"></a> sets | number | packages/sdk/src/cache.ts:30 |
CacheStore
Defined in: packages/sdk/src/cache.ts:18
Methods
delete()
delete(key): Promise<void>;Defined in: packages/sdk/src/cache.ts:24
Loescht einen Eintrag.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<void>
get()
get(key): Promise<unknown>;Defined in: packages/sdk/src/cache.ts:20
Holt einen Wert. Liefert undefined bei Miss oder Ablauf.
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<unknown>
set()
set(
key,
value,
ttlSec): Promise<void>;Defined in: packages/sdk/src/cache.ts:22
Schreibt einen Wert mit TTL (in Sekunden).
Parameters
| Parameter | Type |
|---|---|
key | string |
value | unknown |
ttlSec | number |
Returns
Promise<void>
ChatChoice
Defined in: packages/sdk/src/types.ts:63
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="finish_reason"></a> finish_reason | | string & object | "stop" | "length" | "tool_calls" | "content_filter" | null | packages/sdk/src/types.ts:66 |
<a id="index"></a> index | number | packages/sdk/src/types.ts:64 |
<a id="message-9"></a> message | ChatMessage | packages/sdk/src/types.ts:65 |
ChatCompletionRequest
Defined in: packages/sdk/src/types.ts:39
Indexable
[key: string]: unknownProperties
| Property | Type | Defined in |
|---|---|---|
<a id="max_tokens"></a> max_tokens? | number | packages/sdk/src/types.ts:44 |
<a id="messages"></a> messages | ChatMessage[] | packages/sdk/src/types.ts:41 |
<a id="model-1"></a> model | CleverRouterModel | packages/sdk/src/types.ts:40 |
<a id="n"></a> n? | number | packages/sdk/src/types.ts:45 |
<a id="response_format"></a> response_format? | object & Record<string, unknown> | packages/sdk/src/types.ts:50 |
<a id="seed"></a> seed? | number | packages/sdk/src/types.ts:51 |
<a id="stop"></a> stop? | string | string[] | packages/sdk/src/types.ts:46 |
<a id="stream-1"></a> stream? | boolean | packages/sdk/src/types.ts:47 |
<a id="temperature"></a> temperature? | number | packages/sdk/src/types.ts:42 |
<a id="tool_choice"></a> tool_choice? | | "auto" | "none" | "required" | { function: { name: string; }; type: "function"; } | packages/sdk/src/types.ts:49 |
<a id="tools"></a> tools? | ChatTool[] | packages/sdk/src/types.ts:48 |
<a id="top_p"></a> top_p? | number | packages/sdk/src/types.ts:43 |
<a id="user"></a> user? | string | packages/sdk/src/types.ts:52 |
ChatCompletionResponse
Defined in: packages/sdk/src/types.ts:69
Indexable
[key: string]: unknownProperties
| Property | Type | Defined in |
|---|---|---|
<a id="choices"></a> choices | ChatChoice[] | packages/sdk/src/types.ts:74 |
<a id="created"></a> created | number | packages/sdk/src/types.ts:72 |
<a id="id-1"></a> id | string | packages/sdk/src/types.ts:70 |
<a id="model-2"></a> model | string | packages/sdk/src/types.ts:73 |
<a id="object-2"></a> object | string & object | "chat.completion" | packages/sdk/src/types.ts:71 |
<a id="system_fingerprint"></a> system_fingerprint? | string | packages/sdk/src/types.ts:76 |
<a id="usage"></a> usage? | ChatUsage | packages/sdk/src/types.ts:75 |
ChatMessage
Defined in: packages/sdk/src/types.ts:8
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="content"></a> content | string | ChatMessageContentPart[] | - | packages/sdk/src/types.ts:10 |
<a id="name-9"></a> name? | string | - | packages/sdk/src/types.ts:11 |
<a id="reasoning_content"></a> reasoning_content? | string | Optional von Modellen wie deepseek-r1 / moonshot kimi-k2 — Chain-of-Thought. | packages/sdk/src/types.ts:15 |
<a id="role"></a> role | string & object | "user" | "system" | "assistant" | "tool" | - | packages/sdk/src/types.ts:9 |
<a id="tool_call_id"></a> tool_call_id? | string | - | packages/sdk/src/types.ts:12 |
<a id="tool_calls"></a> tool_calls? | ChatToolCall[] | - | packages/sdk/src/types.ts:13 |
ChatStreamChunk
Defined in: packages/sdk/src/types.ts:98
Indexable
[key: string]: unknownProperties
| Property | Type | Defined in |
|---|---|---|
<a id="choices-1"></a> choices | ChatStreamChoice[] | packages/sdk/src/types.ts:103 |
<a id="created-1"></a> created | number | packages/sdk/src/types.ts:101 |
<a id="id-2"></a> id | string | packages/sdk/src/types.ts:99 |
<a id="model-3"></a> model | string | packages/sdk/src/types.ts:102 |
<a id="object-3"></a> object | string & object | "chat.completion.chunk" | packages/sdk/src/types.ts:100 |
<a id="usage-1"></a> usage? | ChatUsage | packages/sdk/src/types.ts:104 |
ChatTool
Defined in: packages/sdk/src/types.ts:30
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="function"></a> function | object | packages/sdk/src/types.ts:32 |
function.description? | string | packages/sdk/src/types.ts:34 |
function.name | string | packages/sdk/src/types.ts:33 |
function.parameters? | Record<string, unknown> | packages/sdk/src/types.ts:35 |
<a id="type"></a> type | "function" | packages/sdk/src/types.ts:31 |
ChatToolCall
Defined in: packages/sdk/src/types.ts:24
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="function-1"></a> function | object | packages/sdk/src/types.ts:27 |
function.arguments | string | packages/sdk/src/types.ts:27 |
function.name | string | packages/sdk/src/types.ts:27 |
<a id="id-3"></a> id | string | packages/sdk/src/types.ts:25 |
<a id="type-1"></a> type | "function" | string & object | packages/sdk/src/types.ts:26 |
ChatUsage
Defined in: packages/sdk/src/types.ts:56
Indexable
[key: string]: unknownProperties
| Property | Type | Defined in |
|---|---|---|
<a id="completion_tokens"></a> completion_tokens | number | packages/sdk/src/types.ts:58 |
<a id="prompt_tokens"></a> prompt_tokens | number | packages/sdk/src/types.ts:57 |
<a id="total_tokens"></a> total_tokens | number | packages/sdk/src/types.ts:59 |
CleverRouterConfig
Defined in: packages/sdk/src/index.ts:83
Konfiguration fuer den CleverRouter-Client.
Example
const cr = createCleverRouter({
apiKey: process.env.CLEVERROUTER_API_KEY!,
strategy: 'fastest',
provider: 'scaleway',
timeoutMs: 30_000,
});Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="apikey"></a> apiKey | string | Bearer-Token. Beginnt mit cr_live_. | packages/sdk/src/index.ts:85 |
<a id="baseurl"></a> baseURL? | string | Base-URL des Gateways. Default: https://api.cleverouter.eu/v1. | packages/sdk/src/index.ts:87 |
<a id="cache-1"></a> cache? | CacheConfig | Optionaler Client-seitiger Cache fuer deterministische Endpoints (Embeddings, Model-Liste). Default: AUS. Chat-Completions, Streams und Rerank werden NIE gecacht. Example const cr = createCleverRouter({ apiKey: '...', cache: { embeddings: { ttlSec: 30 * 24 * 3600 } }, }); | packages/sdk/src/index.ts:112 |
<a id="provider-1"></a> provider? | string | Default-Provider-Pin für alle Requests. | packages/sdk/src/index.ts:91 |
<a id="retry-1"></a> retry? | false | Partial<RetryConfig> | Retry-Konfig. false deaktiviert Retries komplett. Default: 3 attempts auf 429/5xx. | packages/sdk/src/index.ts:93 |
<a id="strategy"></a> strategy? | "default" | "cheapest" | "fastest" | "best" | Default-Strategy für alle Requests (kann pro Call ueberschrieben werden). | packages/sdk/src/index.ts:89 |
<a id="telemetry-1"></a> telemetry? | boolean | TelemetryConfig | Telemetrie-Opt-in (Default: AUS). | packages/sdk/src/index.ts:97 |
<a id="timeoutms-1"></a> timeoutMs? | number | Default-Timeout in ms fuer alle Requests. Default: 60000. | packages/sdk/src/index.ts:95 |
CreateBatchOpts
Defined in: packages/sdk/src/batches.ts:54
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="completion_window-1"></a> completion_window? | string | packages/sdk/src/batches.ts:57 |
<a id="endpoint-1"></a> endpoint | BatchEndpoint | packages/sdk/src/batches.ts:56 |
<a id="input_file_id-1"></a> input_file_id | string | packages/sdk/src/batches.ts:55 |
<a id="metadata-1"></a> metadata? | Record<string, unknown> | packages/sdk/src/batches.ts:58 |
CreateFileOpts
Defined in: packages/sdk/src/files.ts:36
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="purpose"></a> purpose? | FilePurpose | packages/sdk/src/files.ts:37 |
CreateWebhookOpts
Defined in: packages/sdk/src/webhooks.ts:38
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="description"></a> description? | string | packages/sdk/src/webhooks.ts:41 |
<a id="events"></a> events? | WebhookEvent[] | packages/sdk/src/webhooks.ts:40 |
<a id="url"></a> url | string | packages/sdk/src/webhooks.ts:39 |
EmbeddingDataEntry
Defined in: packages/sdk/src/embeddings.ts:30
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="embedding"></a> embedding | string | number[] | packages/sdk/src/embeddings.ts:33 |
<a id="index-1"></a> index | number | packages/sdk/src/embeddings.ts:31 |
<a id="object-4"></a> object | string & object | "embedding" | packages/sdk/src/embeddings.ts:32 |
EmbeddingOpts
Defined in: packages/sdk/src/embeddings.ts:18
Optionen fuer cr.embed().
Example
const opts: EmbeddingOpts = {
model: 'cohere/embed-v4',
encoding_format: 'base64',
dimensions: 512,
};Indexable
[key: string]: unknownProperties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="dimensions"></a> dimensions? | number | Bei Modellen mit Matryoshka / variable Dimensionen — Output-Laenge. | packages/sdk/src/embeddings.ts:24 |
<a id="encoding_format"></a> encoding_format? | "float" | "base64" | 'float' (default) liefert number[]. 'base64' liefert string (kompakter). | packages/sdk/src/embeddings.ts:22 |
<a id="model-4"></a> model? | CleverRouterModel | Modell-ID; Default cohere/embed-v4. | packages/sdk/src/embeddings.ts:20 |
<a id="user-1"></a> user? | string | Wird upstream als Audit-Hint durchgereicht. | packages/sdk/src/embeddings.ts:26 |
EmbeddingResponse
Defined in: packages/sdk/src/embeddings.ts:42
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="data-1"></a> data | EmbeddingDataEntry[] | packages/sdk/src/embeddings.ts:44 |
<a id="model-5"></a> model | string | packages/sdk/src/embeddings.ts:45 |
<a id="object-5"></a> object | string & object | "list" | packages/sdk/src/embeddings.ts:43 |
<a id="usage-2"></a> usage? | EmbeddingUsage | packages/sdk/src/embeddings.ts:46 |
EmbeddingUsage
Defined in: packages/sdk/src/embeddings.ts:36
Indexable
[key: string]: unknownProperties
| Property | Type | Defined in |
|---|---|---|
<a id="prompt_tokens-1"></a> prompt_tokens? | number | packages/sdk/src/embeddings.ts:37 |
<a id="total_tokens-1"></a> total_tokens? | number | packages/sdk/src/embeddings.ts:38 |
FileList
Defined in: packages/sdk/src/files.ts:21
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="data-2"></a> data | FileObject[] | packages/sdk/src/files.ts:23 |
<a id="object-6"></a> object | "list" | packages/sdk/src/files.ts:22 |
FileObject
Defined in: packages/sdk/src/files.ts:10
Antwort-Shape vom Gateway.
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="bytes"></a> bytes | number | packages/sdk/src/files.ts:13 |
<a id="created_at-1"></a> created_at | number | packages/sdk/src/files.ts:14 |
<a id="expires_at-1"></a> expires_at | number | null | packages/sdk/src/files.ts:18 |
<a id="filename"></a> filename | string | packages/sdk/src/files.ts:15 |
<a id="id-4"></a> id | string | packages/sdk/src/files.ts:11 |
<a id="object-7"></a> object | "file" | packages/sdk/src/files.ts:12 |
<a id="purpose-1"></a> purpose | FilePurpose | packages/sdk/src/files.ts:16 |
<a id="status-10"></a> status | FileStatus | packages/sdk/src/files.ts:17 |
ModelInfo
Defined in: packages/sdk/src/index.ts:127
Antwort-Shape von GET /v1/models.
Indexable
[key: string]: unknownProperties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="created-2"></a> created? | number | - | packages/sdk/src/index.ts:134 |
<a id="id-5"></a> id | string | - | packages/sdk/src/index.ts:128 |
<a id="kind"></a> kind? | "audio" | "embedding" | "chat" | "rerank" | Capability-Klasse (chat / embedding / rerank / audio). | packages/sdk/src/index.ts:131 |
<a id="object-8"></a> object | string | - | packages/sdk/src/index.ts:129 |
<a id="owned_by"></a> owned_by? | string | Provider-Hersteller (z.B. "mistral", "qwen"). | packages/sdk/src/index.ts:133 |
RedisLike
Defined in: packages/sdk/src/cache.ts:103
Redis-basierter Cache. Erwartet ein ioredis-kompatibles Client-Objekt (GET/SET-EX/DEL). Wird nicht direkt von der SDK importiert — User uebergibt den Client selbst, damit wir ioredis nicht als Dependency haben.
Example
import Redis from 'ioredis';
import { createCleverRouter, RedisCache } from '@cleverrouter/sdk';
const redis = new Redis(process.env.REDIS_URL!);
const cr = createCleverRouter({
apiKey: '...',
cache: { store: new RedisCache(redis), embeddings: { ttlSec: 30 * 24 * 3600 } },
});Methods
del()
del(key): Promise<unknown>;Defined in: packages/sdk/src/cache.ts:107
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<unknown>
get()
get(key): Promise<string | null>;Defined in: packages/sdk/src/cache.ts:104
Parameters
| Parameter | Type |
|---|---|
key | string |
Returns
Promise<string | null>
set()
set(
key,
value,
mode?,
duration?): Promise<unknown>;Defined in: packages/sdk/src/cache.ts:105
Parameters
| Parameter | Type |
|---|---|
key | string |
value | string |
mode? | string |
duration? | number |
Returns
Promise<unknown>
setex()?
optional setex(
key,
ttl,
value): Promise<unknown>;Defined in: packages/sdk/src/cache.ts:106
Parameters
| Parameter | Type |
|---|---|
key | string |
ttl | number |
value | string |
Returns
Promise<unknown>
RequestOptions
Defined in: packages/sdk/src/index.ts:115
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="provider-2"></a> provider? | string | Pin auf einen bestimmten Provider (z.B. "scaleway"). | packages/sdk/src/index.ts:117 |
<a id="signal"></a> signal? | AbortSignal | AbortSignal fuer manuellen Cancel. | packages/sdk/src/index.ts:121 |
<a id="strategy-1"></a> strategy? | "default" | "cheapest" | "fastest" | "best" | Routing-Strategie für diesen Request. | packages/sdk/src/index.ts:119 |
<a id="timeoutms-2"></a> timeoutMs? | number | Per-Call-Timeout. Default: aus config (60s). | packages/sdk/src/index.ts:123 |
RerankMeta
Defined in: packages/sdk/src/rerank.ts:42
Indexable
[key: string]: unknownProperties
| Property | Type | Defined in |
|---|---|---|
<a id="api_version"></a> api_version? | object | packages/sdk/src/rerank.ts:44 |
api_version.version? | string | packages/sdk/src/rerank.ts:44 |
<a id="billed_units"></a> billed_units? | object | packages/sdk/src/rerank.ts:43 |
billed_units.search_units? | number | packages/sdk/src/rerank.ts:43 |
RerankOpts
Defined in: packages/sdk/src/rerank.ts:20
Optionen fuer cr.rerank().
Example
const opts: RerankOpts = {
query: 'EU GDPR',
documents: ['doc1', 'doc2'],
top_n: 2,
model: 'cohere/rerank-v3-5',
};Indexable
[key: string]: unknownProperties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="documents"></a> documents | string[] | Liste der Dokumente die geranked werden. Mindestens 1 Eintrag. | packages/sdk/src/rerank.ts:24 |
<a id="max_chunks_per_doc"></a> max_chunks_per_doc? | number | Maximale Anzahl an Dokumenten die in Chunks zerteilt werden. | packages/sdk/src/rerank.ts:30 |
<a id="model-6"></a> model? | CleverRouterModel | Modell-ID; Default cohere/rerank-v3-5. | packages/sdk/src/rerank.ts:28 |
<a id="query"></a> query | string | Suchanfrage gegen die documents gescort werden. | packages/sdk/src/rerank.ts:22 |
<a id="return_documents"></a> return_documents? | boolean | Return-Original-Documents-Toggle. Default: false. | packages/sdk/src/rerank.ts:32 |
<a id="top_n"></a> top_n? | number | Optional — gibt nur die Top-N zurueck (nach relevance_score). | packages/sdk/src/rerank.ts:26 |
RerankResponse
Defined in: packages/sdk/src/rerank.ts:48
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="id-6"></a> id? | string | packages/sdk/src/rerank.ts:49 |
<a id="meta"></a> meta? | RerankMeta | packages/sdk/src/rerank.ts:51 |
<a id="results"></a> results | RerankResultEntry[] | packages/sdk/src/rerank.ts:50 |
RerankResultEntry
Defined in: packages/sdk/src/rerank.ts:36
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="document"></a> document? | | string | { text: string; } | packages/sdk/src/rerank.ts:39 |
<a id="index-2"></a> index | number | packages/sdk/src/rerank.ts:37 |
<a id="relevance_score"></a> relevance_score | number | packages/sdk/src/rerank.ts:38 |
RetryConfig
Defined in: packages/sdk/src/retry.ts:21
Retry-Konfiguration fuer den SDK-internen Fetch-Wrapper.
Example
const cr = createCleverRouter({
apiKey: process.env.CLEVERROUTER_API_KEY!,
retry: { maxAttempts: 5, baseDelayMs: 250 },
});Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="basedelayms"></a> baseDelayMs | number | Basis-Delay in ms fuer exponential backoff. Default: 500. | packages/sdk/src/retry.ts:25 |
<a id="maxattempts"></a> maxAttempts | number | Maximale Anzahl Versuche inklusive erstem. Default: 3 (= 2 Retries). | packages/sdk/src/retry.ts:23 |
<a id="maxdelayms"></a> maxDelayMs | number | Maximaler Delay-Cap in ms. Default: 10000. | packages/sdk/src/retry.ts:29 |
<a id="statuscodes"></a> statusCodes | number[] | Status-Codes die geretryt werden. Default: [429, 502, 503, 504]. | packages/sdk/src/retry.ts:27 |
TelemetryConfig
Defined in: packages/sdk/src/telemetry.ts:28
Telemetrie-Konfiguration. Default ist immer AUS.
Sammelt nur anonyme Counter (SDK-Version, Runtime, Calls-pro-Endpoint). KEINE Prompts, KEINE API-Keys, KEINE User-IDs.
Example
const cr = createCleverRouter({
apiKey: process.env.CLEVERROUTER_API_KEY!,
telemetry: true,
});Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="enabled"></a> enabled | boolean | Telemetrie an/aus. Default: false. | packages/sdk/src/telemetry.ts:30 |
<a id="endpoint-2"></a> endpoint? | string | Ueberschreibt die Endpoint-URL. Default: https://api.cleverouter.eu/telemetry | packages/sdk/src/telemetry.ts:32 |
TranscribeOpts
Defined in: packages/sdk/src/audio.ts:25
Optionen fuer cr.transcribe().
Example
const opts: TranscribeOpts = {
model: 'systran/faster-whisper-large-v3',
language: 'de',
response_format: 'verbose_json',
timestamp_granularities: ['word', 'segment'],
};Indexable
[key: string]: unknownProperties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="language"></a> language? | string | ISO-639-1 Sprach-Hint. | packages/sdk/src/audio.ts:29 |
<a id="model-7"></a> model? | CleverRouterModel | Modell-ID; Default systran/faster-whisper-large-v3. | packages/sdk/src/audio.ts:27 |
<a id="prompt"></a> prompt? | string | Optionaler Prompt der die Transkription biased (z.B. Eigennamen). | packages/sdk/src/audio.ts:31 |
<a id="response_format-1"></a> response_format? | "json" | "text" | "srt" | "verbose_json" | "vtt" | Ausgabeformat. Beeinflusst auch den Return-Type. | packages/sdk/src/audio.ts:35 |
<a id="temperature-1"></a> temperature? | number | Sampling-Temperature der Whisper-Variante. | packages/sdk/src/audio.ts:33 |
<a id="timestamp_granularities"></a> timestamp_granularities? | ("word" | "segment")[] | Nur in verbose_json — Wort- und/oder Segment-Timestamps. | packages/sdk/src/audio.ts:37 |
TranscriptionJSONResponse
Defined in: packages/sdk/src/audio.ts:41
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="text"></a> text | string | packages/sdk/src/audio.ts:42 |
TranscriptionVerboseJSONResponse
Defined in: packages/sdk/src/audio.ts:53
Indexable
[key: string]: unknownProperties
| Property | Type | Defined in |
|---|---|---|
<a id="duration"></a> duration? | number | packages/sdk/src/audio.ts:56 |
<a id="language-1"></a> language? | string | packages/sdk/src/audio.ts:55 |
<a id="segments"></a> segments? | TranscriptionVerboseSegment[] | packages/sdk/src/audio.ts:57 |
<a id="text-1"></a> text | string | packages/sdk/src/audio.ts:54 |
<a id="words"></a> words? | object[] | packages/sdk/src/audio.ts:58 |
VerifyResult
Defined in: packages/sdk/src/webhooks.ts:44
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="reason"></a> reason? | | "missing_signature" | "invalid_timestamp" | "timestamp_out_of_tolerance" | "signature_mismatch" | packages/sdk/src/webhooks.ts:46 |
<a id="valid"></a> valid | boolean | packages/sdk/src/webhooks.ts:45 |
WebhookList
Defined in: packages/sdk/src/webhooks.ts:33
Properties
| Property | Type | Defined in |
|---|---|---|
<a id="data-3"></a> data | WebhookObject[] | packages/sdk/src/webhooks.ts:35 |
<a id="object-9"></a> object | "list" | packages/sdk/src/webhooks.ts:34 |
WebhookObject
Defined in: packages/sdk/src/webhooks.ts:19
Properties
| Property | Type | Description | Defined in |
|---|---|---|---|
<a id="created_at-2"></a> created_at | number | - | packages/sdk/src/webhooks.ts:28 |
<a id="description-1"></a> description | string | null | - | packages/sdk/src/webhooks.ts:25 |
<a id="events-1"></a> events | WebhookEvent[] | - | packages/sdk/src/webhooks.ts:23 |
<a id="id-7"></a> id | string | - | packages/sdk/src/webhooks.ts:20 |
<a id="last_response_status"></a> last_response_status | number | null | - | packages/sdk/src/webhooks.ts:27 |
<a id="last_triggered_at"></a> last_triggered_at | number | null | - | packages/sdk/src/webhooks.ts:26 |
<a id="object-10"></a> object | "webhook" | - | packages/sdk/src/webhooks.ts:21 |
<a id="secret"></a> secret? | string | Nur in der Create-Response gesetzt — danach nie wieder abrufbar. | packages/sdk/src/webhooks.ts:30 |
<a id="status-11"></a> status | WebhookStatus | - | packages/sdk/src/webhooks.ts:24 |
<a id="url-1"></a> url | string | - | packages/sdk/src/webhooks.ts:22 |
Type Aliases
BatchEndpoint
type BatchEndpoint = "/v1/chat/completions" | "/v1/embeddings";Defined in: packages/sdk/src/batches.ts:17
BatchStatus
type BatchStatus =
| "validating"
| "in_progress"
| "finalizing"
| "completed"
| "failed"
| "expired"
| "cancelling"
| "cancelled";Defined in: packages/sdk/src/batches.ts:7
CleverRouterModel
type CleverRouterModel = keyof typeof MODELS | string & object;Defined in: packages/sdk/src/models.ts:35
FileInput
type FileInput =
| File
| Blob
| {
data: ArrayBuffer | Uint8Array | Blob;
name: string;
type?: string;
};Defined in: packages/sdk/src/files.ts:27
Akzeptierte File-Inputs analog zur Audio-Helper-API.
FilePurpose
type FilePurpose = "batch" | "batch_output" | "batch_error";Defined in: packages/sdk/src/files.ts:6
FileStatus
type FileStatus = "uploaded" | "processing" | "deleted";Defined in: packages/sdk/src/files.ts:7
ModelClass
type ModelClass =
| "frontier-reasoning"
| "fast"
| "coder"
| "vision"
| "audio"
| "embedding"
| "open-source";Defined in: packages/sdk/src/models.ts:38
TranscribeInput
type TranscribeInput =
| File
| Blob
| {
data: ArrayBuffer | Uint8Array | Blob;
name: string;
type?: string;
};Defined in: packages/sdk/src/audio.ts:7
TranscriptionResponse
type TranscriptionResponse =
| TranscriptionJSONResponse
| TranscriptionVerboseJSONResponse
| string;Defined in: packages/sdk/src/audio.ts:63
Union der moeglichen Responses je nach response_format.
WebhookEvent
type WebhookEvent =
| "batch.completed"
| "batch.failed"
| "batch.cancelled"
| "batch.expired";Defined in: packages/sdk/src/webhooks.ts:11
WebhookStatus
type WebhookStatus = "active" | "disabled";Defined in: packages/sdk/src/webhooks.ts:17
Variables
MODELS
const MODELS: object;Defined in: packages/sdk/src/models.ts:5
Type Declaration
| Name | Type | Default value | Defined in |
|---|---|---|---|
<a id="property-baaibge-multilingual-gemma2"></a> baai/bge-multilingual-gemma2 | "baai/bge-multilingual-gemma2" | 'baai/bge-multilingual-gemma2' | packages/sdk/src/models.ts:32 |
<a id="property-deepseekdeepseek-r1-distill-llama-70b"></a> deepseek/deepseek-r1-distill-llama-70b | "deepseek/deepseek-r1-distill-llama-70b" | 'deepseek/deepseek-r1-distill-llama-70b' | packages/sdk/src/models.ts:28 |
<a id="property-googlegemma-3-27b"></a> google/gemma-3-27b | "google/gemma-3-27b" | 'google/gemma-3-27b' | packages/sdk/src/models.ts:22 |
<a id="property-googlegemma-4-26b"></a> google/gemma-4-26b | "google/gemma-4-26b" | 'google/gemma-4-26b' | packages/sdk/src/models.ts:23 |
<a id="property-hcompanyholo-2"></a> hcompany/holo-2 | "hcompany/holo-2" | 'hcompany/holo-2' | packages/sdk/src/models.ts:30 |
<a id="property-metallama-33-70b"></a> meta/llama-3.3-70b | "meta/llama-3.3-70b" | 'meta/llama-3.3-70b' | packages/sdk/src/models.ts:20 |
<a id="property-mistraldevstral-2"></a> mistral/devstral-2 | "mistral/devstral-2" | 'mistral/devstral-2' | packages/sdk/src/models.ts:12 |
<a id="property-mistralmistral-embed"></a> mistral/mistral-embed | "mistral/mistral-embed" | 'mistral/mistral-embed' | packages/sdk/src/models.ts:13 |
<a id="property-mistralmistral-large-2"></a> mistral/mistral-large-2 | "mistral/mistral-large-2" | 'mistral/mistral-large-2' | packages/sdk/src/models.ts:7 |
<a id="property-mistralmistral-nemo"></a> mistral/mistral-nemo | "mistral/mistral-nemo" | 'mistral/mistral-nemo' | packages/sdk/src/models.ts:9 |
<a id="property-mistralmistral-small-32"></a> mistral/mistral-small-3.2 | "mistral/mistral-small-3.2" | 'mistral/mistral-small-3.2' | packages/sdk/src/models.ts:8 |
<a id="property-mistralpixtral-12b"></a> mistral/pixtral-12b | "mistral/pixtral-12b" | 'mistral/pixtral-12b' | packages/sdk/src/models.ts:10 |
<a id="property-mistralvoxtral-small"></a> mistral/voxtral-small | "mistral/voxtral-small" | 'mistral/voxtral-small' | packages/sdk/src/models.ts:11 |
<a id="property-openaigpt-oss-120b"></a> openai/gpt-oss-120b | "openai/gpt-oss-120b" | 'openai/gpt-oss-120b' | packages/sdk/src/models.ts:25 |
<a id="property-openaiwhisper-large-v3"></a> openai/whisper-large-v3 | "openai/whisper-large-v3" | 'openai/whisper-large-v3' | packages/sdk/src/models.ts:26 |
<a id="property-qwenqwen3-235b"></a> qwen/qwen3-235b | "qwen/qwen3-235b" | 'qwen/qwen3-235b' | packages/sdk/src/models.ts:16 |
<a id="property-qwenqwen3-coder"></a> qwen/qwen3-coder | "qwen/qwen3-coder" | 'qwen/qwen3-coder' | packages/sdk/src/models.ts:17 |
<a id="property-qwenqwen3-embedding"></a> qwen/qwen3-embedding | "qwen/qwen3-embedding" | 'qwen/qwen3-embedding' | packages/sdk/src/models.ts:18 |
<a id="property-qwenqwen35-397b"></a> qwen/qwen3.5-397b | "qwen/qwen3.5-397b" | 'qwen/qwen3.5-397b' | packages/sdk/src/models.ts:15 |
MODELS_BY_CLASS
const MODELS_BY_CLASS: Record<ModelClass, CleverRouterModel[]>;Defined in: packages/sdk/src/models.ts:59
SDK_VERSION
const SDK_VERSION: "0.1.2" = '0.1.2';Defined in: packages/sdk/src/version.ts:3
Functions
createCleverRouter()
function createCleverRouter(config): CleverRouter;Defined in: packages/sdk/src/index.ts:809
Convenience-Factory fuer einen CleverRouter-Client.
Parameters
| Parameter | Type | Description |
|---|---|---|
config | CleverRouterConfig | Mindestens apiKey. Optional baseURL, provider, strategy, retry, timeoutMs, telemetry. |
Returns
Eine konfigurierte CleverRouter-Instanz.
Example
const cr = createCleverRouter({ apiKey: process.env.CLEVERROUTER_API_KEY! });
const res = await cr.chat({
model: 'mistral/mistral-small-3.2',
messages: [{ role: 'user', content: 'Hi.' }],
});fetchCR()
function fetchCR<TRes>(
cfg,
path,
init?): Promise<TRes>;Defined in: packages/sdk/src/index.ts:163
Interner Fetch-Helper mit JSON-Parsing, Retry, Timeout, Abort-Support, typed Response. Wirft typed CRError-Subtypen bei Non-2xx Responses. Generisch ueber den Response-Typ.
Type Parameters
| Type Parameter | Default type |
|---|---|
TRes | unknown |
Parameters
| Parameter | Type |
|---|---|
cfg | FetchCRConfig |
path | string |
init | RequestInit |
Returns
Promise<TRes>
fetchCRRaw()
function fetchCRRaw(
cfg,
path,
init?): Promise<Response>;Defined in: packages/sdk/src/index.ts:175
Wie fetchCR, gibt aber die Raw-Response zurueck (z.B. fuer Streams oder text/plain).
Parameters
| Parameter | Type |
|---|---|
cfg | FetchCRConfig |
path | string |
init | RequestInit |
Returns
Promise<Response>
hashKey()
function hashKey(value): Promise<string>;Defined in: packages/sdk/src/cache.ts:191
SHA-256-Hash eines Werts (JSON-stringified). Web-Crypto wenn verfuegbar (Browser/Edge/Node 19+), Fallback auf node:crypto via dynamic require.
Parameters
| Parameter | Type |
|---|---|
value | unknown |
Returns
Promise<string>
iterateChatStream()
function iterateChatStream(res, signal?): AsyncIterable<ChatStreamChunk>;Defined in: packages/sdk/src/stream.ts:102
Konsumiert eine Stream-Response und yieldet ChatStreamChunk-Objekte.
Yieldet zusaetzlich ein letztes Element mit usage, wenn der Server eines schickt.
Wirft am Ende wenn der Stream ohne [DONE] abreisst — ausser der externe
Caller hat per AbortSignal abgebrochen (Audit Finding #2).
Parameters
| Parameter | Type |
|---|---|
res | Response |
signal? | AbortSignal |
Returns
AsyncIterable<ChatStreamChunk>
iterateJsonlBody()
function iterateJsonlBody<T>(res): AsyncGenerator<T>;Defined in: packages/sdk/src/batches.ts:66
Liest ein JSONL-Body Zeile-fuer-Zeile aus einer Response und yields die geparsten JSON-Objects. Stream-faehig: laedt nicht den ganzen Body in Memory.
Type Parameters
| Type Parameter | Default type |
|---|---|
T | unknown |
Parameters
| Parameter | Type |
|---|---|
res | Response |
Returns
AsyncGenerator<T>
mapResponse()
function mapResponse(res): Promise<CRError>;Defined in: packages/sdk/src/errors.ts:111
Wandelt eine fehlgeschlagene Fetch-Response in den passenden CRError-Subtyp.
Liest JSON-Body, extrahiert error.code und error.message, mapped auf Status.
Parameters
| Parameter | Type |
|---|---|
res | Response |
Returns
Promise<CRError>
streamTextDeltas()
function streamTextDeltas(stream): AsyncIterable<string>;Defined in: packages/sdk/src/stream.ts:188
Convenience: yieldet nur die content-Delta-Strings.
Parameters
| Parameter | Type |
|---|---|
stream | AsyncIterable<ChatStreamChunk> |
Returns
AsyncIterable<string>
verifyWebhook()
function verifyWebhook(
rawBody,
signature,
secret,
toleranceSec?): Promise<VerifyResult>;Defined in: packages/sdk/src/webhooks.ts:65
Verifiziert die X-CleverRouter-Signature-Signatur.
Parameters
| Parameter | Type | Default value | Description |
|---|---|---|---|
rawBody | string | undefined | Roh-HTTP-Body als string (NICHT geparsed JSON) |
signature | string | null | undefined | undefined | Wert vom X-CleverRouter-Signature-Header |
secret | string | undefined | whsec_... aus der Webhook-Registry |
toleranceSec | number | 300 | Max-Drift in Sekunden (Default 300s = 5 min) |
Returns
Promise<VerifyResult>
Example
import { verifyWebhook } from '@cleverrouter/sdk/webhooks';
const result = await verifyWebhook(rawBody, req.headers['x-cleverrouter-signature'], process.env.WEBHOOK_SECRET!);
if (!result.valid) return new Response('invalid', { status: 400 });