@axlsdk/axl 0.20.0 → 0.20.1
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/dist/index.cjs +1378 -310
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -16
- package/dist/index.d.ts +67 -16
- package/dist/index.js +1378 -310
- package/dist/index.js.map +1 -1
- package/package.json +3 -2
package/dist/index.d.cts
CHANGED
|
@@ -112,6 +112,8 @@ type StreamChunk = {
|
|
|
112
112
|
total_tokens: number;
|
|
113
113
|
reasoning_tokens?: number;
|
|
114
114
|
cached_tokens?: number;
|
|
115
|
+
/** Tokens written to a provider prompt cache during this call, when reported. */
|
|
116
|
+
cache_write_tokens?: number;
|
|
115
117
|
};
|
|
116
118
|
/** Estimated cost in USD for this call, computed the same way as ProviderResponse.cost. */
|
|
117
119
|
cost?: number;
|
|
@@ -859,6 +861,8 @@ type AxlEventBase = {
|
|
|
859
861
|
input?: number;
|
|
860
862
|
output?: number;
|
|
861
863
|
reasoning?: number;
|
|
864
|
+
cached?: number;
|
|
865
|
+
cacheWrite?: number;
|
|
862
866
|
};
|
|
863
867
|
/** Duration in ms (set on `_end` variants and a few single-point events). */
|
|
864
868
|
duration?: number;
|
|
@@ -944,6 +948,8 @@ type LegacyAxlEventPayloadV1 = (AxlEventBase & {
|
|
|
944
948
|
input?: number;
|
|
945
949
|
output?: number;
|
|
946
950
|
reasoning?: number;
|
|
951
|
+
cached?: number;
|
|
952
|
+
cacheWrite?: number;
|
|
947
953
|
};
|
|
948
954
|
/** Response-side payload — response text, thinking. */
|
|
949
955
|
data: AgentCallEndData;
|
|
@@ -1296,6 +1302,8 @@ type ProviderResponse = {
|
|
|
1296
1302
|
total_tokens: number;
|
|
1297
1303
|
reasoning_tokens?: number;
|
|
1298
1304
|
cached_tokens?: number;
|
|
1305
|
+
/** Tokens written to a provider prompt cache during this call, when reported. */
|
|
1306
|
+
cache_write_tokens?: number;
|
|
1299
1307
|
};
|
|
1300
1308
|
cost?: number;
|
|
1301
1309
|
/** Provider-specific opaque metadata that needs to round-trip through conversation history. */
|
|
@@ -1949,6 +1957,8 @@ type PricingTable = Record<string, [number, number, number]>;
|
|
|
1949
1957
|
type PricingSource = {
|
|
1950
1958
|
kind: 'table';
|
|
1951
1959
|
table: PricingTable;
|
|
1960
|
+
/** Exact matching prevents a future sibling from inheriting a base price. */
|
|
1961
|
+
match?: 'prefix' | 'exact';
|
|
1952
1962
|
}
|
|
1953
1963
|
/** Provider reports per-call cost in `usage.cost` (OpenRouter credits ≈ USD). */
|
|
1954
1964
|
| {
|
|
@@ -2075,7 +2085,7 @@ type ProviderProfile = {
|
|
|
2075
2085
|
* versioned snapshots like `gpt-4o-2024-05-13`). Returns `undefined` on a miss —
|
|
2076
2086
|
* callers MUST treat that as "unknown cost", never as free.
|
|
2077
2087
|
*/
|
|
2078
|
-
declare function priceFromTable(table: PricingTable, model: string, promptTokens: number, completionTokens: number, cachedTokens?: number): number | undefined;
|
|
2088
|
+
declare function priceFromTable(table: PricingTable, model: string, promptTokens: number, completionTokens: number, cachedTokens?: number, match?: 'prefix' | 'exact'): number | undefined;
|
|
2079
2089
|
/**
|
|
2080
2090
|
* Incremental scanner that separates streamed content into visible text and
|
|
2081
2091
|
* `<think>…</think>` reasoning, tolerating tags split across chunks.
|
|
@@ -2147,11 +2157,21 @@ declare class OpenAICompatibleProvider implements Provider {
|
|
|
2147
2157
|
protected buildRequestBody(messages: ChatMessage[], options: ChatOptions, stream: boolean): Record<string, unknown>;
|
|
2148
2158
|
protected formatMessage(msg: ChatMessage, model: string): Record<string, unknown>;
|
|
2149
2159
|
protected extractErrorMessage(body: string, status: number): string;
|
|
2160
|
+
private requestModel;
|
|
2150
2161
|
private toUsage;
|
|
2151
|
-
private
|
|
2152
|
-
|
|
2162
|
+
private reportedCost;
|
|
2163
|
+
/**
|
|
2164
|
+
* The generic profile path stays flat and public. Native subclasses may
|
|
2165
|
+
* override this protected seam to use a provider-internal estimator without
|
|
2166
|
+
* widening `PricingSource` or `ProviderProfile`.
|
|
2167
|
+
*/
|
|
2168
|
+
protected computeCost(model: string, usage: ProviderResponse['usage'], reportedCost: number | undefined, context?: {
|
|
2169
|
+
request?: Record<string, unknown>;
|
|
2170
|
+
response?: OpenAIModelResponse;
|
|
2171
|
+
}): number | undefined;
|
|
2172
|
+
protected parseResponse(json: OpenAIChatResponse, model: string, request?: Record<string, unknown>): ProviderResponse;
|
|
2153
2173
|
private roundTripMetadata;
|
|
2154
|
-
protected parseSSEStream(body: ReadableStream<Uint8Array>, model: string): AsyncGenerator<StreamChunk>;
|
|
2174
|
+
protected parseSSEStream(body: ReadableStream<Uint8Array>, model: string, request?: Record<string, unknown>): AsyncGenerator<StreamChunk>;
|
|
2155
2175
|
}
|
|
2156
2176
|
type OpenAIUsage = {
|
|
2157
2177
|
prompt_tokens: number;
|
|
@@ -2162,9 +2182,15 @@ type OpenAIUsage = {
|
|
|
2162
2182
|
};
|
|
2163
2183
|
prompt_tokens_details?: {
|
|
2164
2184
|
cached_tokens?: number;
|
|
2185
|
+
cache_write_tokens?: number;
|
|
2165
2186
|
};
|
|
2166
2187
|
/** OpenRouter / Vercel Gateway: per-call cost in USD. */
|
|
2167
2188
|
cost?: number;
|
|
2189
|
+
/** xAI: exact billed USD cost in ten-billionths of a dollar. */
|
|
2190
|
+
cost_in_usd_ticks?: number;
|
|
2191
|
+
/** DeepSeek: normalized cache hit/miss split for table pricing. */
|
|
2192
|
+
prompt_cache_hit_tokens?: number;
|
|
2193
|
+
prompt_cache_miss_tokens?: number;
|
|
2168
2194
|
};
|
|
2169
2195
|
type OpenAIChatMessage = {
|
|
2170
2196
|
content: string | null | Array<string | {
|
|
@@ -2189,6 +2215,12 @@ type OpenAIChatResponse = {
|
|
|
2189
2215
|
finish_reason: string;
|
|
2190
2216
|
}>;
|
|
2191
2217
|
usage?: OpenAIUsage;
|
|
2218
|
+
} & OpenAIModelResponse;
|
|
2219
|
+
type OpenAIModelResponse = {
|
|
2220
|
+
model?: string;
|
|
2221
|
+
service_tier?: unknown;
|
|
2222
|
+
serviceTier?: unknown;
|
|
2223
|
+
usage?: OpenAIUsage;
|
|
2192
2224
|
};
|
|
2193
2225
|
|
|
2194
2226
|
/** A pending human decision awaiting resolution. */
|
|
@@ -4461,6 +4493,8 @@ declare function hasPositiveTokens(event: {
|
|
|
4461
4493
|
input?: number;
|
|
4462
4494
|
output?: number;
|
|
4463
4495
|
reasoning?: number;
|
|
4496
|
+
cached?: number;
|
|
4497
|
+
cacheWrite?: number;
|
|
4464
4498
|
} | null;
|
|
4465
4499
|
}): boolean;
|
|
4466
4500
|
/**
|
|
@@ -4524,6 +4558,8 @@ declare function isUnpricedLeaf(event: {
|
|
|
4524
4558
|
input?: number;
|
|
4525
4559
|
output?: number;
|
|
4526
4560
|
reasoning?: number;
|
|
4561
|
+
cached?: number;
|
|
4562
|
+
cacheWrite?: number;
|
|
4527
4563
|
} | null;
|
|
4528
4564
|
}): boolean;
|
|
4529
4565
|
/**
|
|
@@ -4739,6 +4775,15 @@ declare class ProviderError extends AxlError {
|
|
|
4739
4775
|
declare function isRetryableStatus(status: number): boolean;
|
|
4740
4776
|
|
|
4741
4777
|
declare const OPENAI_PRICING: PricingTable;
|
|
4778
|
+
type DirectOpenAIPricingContext = {
|
|
4779
|
+
/** Only the canonical direct API endpoint has a usable catalog. */
|
|
4780
|
+
baseUrl?: string;
|
|
4781
|
+
request?: Record<string, unknown>;
|
|
4782
|
+
response?: {
|
|
4783
|
+
service_tier?: unknown;
|
|
4784
|
+
serviceTier?: unknown;
|
|
4785
|
+
};
|
|
4786
|
+
};
|
|
4742
4787
|
/**
|
|
4743
4788
|
* Estimate OpenAI call cost from token usage. Exact match first, then
|
|
4744
4789
|
* longest-prefix match for versioned models (e.g. `gpt-4o-2024-05-13`).
|
|
@@ -4770,6 +4815,7 @@ declare class OpenAIProvider extends OpenAICompatibleProvider {
|
|
|
4770
4815
|
baseUrl?: string;
|
|
4771
4816
|
rateLimit?: RateLimitConfig;
|
|
4772
4817
|
});
|
|
4818
|
+
protected computeCost(model: string, usage: ProviderResponse['usage'], _reportedCost: number | undefined, context?: DirectOpenAIPricingContext): number | undefined;
|
|
4773
4819
|
}
|
|
4774
4820
|
|
|
4775
4821
|
/**
|
|
@@ -4798,6 +4844,7 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
4798
4844
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
4799
4845
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
4800
4846
|
private buildRequestBody;
|
|
4847
|
+
private requestModel;
|
|
4801
4848
|
private buildInput;
|
|
4802
4849
|
/**
|
|
4803
4850
|
* The Responses API uses `text.format` instead of `response_format`.
|
|
@@ -4856,6 +4903,7 @@ declare class AnthropicProvider implements Provider {
|
|
|
4856
4903
|
* - tool messages (tool results) -> user messages with tool_result content blocks
|
|
4857
4904
|
*/
|
|
4858
4905
|
private mapMessages;
|
|
4906
|
+
private getReplayedThinkingBlocks;
|
|
4859
4907
|
/**
|
|
4860
4908
|
* Merge consecutive messages with the same role into a single message.
|
|
4861
4909
|
* This handles cases where multiple tool_result blocks need to be in one user message.
|
|
@@ -4916,6 +4964,11 @@ declare class GeminiProvider implements Provider {
|
|
|
4916
4964
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
4917
4965
|
private buildHeaders;
|
|
4918
4966
|
private extractErrorMessage;
|
|
4967
|
+
private pricingContext;
|
|
4968
|
+
private requestModel;
|
|
4969
|
+
private assertSafeGemini3Continuation;
|
|
4970
|
+
private isTextOnlyClientRequest;
|
|
4971
|
+
private isNonTextGeminiPart;
|
|
4919
4972
|
private buildRequestBody;
|
|
4920
4973
|
/**
|
|
4921
4974
|
* Map OpenAI-format ChatMessages to Gemini content format.
|
|
@@ -4945,6 +4998,7 @@ declare class GeminiProvider implements Provider {
|
|
|
4945
4998
|
private mapToolChoice;
|
|
4946
4999
|
private mapToolDefinition;
|
|
4947
5000
|
private parseResponse;
|
|
5001
|
+
private isTextOnlyGeminiResponse;
|
|
4948
5002
|
private parseSSEStream;
|
|
4949
5003
|
}
|
|
4950
5004
|
|
|
@@ -4954,9 +5008,9 @@ declare class GeminiProvider implements Provider {
|
|
|
4954
5008
|
* - Reasoning is the unified `reasoning` object (`{ effort }` XOR `{ max_tokens }`,
|
|
4955
5009
|
* or `{ enabled: false }`); reasoning text comes back in `message.reasoning`
|
|
4956
5010
|
* with a structured `reasoning_details[]` we round-trip on tool-call turns.
|
|
4957
|
-
* - Cost is provider-reported
|
|
4958
|
-
*
|
|
4959
|
-
*
|
|
5011
|
+
* - Cost is provider-reported in `usage.cost` (USD), so Axl keeps
|
|
5012
|
+
* cost-as-a-primitive working across the whole catalog where a static table
|
|
5013
|
+
* never could. OpenRouter now returns it automatically; no request opt-in.
|
|
4960
5014
|
* - Model ids are `vendor/model` slugs (e.g. `anthropic/claude-opus-4.7`); the
|
|
4961
5015
|
* registry's first-colon split keeps `openrouter:anthropic/claude-…` intact.
|
|
4962
5016
|
*
|
|
@@ -4978,20 +5032,17 @@ declare const OPENROUTER_PROFILE: ProviderProfile;
|
|
|
4978
5032
|
* Entra/AAD bearer-token auth uses the async key callback plus an `authHeader:
|
|
4979
5033
|
* 'bearer'` override.
|
|
4980
5034
|
*
|
|
4981
|
-
* Azure
|
|
4982
|
-
*
|
|
4983
|
-
* detection and pricing only fire when the deployment is named after the model;
|
|
4984
|
-
* otherwise effort is a no-op and cost is `undefined` (honest, not a fake $0).
|
|
5035
|
+
* Azure can share OpenAI's wire reasoning behavior, but never its direct-API
|
|
5036
|
+
* price catalog: model meters, deployment types, regions, and agreements vary.
|
|
4985
5037
|
*/
|
|
4986
5038
|
declare const AZURE_PROFILE: ProviderProfile;
|
|
4987
5039
|
|
|
4988
5040
|
/**
|
|
4989
|
-
* xAI (Grok)
|
|
5041
|
+
* xAI (Grok) Chat Completions at `https://api.x.ai/v1`.
|
|
4990
5042
|
*
|
|
4991
|
-
*
|
|
4992
|
-
*
|
|
4993
|
-
* -
|
|
4994
|
-
* Penalties aren't engine-computed, so they only matter if a user adds them.
|
|
5043
|
+
* Pricing is the exact response total in `usage.cost_in_usd_ticks`; it already
|
|
5044
|
+
* includes cache, service-tier, and server-side-tool charges. Grok 4.20
|
|
5045
|
+
* multi-agent is Responses-only, so it deliberately has no Chat descriptor.
|
|
4995
5046
|
*/
|
|
4996
5047
|
declare const XAI_PROFILE: ProviderProfile;
|
|
4997
5048
|
|
package/dist/index.d.ts
CHANGED
|
@@ -112,6 +112,8 @@ type StreamChunk = {
|
|
|
112
112
|
total_tokens: number;
|
|
113
113
|
reasoning_tokens?: number;
|
|
114
114
|
cached_tokens?: number;
|
|
115
|
+
/** Tokens written to a provider prompt cache during this call, when reported. */
|
|
116
|
+
cache_write_tokens?: number;
|
|
115
117
|
};
|
|
116
118
|
/** Estimated cost in USD for this call, computed the same way as ProviderResponse.cost. */
|
|
117
119
|
cost?: number;
|
|
@@ -859,6 +861,8 @@ type AxlEventBase = {
|
|
|
859
861
|
input?: number;
|
|
860
862
|
output?: number;
|
|
861
863
|
reasoning?: number;
|
|
864
|
+
cached?: number;
|
|
865
|
+
cacheWrite?: number;
|
|
862
866
|
};
|
|
863
867
|
/** Duration in ms (set on `_end` variants and a few single-point events). */
|
|
864
868
|
duration?: number;
|
|
@@ -944,6 +948,8 @@ type LegacyAxlEventPayloadV1 = (AxlEventBase & {
|
|
|
944
948
|
input?: number;
|
|
945
949
|
output?: number;
|
|
946
950
|
reasoning?: number;
|
|
951
|
+
cached?: number;
|
|
952
|
+
cacheWrite?: number;
|
|
947
953
|
};
|
|
948
954
|
/** Response-side payload — response text, thinking. */
|
|
949
955
|
data: AgentCallEndData;
|
|
@@ -1296,6 +1302,8 @@ type ProviderResponse = {
|
|
|
1296
1302
|
total_tokens: number;
|
|
1297
1303
|
reasoning_tokens?: number;
|
|
1298
1304
|
cached_tokens?: number;
|
|
1305
|
+
/** Tokens written to a provider prompt cache during this call, when reported. */
|
|
1306
|
+
cache_write_tokens?: number;
|
|
1299
1307
|
};
|
|
1300
1308
|
cost?: number;
|
|
1301
1309
|
/** Provider-specific opaque metadata that needs to round-trip through conversation history. */
|
|
@@ -1949,6 +1957,8 @@ type PricingTable = Record<string, [number, number, number]>;
|
|
|
1949
1957
|
type PricingSource = {
|
|
1950
1958
|
kind: 'table';
|
|
1951
1959
|
table: PricingTable;
|
|
1960
|
+
/** Exact matching prevents a future sibling from inheriting a base price. */
|
|
1961
|
+
match?: 'prefix' | 'exact';
|
|
1952
1962
|
}
|
|
1953
1963
|
/** Provider reports per-call cost in `usage.cost` (OpenRouter credits ≈ USD). */
|
|
1954
1964
|
| {
|
|
@@ -2075,7 +2085,7 @@ type ProviderProfile = {
|
|
|
2075
2085
|
* versioned snapshots like `gpt-4o-2024-05-13`). Returns `undefined` on a miss —
|
|
2076
2086
|
* callers MUST treat that as "unknown cost", never as free.
|
|
2077
2087
|
*/
|
|
2078
|
-
declare function priceFromTable(table: PricingTable, model: string, promptTokens: number, completionTokens: number, cachedTokens?: number): number | undefined;
|
|
2088
|
+
declare function priceFromTable(table: PricingTable, model: string, promptTokens: number, completionTokens: number, cachedTokens?: number, match?: 'prefix' | 'exact'): number | undefined;
|
|
2079
2089
|
/**
|
|
2080
2090
|
* Incremental scanner that separates streamed content into visible text and
|
|
2081
2091
|
* `<think>…</think>` reasoning, tolerating tags split across chunks.
|
|
@@ -2147,11 +2157,21 @@ declare class OpenAICompatibleProvider implements Provider {
|
|
|
2147
2157
|
protected buildRequestBody(messages: ChatMessage[], options: ChatOptions, stream: boolean): Record<string, unknown>;
|
|
2148
2158
|
protected formatMessage(msg: ChatMessage, model: string): Record<string, unknown>;
|
|
2149
2159
|
protected extractErrorMessage(body: string, status: number): string;
|
|
2160
|
+
private requestModel;
|
|
2150
2161
|
private toUsage;
|
|
2151
|
-
private
|
|
2152
|
-
|
|
2162
|
+
private reportedCost;
|
|
2163
|
+
/**
|
|
2164
|
+
* The generic profile path stays flat and public. Native subclasses may
|
|
2165
|
+
* override this protected seam to use a provider-internal estimator without
|
|
2166
|
+
* widening `PricingSource` or `ProviderProfile`.
|
|
2167
|
+
*/
|
|
2168
|
+
protected computeCost(model: string, usage: ProviderResponse['usage'], reportedCost: number | undefined, context?: {
|
|
2169
|
+
request?: Record<string, unknown>;
|
|
2170
|
+
response?: OpenAIModelResponse;
|
|
2171
|
+
}): number | undefined;
|
|
2172
|
+
protected parseResponse(json: OpenAIChatResponse, model: string, request?: Record<string, unknown>): ProviderResponse;
|
|
2153
2173
|
private roundTripMetadata;
|
|
2154
|
-
protected parseSSEStream(body: ReadableStream<Uint8Array>, model: string): AsyncGenerator<StreamChunk>;
|
|
2174
|
+
protected parseSSEStream(body: ReadableStream<Uint8Array>, model: string, request?: Record<string, unknown>): AsyncGenerator<StreamChunk>;
|
|
2155
2175
|
}
|
|
2156
2176
|
type OpenAIUsage = {
|
|
2157
2177
|
prompt_tokens: number;
|
|
@@ -2162,9 +2182,15 @@ type OpenAIUsage = {
|
|
|
2162
2182
|
};
|
|
2163
2183
|
prompt_tokens_details?: {
|
|
2164
2184
|
cached_tokens?: number;
|
|
2185
|
+
cache_write_tokens?: number;
|
|
2165
2186
|
};
|
|
2166
2187
|
/** OpenRouter / Vercel Gateway: per-call cost in USD. */
|
|
2167
2188
|
cost?: number;
|
|
2189
|
+
/** xAI: exact billed USD cost in ten-billionths of a dollar. */
|
|
2190
|
+
cost_in_usd_ticks?: number;
|
|
2191
|
+
/** DeepSeek: normalized cache hit/miss split for table pricing. */
|
|
2192
|
+
prompt_cache_hit_tokens?: number;
|
|
2193
|
+
prompt_cache_miss_tokens?: number;
|
|
2168
2194
|
};
|
|
2169
2195
|
type OpenAIChatMessage = {
|
|
2170
2196
|
content: string | null | Array<string | {
|
|
@@ -2189,6 +2215,12 @@ type OpenAIChatResponse = {
|
|
|
2189
2215
|
finish_reason: string;
|
|
2190
2216
|
}>;
|
|
2191
2217
|
usage?: OpenAIUsage;
|
|
2218
|
+
} & OpenAIModelResponse;
|
|
2219
|
+
type OpenAIModelResponse = {
|
|
2220
|
+
model?: string;
|
|
2221
|
+
service_tier?: unknown;
|
|
2222
|
+
serviceTier?: unknown;
|
|
2223
|
+
usage?: OpenAIUsage;
|
|
2192
2224
|
};
|
|
2193
2225
|
|
|
2194
2226
|
/** A pending human decision awaiting resolution. */
|
|
@@ -4461,6 +4493,8 @@ declare function hasPositiveTokens(event: {
|
|
|
4461
4493
|
input?: number;
|
|
4462
4494
|
output?: number;
|
|
4463
4495
|
reasoning?: number;
|
|
4496
|
+
cached?: number;
|
|
4497
|
+
cacheWrite?: number;
|
|
4464
4498
|
} | null;
|
|
4465
4499
|
}): boolean;
|
|
4466
4500
|
/**
|
|
@@ -4524,6 +4558,8 @@ declare function isUnpricedLeaf(event: {
|
|
|
4524
4558
|
input?: number;
|
|
4525
4559
|
output?: number;
|
|
4526
4560
|
reasoning?: number;
|
|
4561
|
+
cached?: number;
|
|
4562
|
+
cacheWrite?: number;
|
|
4527
4563
|
} | null;
|
|
4528
4564
|
}): boolean;
|
|
4529
4565
|
/**
|
|
@@ -4739,6 +4775,15 @@ declare class ProviderError extends AxlError {
|
|
|
4739
4775
|
declare function isRetryableStatus(status: number): boolean;
|
|
4740
4776
|
|
|
4741
4777
|
declare const OPENAI_PRICING: PricingTable;
|
|
4778
|
+
type DirectOpenAIPricingContext = {
|
|
4779
|
+
/** Only the canonical direct API endpoint has a usable catalog. */
|
|
4780
|
+
baseUrl?: string;
|
|
4781
|
+
request?: Record<string, unknown>;
|
|
4782
|
+
response?: {
|
|
4783
|
+
service_tier?: unknown;
|
|
4784
|
+
serviceTier?: unknown;
|
|
4785
|
+
};
|
|
4786
|
+
};
|
|
4742
4787
|
/**
|
|
4743
4788
|
* Estimate OpenAI call cost from token usage. Exact match first, then
|
|
4744
4789
|
* longest-prefix match for versioned models (e.g. `gpt-4o-2024-05-13`).
|
|
@@ -4770,6 +4815,7 @@ declare class OpenAIProvider extends OpenAICompatibleProvider {
|
|
|
4770
4815
|
baseUrl?: string;
|
|
4771
4816
|
rateLimit?: RateLimitConfig;
|
|
4772
4817
|
});
|
|
4818
|
+
protected computeCost(model: string, usage: ProviderResponse['usage'], _reportedCost: number | undefined, context?: DirectOpenAIPricingContext): number | undefined;
|
|
4773
4819
|
}
|
|
4774
4820
|
|
|
4775
4821
|
/**
|
|
@@ -4798,6 +4844,7 @@ declare class OpenAIResponsesProvider implements Provider {
|
|
|
4798
4844
|
chat(messages: ChatMessage[], options: ChatOptions): Promise<ProviderResponse>;
|
|
4799
4845
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
4800
4846
|
private buildRequestBody;
|
|
4847
|
+
private requestModel;
|
|
4801
4848
|
private buildInput;
|
|
4802
4849
|
/**
|
|
4803
4850
|
* The Responses API uses `text.format` instead of `response_format`.
|
|
@@ -4856,6 +4903,7 @@ declare class AnthropicProvider implements Provider {
|
|
|
4856
4903
|
* - tool messages (tool results) -> user messages with tool_result content blocks
|
|
4857
4904
|
*/
|
|
4858
4905
|
private mapMessages;
|
|
4906
|
+
private getReplayedThinkingBlocks;
|
|
4859
4907
|
/**
|
|
4860
4908
|
* Merge consecutive messages with the same role into a single message.
|
|
4861
4909
|
* This handles cases where multiple tool_result blocks need to be in one user message.
|
|
@@ -4916,6 +4964,11 @@ declare class GeminiProvider implements Provider {
|
|
|
4916
4964
|
stream(messages: ChatMessage[], options: ChatOptions): AsyncGenerator<StreamChunk>;
|
|
4917
4965
|
private buildHeaders;
|
|
4918
4966
|
private extractErrorMessage;
|
|
4967
|
+
private pricingContext;
|
|
4968
|
+
private requestModel;
|
|
4969
|
+
private assertSafeGemini3Continuation;
|
|
4970
|
+
private isTextOnlyClientRequest;
|
|
4971
|
+
private isNonTextGeminiPart;
|
|
4919
4972
|
private buildRequestBody;
|
|
4920
4973
|
/**
|
|
4921
4974
|
* Map OpenAI-format ChatMessages to Gemini content format.
|
|
@@ -4945,6 +4998,7 @@ declare class GeminiProvider implements Provider {
|
|
|
4945
4998
|
private mapToolChoice;
|
|
4946
4999
|
private mapToolDefinition;
|
|
4947
5000
|
private parseResponse;
|
|
5001
|
+
private isTextOnlyGeminiResponse;
|
|
4948
5002
|
private parseSSEStream;
|
|
4949
5003
|
}
|
|
4950
5004
|
|
|
@@ -4954,9 +5008,9 @@ declare class GeminiProvider implements Provider {
|
|
|
4954
5008
|
* - Reasoning is the unified `reasoning` object (`{ effort }` XOR `{ max_tokens }`,
|
|
4955
5009
|
* or `{ enabled: false }`); reasoning text comes back in `message.reasoning`
|
|
4956
5010
|
* with a structured `reasoning_details[]` we round-trip on tool-call turns.
|
|
4957
|
-
* - Cost is provider-reported
|
|
4958
|
-
*
|
|
4959
|
-
*
|
|
5011
|
+
* - Cost is provider-reported in `usage.cost` (USD), so Axl keeps
|
|
5012
|
+
* cost-as-a-primitive working across the whole catalog where a static table
|
|
5013
|
+
* never could. OpenRouter now returns it automatically; no request opt-in.
|
|
4960
5014
|
* - Model ids are `vendor/model` slugs (e.g. `anthropic/claude-opus-4.7`); the
|
|
4961
5015
|
* registry's first-colon split keeps `openrouter:anthropic/claude-…` intact.
|
|
4962
5016
|
*
|
|
@@ -4978,20 +5032,17 @@ declare const OPENROUTER_PROFILE: ProviderProfile;
|
|
|
4978
5032
|
* Entra/AAD bearer-token auth uses the async key callback plus an `authHeader:
|
|
4979
5033
|
* 'bearer'` override.
|
|
4980
5034
|
*
|
|
4981
|
-
* Azure
|
|
4982
|
-
*
|
|
4983
|
-
* detection and pricing only fire when the deployment is named after the model;
|
|
4984
|
-
* otherwise effort is a no-op and cost is `undefined` (honest, not a fake $0).
|
|
5035
|
+
* Azure can share OpenAI's wire reasoning behavior, but never its direct-API
|
|
5036
|
+
* price catalog: model meters, deployment types, regions, and agreements vary.
|
|
4985
5037
|
*/
|
|
4986
5038
|
declare const AZURE_PROFILE: ProviderProfile;
|
|
4987
5039
|
|
|
4988
5040
|
/**
|
|
4989
|
-
* xAI (Grok)
|
|
5041
|
+
* xAI (Grok) Chat Completions at `https://api.x.ai/v1`.
|
|
4990
5042
|
*
|
|
4991
|
-
*
|
|
4992
|
-
*
|
|
4993
|
-
* -
|
|
4994
|
-
* Penalties aren't engine-computed, so they only matter if a user adds them.
|
|
5043
|
+
* Pricing is the exact response total in `usage.cost_in_usd_ticks`; it already
|
|
5044
|
+
* includes cache, service-tier, and server-side-tool charges. Grok 4.20
|
|
5045
|
+
* multi-agent is Responses-only, so it deliberately has no Chat descriptor.
|
|
4995
5046
|
*/
|
|
4996
5047
|
declare const XAI_PROFILE: ProviderProfile;
|
|
4997
5048
|
|