@broberg/ai-sdk 0.15.0 → 0.16.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/dist/index.d.ts +16 -3
- package/dist/index.js +15 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1733,6 +1733,19 @@ interface BflAdapterConfig {
|
|
|
1733
1733
|
/** Override the per-image USD price (else the built-in finetuned-inference estimate). */
|
|
1734
1734
|
pricePerImage?: number;
|
|
1735
1735
|
}
|
|
1736
|
+
/** Remaining BFL account credits + their USD value (1 credit = $0.01). */
|
|
1737
|
+
interface BflCredits {
|
|
1738
|
+
credits: number;
|
|
1739
|
+
usd: number;
|
|
1740
|
+
}
|
|
1741
|
+
/** F023.6 — check the BFL account's remaining credit balance (`GET /v1/credits`).
|
|
1742
|
+
* Account-level (region-independent); EU-pinned by default for consistency. Use it
|
|
1743
|
+
* for budget-gating before a generate call: `if ((await bflCredits()).usd < 1) …`. */
|
|
1744
|
+
declare function bflCredits(opts?: {
|
|
1745
|
+
apiKey?: string;
|
|
1746
|
+
baseUrl?: string;
|
|
1747
|
+
fetch?: typeof fetch;
|
|
1748
|
+
}): Promise<BflCredits>;
|
|
1736
1749
|
declare function bflAdapter(config?: BflAdapterConfig): ProviderAdapter;
|
|
1737
1750
|
|
|
1738
1751
|
interface OpenAICompatibleConfig {
|
|
@@ -1768,8 +1781,8 @@ declare const falStubAdapter: ProviderAdapter;
|
|
|
1768
1781
|
* wires the live adapters. */
|
|
1769
1782
|
declare const stubProviders: Record<string, ProviderAdapter>;
|
|
1770
1783
|
|
|
1771
|
-
declare const VERSION: "0.
|
|
1772
|
-
declare const SDK_TAG: "@broberg/ai-sdk@0.
|
|
1784
|
+
declare const VERSION: "0.16.0";
|
|
1785
|
+
declare const SDK_TAG: "@broberg/ai-sdk@0.16.0";
|
|
1773
1786
|
|
|
1774
1787
|
/** Built-in defaults. Every entry is overridable via AiConfig.defaults or a
|
|
1775
1788
|
* per-call override. Model IDs are current at scaffold time; callers pin their
|
|
@@ -1995,4 +2008,4 @@ interface StreamTransportRequest extends TransportRequest {
|
|
|
1995
2008
|
*/
|
|
1996
2009
|
declare function streamTransport(req: StreamTransportRequest): AsyncIterable<string>;
|
|
1997
2010
|
|
|
1998
|
-
export { type AiClient, type AiConfig, type BatchJob, type BatchRequestItem, type BatchResultItem, type BflAdapterConfig, type BudgetConfig, BudgetExceededError, BudgetGuard, type BudgetStore, type CallOptions, type Capability, type ChatInput, type ChatRequest, type ChatResult, type ChatStreamEvent, type ClassifyInput, type ClassifyResult, type ContentPart, type Contracts, type CostSink, type CostSummary, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DialogueRequest, type DialogueTurn, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, type EmbeddingRequest, type EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type HttpResponse, type ImageInput, type ImageRequest, type ImageResult, type LoraWeight, type Message, type MockupInput, type MockupResult, type ModerationInput, type ModerationItem, type ModerationRequest, type ModerationResult, type OcrInput, type OcrPage, type OcrRequest, type OcrResult, type OpenAICompatibleConfig, type PodcastInput, type PodcastResult, type PricingEntry, type ProviderAdapter, type RefreshOptions, type RefreshResult, type RerankInput, type RerankResult, type Role, SDK_TAG, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, type Tier, type TierSpec, type Tool, type ToolCall, type TrainStyleInput, type TrainStyleRequest, type TrainStyleResult, type TranscribeInput, type TranscribeRequest, type TranscribeResult, type TranslateInput, type TranslateResult, type Transport, type TransportRequest, type TransportResponse, type TtsInput, type TtsRequest, type UpmetricsSinkConfig, type Usage, VERSION, type VideoInput, type VisionInput, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, bflAdapter, chatInputSchema, computeCost, createAI, deepinfraAdapter, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, makeContracts, makeOpenAICompatibleAdapter, messageSchema, mistralAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, refreshAvailability, resetRefreshState, resetRegistry, resolveTier, resolveVoice, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, upmetricsSink, visionInputSchema };
|
|
2011
|
+
export { type AiClient, type AiConfig, type BatchJob, type BatchRequestItem, type BatchResultItem, type BflAdapterConfig, type BflCredits, type BudgetConfig, BudgetExceededError, BudgetGuard, type BudgetStore, type CallOptions, type Capability, type ChatInput, type ChatRequest, type ChatResult, type ChatStreamEvent, type ClassifyInput, type ClassifyResult, type ContentPart, type Contracts, type CostSink, type CostSummary, DEFAULT_TIER_MAP, type DesignInput, type DesignResult, type DialogueRequest, type DialogueTurn, type DiscordSinkConfig, ELEVENLABS_DANISH_VOICES, type EmbeddingInput, type EmbeddingRequest, type EmbeddingResult, type ExtractInput, type ExtractResult, type FalAdapterConfig, type HttpResponse, type ImageInput, type ImageRequest, type ImageResult, type LoraWeight, type Message, type MockupInput, type MockupResult, type ModerationInput, type ModerationItem, type ModerationRequest, type ModerationResult, type OcrInput, type OcrPage, type OcrRequest, type OcrResult, type OpenAICompatibleConfig, type PodcastInput, type PodcastResult, type PricingEntry, type ProviderAdapter, type RefreshOptions, type RefreshResult, type RerankInput, type RerankResult, type Role, SDK_TAG, type SqliteBudgetStoreConfig, type SqliteSinkConfig, StreamHttpError, type SubprocessResponse, type Tier, type TierSpec, type Tool, type ToolCall, type TrainStyleInput, type TrainStyleRequest, type TrainStyleResult, type TranscribeInput, type TranscribeRequest, type TranscribeResult, type TranslateInput, type TranslateResult, type Transport, type TransportRequest, type TransportResponse, type TtsInput, type TtsRequest, type UpmetricsSinkConfig, type Usage, VERSION, type VideoInput, type VisionInput, aiConfigSchema, anthropicAdapter, anthropicApiAdapter, anthropicSubprocessAdapter, bflAdapter, bflCredits, chatInputSchema, computeCost, createAI, deepinfraAdapter, defaultProviders, discordSink, elevenlabsAdapter, embeddingInputSchema, falAdapter, falStubAdapter, freshUsage, fromProviderToolCall, geminiAdapter, getCostSummary, getPrice, httpTransport, imageInputSchema, makeContracts, makeOpenAICompatibleAdapter, messageSchema, mistralAdapter, multiSink, noopSink, openaiAdapter, openaiStubAdapter, openrouterAdapter, parseClaudeCliJson, parseJsonLoose, refreshAvailability, resetRefreshState, resetRegistry, resolveTier, resolveVoice, sqliteBudgetStore, sqliteSink, streamTransport, stubProviders, subprocessTransport, tierSpecSchema, toProviderTools, toolSchema, translateInputSchema, upmetricsSink, visionInputSchema };
|
package/dist/index.js
CHANGED
|
@@ -1581,6 +1581,18 @@ var sleep2 = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
|
1581
1581
|
function gcd(a, b) {
|
|
1582
1582
|
return b === 0 ? a : gcd(b, a % b);
|
|
1583
1583
|
}
|
|
1584
|
+
async function bflCredits(opts = {}) {
|
|
1585
|
+
const apiKey = opts.apiKey ?? process.env.BFL_API_KEY;
|
|
1586
|
+
if (!apiKey) throw new Error("bflCredits: BFL_API_KEY not set");
|
|
1587
|
+
const doFetch = opts.fetch ?? fetch;
|
|
1588
|
+
const res = await doFetch(`${opts.baseUrl ?? EU_BASE}/v1/credits`, { headers: { "x-key": apiKey } });
|
|
1589
|
+
if (!res.ok) {
|
|
1590
|
+
throw new Error(`bflCredits ${res.status}: ${(await res.text().catch(() => "")).slice(0, 200)}`);
|
|
1591
|
+
}
|
|
1592
|
+
const data = await res.json();
|
|
1593
|
+
const credits = typeof data.credits === "number" ? data.credits : 0;
|
|
1594
|
+
return { credits, usd: credits * BFL_CREDIT_USD };
|
|
1595
|
+
}
|
|
1584
1596
|
function bflAdapter(config = {}) {
|
|
1585
1597
|
const doFetch = config.fetch ?? fetch;
|
|
1586
1598
|
const base = config.baseUrl ?? EU_BASE;
|
|
@@ -2621,8 +2633,8 @@ var stubProviders = {
|
|
|
2621
2633
|
};
|
|
2622
2634
|
|
|
2623
2635
|
// src/version.ts
|
|
2624
|
-
var VERSION = "0.
|
|
2625
|
-
var SDK_TAG = "@broberg/ai-sdk@0.
|
|
2636
|
+
var VERSION = "0.16.0";
|
|
2637
|
+
var SDK_TAG = "@broberg/ai-sdk@0.16.0";
|
|
2626
2638
|
|
|
2627
2639
|
// src/availability/refresh.ts
|
|
2628
2640
|
var NOT_REFRESHED = { refreshed: false, checked: 0, markedUnavailable: [] };
|
|
@@ -2909,6 +2921,7 @@ export {
|
|
|
2909
2921
|
anthropicApiAdapter,
|
|
2910
2922
|
anthropicSubprocessAdapter,
|
|
2911
2923
|
bflAdapter,
|
|
2924
|
+
bflCredits,
|
|
2912
2925
|
chatInputSchema,
|
|
2913
2926
|
computeCost,
|
|
2914
2927
|
createAI,
|