@lionhummer/constellation 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -201,3 +201,19 @@ const body = await client.telemetry.requests.getHttpBody(requestId, attemptId, {
|
|
|
201
201
|
Request lists accept `RequestListQuery`, including exact `externalId` and requested-model filters, exclusions and substring matches. Record lists accept `RequestRecordsQuery` (`id`, `q`, log-only `level`, `offset`, `limit`). `PageQuery.filters` belongs only to registry list rows. Every other method has its endpoint's exact query type. See the [HTTP filter matrix](../../docs/api.md#filter-audit-and-exact-query-support) for search semantics, caps, cursor behavior and capabilities not currently provided.
|
|
202
202
|
|
|
203
203
|
Unscoped telemetry also exposes `observability.getBilling`, `getTraffic`, `getTiming`, dashboard and measurement series. Use `providerId` for local series and `upstream` for gateway series. `system.getComponent(component, { status, statusNot, q, offset })` and `jobs.listHistory` page matching operational records; notifications use fixed 25-item pages and status/offset, not generic filters.
|
|
204
|
+
|
|
205
|
+
### Supplier cost, customer basis and margin
|
|
206
|
+
|
|
207
|
+
Each provider attempt records immutable `attributes.billing` on its Constellation `provider.call` span. The `step.usage_ready` event carries the same `billing` facts. Both are included in default telemetry metadata. `supplierPrice`/`supplierCost` record the selected supplier rates and usage cost. `customerPricing` identifies the model or offering basis, plan, scoped rule and adjustment; `customerBasisPrice`/`customerBasisCost` record the customer calculation before adjustment. `customerPrice`/`customerCost` record the final rates and charge. `grossMarginAmount` is charge minus supplier cost; `grossMarginPercent` divides it by charge. Unknown costs leave margins null, and a zero charge has a null margin percentage. These costs use provider-reported usage and captured schedules, not reconciled supplier invoices. Prices are USD per million tokens; costs are decimal USD strings.
|
|
208
|
+
|
|
209
|
+
Provider cost capture is optional: `billing.amountPointer` locates a provider-reported amount in response JSON and `unitsPerUsd` converts it to USD. `reportedSupplierCost` is retained only for analysis; it never changes supplier cost, customer basis, charges or margin. Supplier cost is calculated from reported token usage and captured supplier rates. `supplierCostDifference` is reported minus calculated cost when both are known. The offering selects `customerPriceBasis:model|offering`; plans apply the customer adjustment.
|
|
210
|
+
|
|
211
|
+
### Standard settings and headers
|
|
212
|
+
|
|
213
|
+
Use `parameters.reasoningEffort` for reasoning effort across providers. The model discovery schema defines its allowed values and other supported settings. Constellation translates fields and values for the selected offering. Required unsupported settings reject; `optionalParameters` permits declared omissions with warnings.
|
|
214
|
+
|
|
215
|
+
The standard Reasoning Effort vocabulary is `none`, `minimal`, `low`, `medium`, `high`, `xhigh`, and `max`; Verbosity is `low`, `medium`, or `high`; Service Tier is `auto`, `default`, `flex`, or `priority`. Discovery lists the values accessible to your key and eligible routes. A model’s standard definitions cannot be renamed or given additional values; custom parameters have separately authored definitions. Provider wire names and values are translated internally.
|
|
216
|
+
|
|
217
|
+
For cache diagnostics, send `cache: { mode: "automatic", diagnostics: true }` on the first step. `providerResponseId` appears on attempts and in the `afterModel` checkpoint payload. Use that upstream ID as a later step’s `cache.comparisonId`, which also enables diagnostics. A successful cache hit may return no diagnostic payload. Telemetry exposes the response ID by default; raw `cacheDiagnostics` requires `include: "content"`. Diagnostics and prewarm are offering capabilities: discover support before requesting them. Invalid TTLs or unsupported required cache settings fail rather than being silently dropped.
|
|
218
|
+
|
|
219
|
+
Send beta tokens as `headers: { "anthropic-beta": "your-beta-token" }`, not inside `parameters`. The provider connection must allow the header name. Unapproved, protected or malformed headers are dropped with warnings. A permitted header can still contain an upstream-unsupported beta token; the provider's own error remains visible. Cache diagnostics can add their required beta separately. Obvious may choose provider-specific prompt placement and cache boundaries while using Constellation's standard cache request.
|
|
@@ -29,6 +29,20 @@ export type Message = {
|
|
|
29
29
|
isError?: boolean;
|
|
30
30
|
}[];
|
|
31
31
|
};
|
|
32
|
+
/** Standard settings. The model discovery schema describes supported values and extensions. */
|
|
33
|
+
export type InferenceParameters = Record<string, Json> & {
|
|
34
|
+
reasoningEffort?: "none" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
|
|
35
|
+
verbosity?: "low" | "medium" | "high";
|
|
36
|
+
temperature?: number;
|
|
37
|
+
topP?: number;
|
|
38
|
+
thinking?: Json;
|
|
39
|
+
toolChoice?: Json;
|
|
40
|
+
parallelToolCalls?: boolean;
|
|
41
|
+
toolStrict?: boolean;
|
|
42
|
+
responseFormat?: Json;
|
|
43
|
+
stopSequences?: string[];
|
|
44
|
+
serviceTier?: "auto" | "default" | "flex" | "priority";
|
|
45
|
+
};
|
|
32
46
|
type RequestFields = {
|
|
33
47
|
idempotencyKey: string;
|
|
34
48
|
externalId?: string;
|
|
@@ -39,12 +53,21 @@ type RequestFields = {
|
|
|
39
53
|
instructions?: string;
|
|
40
54
|
messages: Message[];
|
|
41
55
|
tools?: Tool[];
|
|
42
|
-
parameters?:
|
|
56
|
+
parameters?: InferenceParameters;
|
|
57
|
+
optionalParameters?: string[];
|
|
58
|
+
/** Only headers approved by the selected provider are forwarded; others produce warnings. */
|
|
59
|
+
headers?: Record<string, string>;
|
|
60
|
+
nativeContentPolicy?: "require" | "omitCompleted";
|
|
43
61
|
maxSteps?: number;
|
|
44
62
|
timeoutMs?: number;
|
|
45
63
|
maxOutputTokens?: number;
|
|
46
64
|
cache?: {
|
|
47
65
|
mode: "automatic" | "explicit";
|
|
66
|
+
ttl?: string;
|
|
67
|
+
prewarm?: boolean;
|
|
68
|
+
comparisonId?: string;
|
|
69
|
+
/** Request cache diagnostics, including a first-turn baseline without a comparison ID. */
|
|
70
|
+
diagnostics?: boolean;
|
|
48
71
|
points?: ({
|
|
49
72
|
target: "tools" | "instructions";
|
|
50
73
|
} | {
|
|
@@ -126,6 +149,8 @@ export type Attempt = {
|
|
|
126
149
|
providerId: string;
|
|
127
150
|
offeringId: string;
|
|
128
151
|
providerModel: string;
|
|
152
|
+
providerResponseId?: string | null;
|
|
153
|
+
cacheDiagnostics?: Json | null;
|
|
129
154
|
connectionKind: string;
|
|
130
155
|
endpoint: string;
|
|
131
156
|
fallback: boolean;
|
|
@@ -154,7 +179,11 @@ export type PreparedStep = {
|
|
|
154
179
|
instructions: string;
|
|
155
180
|
messages: Message[];
|
|
156
181
|
tools: Tool[];
|
|
157
|
-
parameters:
|
|
182
|
+
parameters: InferenceParameters;
|
|
183
|
+
optionalParameters?: string[];
|
|
184
|
+
/** Only headers approved by the selected provider are forwarded; others produce warnings. */
|
|
185
|
+
headers?: Record<string, string>;
|
|
186
|
+
nativeContentPolicy?: "require" | "omitCompleted";
|
|
158
187
|
maxOutputTokens: number;
|
|
159
188
|
cache: RequestInput["cache"] | null;
|
|
160
189
|
};
|
|
@@ -174,6 +203,8 @@ export type PendingInput = {
|
|
|
174
203
|
customerCost?: string | null;
|
|
175
204
|
supplierCost?: string | null;
|
|
176
205
|
customerPrice?: Json;
|
|
206
|
+
customerPricing?: CustomerPricing;
|
|
207
|
+
billing?: BillingFacts;
|
|
177
208
|
output?: Json;
|
|
178
209
|
};
|
|
179
210
|
claimId: string | null;
|
|
@@ -307,7 +338,11 @@ export type ModelResolution = ModelScope & {
|
|
|
307
338
|
targetId: string;
|
|
308
339
|
inputTokens?: number;
|
|
309
340
|
outputTokens?: number;
|
|
310
|
-
parameters?:
|
|
341
|
+
parameters?: InferenceParameters;
|
|
342
|
+
optionalParameters?: string[];
|
|
343
|
+
/** Only headers approved by the selected provider are forwarded; others produce warnings. */
|
|
344
|
+
headers?: Record<string, string>;
|
|
345
|
+
nativeContentPolicy?: "require" | "omitCompleted";
|
|
311
346
|
};
|
|
312
347
|
export type WebhookEvent = {
|
|
313
348
|
requestId: string;
|
|
@@ -336,9 +371,51 @@ export type TokenUsage = {
|
|
|
336
371
|
outputTokens?: number;
|
|
337
372
|
cacheReadTokens?: number;
|
|
338
373
|
cacheWriteTokens?: number;
|
|
374
|
+
cacheWriteOneHourTokens?: number;
|
|
339
375
|
reasoningTokens?: number;
|
|
340
376
|
partial?: boolean;
|
|
341
377
|
};
|
|
378
|
+
/** USD per million tokens. The selected rates apply to the whole call. */
|
|
379
|
+
export type TokenPrice = {
|
|
380
|
+
input: string;
|
|
381
|
+
output: string;
|
|
382
|
+
cacheRead?: string | null;
|
|
383
|
+
cacheWrite?: string | null;
|
|
384
|
+
cacheWriteOneHour?: string | null;
|
|
385
|
+
tiers?: {
|
|
386
|
+
aboveInputTokens: number;
|
|
387
|
+
price: TokenPrice;
|
|
388
|
+
}[];
|
|
389
|
+
};
|
|
390
|
+
export type CustomerPricing = {
|
|
391
|
+
basis: "model" | "offering";
|
|
392
|
+
basisTargetId: string;
|
|
393
|
+
basisPrice?: TokenPrice;
|
|
394
|
+
planId: string | null;
|
|
395
|
+
pricingRuleId: string | null;
|
|
396
|
+
adjustment: {
|
|
397
|
+
mode: "margin" | "markup" | "discount";
|
|
398
|
+
percent: string;
|
|
399
|
+
};
|
|
400
|
+
};
|
|
401
|
+
/** Costs use captured rates; provider-reported amounts are analysis-only. */
|
|
402
|
+
export type BillingFacts = {
|
|
403
|
+
totalInputTokens: number | null;
|
|
404
|
+
supplierPrice: TokenPrice | null;
|
|
405
|
+
supplierCost: string | null;
|
|
406
|
+
calculatedSupplierCost: string | null;
|
|
407
|
+
reportedSupplierCost: string | null;
|
|
408
|
+
supplierCostSource: "calculated" | "unknown";
|
|
409
|
+
supplierCostDifference: string | null;
|
|
410
|
+
customerPricing: CustomerPricing;
|
|
411
|
+
customerBasisPrice: TokenPrice | null;
|
|
412
|
+
customerBasisCost: string | null;
|
|
413
|
+
customerBasisSource: "calculated" | "unknown" | "model_schedule";
|
|
414
|
+
customerPrice: TokenPrice | null;
|
|
415
|
+
customerCost: string | null;
|
|
416
|
+
grossMarginAmount: string | null;
|
|
417
|
+
grossMarginPercent: string | null;
|
|
418
|
+
};
|
|
342
419
|
export type TimingInterval = {
|
|
343
420
|
id: string;
|
|
344
421
|
requestId: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** External server SDK. Operator APIs and cookie sessions are internal-only clients. */
|
|
2
2
|
import { RequestClient, type WebhookEvent, type Json, type Page, type PageQuery, type ModelResolution, type RequestRecord, type RequestEvent, type RecordTypes, type Timeline, type TimelineRow, type RequestListQuery, type RequestRecordsQuery, type RequestTimings, type TokenUsage } from "../../client-core/src/index";
|
|
3
3
|
export { ConstellationError, uuid7 } from "../../client-core/src/index";
|
|
4
|
-
export type { Json, Tool, ToolCall, Message, RequestEventModes, RequestInput, RequestTimings, TimingInterval, TokenUsage, Status, RequestRecord, Step, Attempt, PreparedStep, PendingInput, Span, TimelineRow, Timeline, Log, Inspection, RecordTypes, InputResponse, InputHandlers, RequestEvent, Page, PageQuery, ModelScope, ModelResolution, WebhookEvent, RequestRecordsQuery, RequestListQuery, StartSpanOptions } from "../../client-core/src/index";
|
|
4
|
+
export type { InferenceParameters, Json, Tool, ToolCall, Message, RequestEventModes, RequestInput, RequestTimings, TimingInterval, TokenUsage, TokenPrice, CustomerPricing, BillingFacts, Status, RequestRecord, Step, Attempt, PreparedStep, PendingInput, Span, TimelineRow, Timeline, Log, Inspection, RecordTypes, InputResponse, InputHandlers, RequestEvent, Page, PageQuery, ModelScope, ModelResolution, WebhookEvent, RequestRecordsQuery, RequestListQuery, StartSpanOptions } from "../../client-core/src/index";
|
|
5
5
|
/** OpenAPI contract filtered to this key's permissions and scope. */
|
|
6
6
|
export type DiscoveryDocument = {
|
|
7
7
|
openapi: string;
|