samsar-js 0.48.11 → 0.48.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -158,7 +158,7 @@ const websiteEmbedding = await samsar.createEmbeddingFromUrl({
158
158
  });
159
159
 
160
160
  // `levels` controls crawl depth for URL mode: 1 = only listed URLs, 2 = one link hop, 3 = two link hops.
161
- // The API defaults to 3 levels and caps total crawled pages at 50 per request.
161
+ // The API defaults to 2 levels and caps total crawled pages at 50 per request.
162
162
 
163
163
  // Create embeddings from already cleaned plain text without crawling
164
164
  const cleanTextEmbedding = await samsar.generateEmbeddingsFromPlainText({
@@ -396,7 +396,7 @@ Each method returns `{ data, status, headers, creditsCharged, creditsRemaining,
396
396
 
397
397
  - Assistant completions are billed from actual request usage. Samsar measures the processed input and generated output, converts usage to credits using the standard `100 credits = $1` rule, and applies a `2.5x` assistant multiplier so text-only and multimodal sessions are priced consistently.
398
398
  - Embedding endpoints (`createEmbedding`, `updateEmbedding`, `searchAgainstEmbedding`, `similarToEmbedding`) are billed by input tokens at $1 per million tokens. `deleteEmbeddings` does not consume tokens.
399
- - URL-based embedding creation (`createEmbedding` with `urls`, or `createEmbeddingFromUrl`) supports `levels` 1-3, defaults to 3, caps total crawled pages at 50 per request, bills actual Firecrawl usage with a `2.5x` crawl multiplier, and then bills the embedding phase with a separate flat `2.5x` multiplier.
399
+ - URL-based embedding creation (`createEmbedding` with `urls`, or `createEmbeddingFromUrl`) supports `levels` 1-3, defaults to 2, caps total crawled pages at 50 per request, bills actual Firecrawl usage with a `2.5x` crawl multiplier, and then bills the embedding phase with a separate flat `2.5x` multiplier.
400
400
  - Plain-text embedding creation (`generateEmbeddingsFromPlainText`, `generateExternalEmbeddingsFromPlainText`) skips crawling and charges only the embedding-token cost with a flat `2.5x` multiplier.
401
401
  - Token-based routes scale with the amount of content processed. Larger prompts, longer responses, and richer inputs use more credits than short text-only requests.
402
402
  - Receipt template creation (`createReceiptTemplate`) and template JSON lookup (`getReceiptTemplateJson`) are free; receipt template query (`queryReceiptTemplate`) costs 50 credits per request.
package/dist/index.d.ts CHANGED
@@ -1015,6 +1015,52 @@ export interface ExternalCreditsGrantResponse {
1015
1015
  external_user?: ExternalUserSummary | null;
1016
1016
  [key: string]: unknown;
1017
1017
  }
1018
+ export interface ExternalUtilityChargeRequest {
1019
+ utility_type?: string;
1020
+ utilityType?: string;
1021
+ type?: string;
1022
+ provider?: string;
1023
+ model?: string;
1024
+ model_id?: string;
1025
+ modelId?: string;
1026
+ text?: string;
1027
+ content?: string;
1028
+ characters?: number;
1029
+ character_count?: number;
1030
+ characterCount?: number;
1031
+ duration_ms?: number;
1032
+ durationMs?: number;
1033
+ duration_seconds?: number;
1034
+ durationSeconds?: number;
1035
+ duration_minutes?: number;
1036
+ durationMinutes?: number;
1037
+ duration_hours?: number;
1038
+ durationHours?: number;
1039
+ firecrawl_credits_used?: number;
1040
+ firecrawlCreditsUsed?: number;
1041
+ pricing_multiplier?: number;
1042
+ pricingMultiplier?: number;
1043
+ multiplier?: number;
1044
+ metadata?: Record<string, unknown>;
1045
+ [key: string]: unknown;
1046
+ }
1047
+ export interface ExternalUtilityChargeResponse {
1048
+ utilityType?: string;
1049
+ provider?: string | null;
1050
+ model?: string | null;
1051
+ creditsCharged?: number;
1052
+ remainingCredits?: number | null;
1053
+ pricing?: {
1054
+ costUsd?: number;
1055
+ pricingMultiplier?: number;
1056
+ creditsPerDollar?: number;
1057
+ units?: Record<string, unknown>;
1058
+ [key: string]: unknown;
1059
+ } | null;
1060
+ externalUser?: ExternalUserSummary | null;
1061
+ external_user?: ExternalUserSummary | null;
1062
+ [key: string]: unknown;
1063
+ }
1018
1064
  export interface ExternalCreditsRechargeResponse extends CreditsRechargeResponse {
1019
1065
  external_payment_id?: string;
1020
1066
  external_user?: ExternalUserSummary | null;
@@ -1305,6 +1351,11 @@ export declare class SamsarClient {
1305
1351
  sessionName?: string;
1306
1352
  metadata?: Record<string, unknown>;
1307
1353
  }, options?: SamsarRequestOptions): Promise<SamsarResult<ExternalAssistantSessionResponse>>;
1354
+ /**
1355
+ * Charge an external user's credits for utility usage such as ElevenLabs TTS/STT or Firecrawl crawl costs.
1356
+ * This is useful when a proxy or integration incurs third-party usage outside the standard Samsar route billing flow.
1357
+ */
1358
+ chargeExternalUserUtilityUsage(payload: ExternalUtilityChargeRequest, externalUser?: ExternalUserIdentity | null, options?: SamsarRequestOptions): Promise<SamsarResult<ExternalUtilityChargeResponse>>;
1308
1359
  /**
1309
1360
  * Create a short-lived external-user login token plus a ready-to-open client login URL.
1310
1361
  */
@@ -1404,7 +1455,7 @@ export declare class SamsarClient {
1404
1455
  createEmbedding(payload: CreateEmbeddingRequest, options?: SamsarRequestOptions): Promise<SamsarResult<CreateEmbeddingResponse>>;
1405
1456
  /**
1406
1457
  * Create a new embedding template from one URL or a list of URLs.
1407
- * Pass `levels` (1-3) to control crawl depth; the API defaults to 3.
1458
+ * Pass `levels` (1-3) to control crawl depth; the API defaults to 2.
1408
1459
  */
1409
1460
  createEmbeddingFromUrl(payload: CreateEmbeddingFromUrlRequest, options?: SamsarRequestOptions): Promise<SamsarResult<CreateEmbeddingResponse>>;
1410
1461
  /**
package/dist/index.js CHANGED
@@ -128,6 +128,19 @@ export class SamsarClient {
128
128
  }
129
129
  return this.post('external_users/utils/assistant_session', body, options);
130
130
  }
131
+ /**
132
+ * Charge an external user's credits for utility usage such as ElevenLabs TTS/STT or Firecrawl crawl costs.
133
+ * This is useful when a proxy or integration incurs third-party usage outside the standard Samsar route billing flow.
134
+ */
135
+ async chargeExternalUserUtilityUsage(payload, externalUser, options) {
136
+ const body = {
137
+ ...payload,
138
+ };
139
+ if (externalUser) {
140
+ body.external_user = normalizeExternalUserIdentity(externalUser);
141
+ }
142
+ return this.post('external_users/utils/usage_charge', body, options);
143
+ }
131
144
  /**
132
145
  * Create a short-lived external-user login token plus a ready-to-open client login URL.
133
146
  */
@@ -625,7 +638,7 @@ export class SamsarClient {
625
638
  }
626
639
  /**
627
640
  * Create a new embedding template from one URL or a list of URLs.
628
- * Pass `levels` (1-3) to control crawl depth; the API defaults to 3.
641
+ * Pass `levels` (1-3) to control crawl depth; the API defaults to 2.
629
642
  */
630
643
  async createEmbeddingFromUrl(payload, options) {
631
644
  return this.post('chat/create_embedding_from_url', payload, options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "samsar-js",
3
- "version": "0.48.11",
3
+ "version": "0.48.13",
4
4
  "description": "TypeScript client for the Samsar Processor API routes.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",