import { type ModelDirectory, type BillingSummary, type ModelRequest, type ModelOperation, type ModelStreamEvent, type ModelRecoveryOptions, type ModelTools, type ModelToolRequest } from './model-usage.js'; export * from './model-usage.js'; export declare const USAGE_V1_PATHS: { readonly capabilities: "/usage/v1/capabilities"; }; export type UsageBinding = { hubUrl: string; userId: string; accountId: string; serviceId: string; }; export type UsageCapabilities = { schema: 'bailing.usage.v1'; supported: true; modes: ('credits' | 'periodic')[]; streaming: true; orchestration: 'host'; model_gateway: { schema: 'bailing.model-gateway.v1'; supported: true; orchestration: 'host'; streaming: true; requests_path: string; models_path: string; summary_path: string; billing_unit: 'USD'; turn_required: false; provider_response: 'bailing.provider-response.v1'; settlement: 'asynchronous'; model_tools?: { schema: 'bailing.model-tools.v1'; directory: boolean; execution: boolean; tools_path: string; requests_path?: string; }; output_budget?: { schema: 'bailing.model-output-budget.v1'; separate_default: true; explicit_parameter: true; explicit_scope: true; }; }; }; export type UsageModelDescriptor = { schema: 'bailing.usage-model.v1'; service_id: string; service_revision: number; label: string; model: string; billing_rate?: { multiplier: number; }; state: string; orchestration: 'host'; streaming: true; input_formats: string[]; model_modalities: ('text' | 'image')[] | null; context_window_tokens: number | null; max_input_bytes: number; input_limit_scope: 'serialized_provider_request'; max_messages: number; max_tools: number; /** Operator's service ceiling, not the supplier's model capability. */ max_output_tokens: number; timeout_ms: number; provider_options: string[]; /** Present together only when the service has an explicit output-budget policy. */ default_output_tokens?: number; output_token_parameter?: UsageOutputTokenParameter; output_budget_scope?: UsageOutputBudgetScope; /** Verified supplier limit for this policy's parameter and scope; unknown stays absent. */ model_max_output_tokens?: number; }; export type UsageOutputTokenParameter = 'max_tokens' | 'max_completion_tokens'; export type UsageOutputBudgetScope = 'completion_total' | 'final_answer'; export type UsageModelOutputBudget = { mode: 'legacy'; defaultTokens: number; maxTokens: number; parameter: null; scope: null; modelMaxTokens: null; } | { mode: 'explicit'; defaultTokens: number; maxTokens: number; parameter: UsageOutputTokenParameter; scope: UsageOutputBudgetScope; modelMaxTokens: number | null; }; export type UsageOutputBudgetDescriptor = Pick; export type UsageInputLimit = { kind: 'serialized_provider_bytes'; actual: number; allowed: number; message_count: number; tool_count: number; }; export type UsageOutputLimit = { actual: number; allowed: number; parameter: UsageOutputTokenParameter; scope?: UsageOutputBudgetScope; }; export type UsageOutputBudgetFeedback = { expected_parameter: UsageOutputTokenParameter; scope: UsageOutputBudgetScope; }; export type UsageRequestOptions = { signal?: AbortSignal; }; export type UsageClientOptions = { hubUrl: string; userId: string; accountId: string; serviceId: string; /** A short-lived Usage session token from the trusted product backend, never an Agent/Client/issuer token. */ accessTokenProvider: () => string | Promise; allowInsecureHttp?: boolean; fetchImpl?: typeof fetch; timeoutMs?: number; }; export type UsageFeedback = { schema: 'bailing.usage-feedback.v1'; code: string; dispatch: 'not_dispatched' | 'unknown'; next_action: 'wait_for_capacity' | 'upgrade_required' | 'reauthenticate' | 'authenticate' | 'contact_operator' | 'wait_for_reset' | 'retry_original' | 'inspect_original' | 'upgrade' | 'resolve_error' | 'select_model'; retryable: boolean; input_limit?: UsageInputLimit; output_limit?: UsageOutputLimit; output_budget?: UsageOutputBudgetFeedback; }; /** Sanitized transport failure. Original request identifiers stay available for read-only recovery. */ export declare class BailingHubUsageError extends Error { readonly code: string; readonly status: number | undefined; readonly dispatch: UsageFeedback['dispatch']; readonly operationId?: string | undefined; readonly turnId?: string | undefined; readonly resetAt?: string | number | undefined; readonly feedback: UsageFeedback; constructor(code: string, status: number | undefined, dispatch: UsageFeedback['dispatch'], operationId?: string | undefined, turnId?: string | undefined, resetAt?: string | number | undefined, serverFeedback?: Partial); } /** * Resolve a validated service policy without inferring a supplier limit or reasoning scope. * Legacy defaultTokens is the old ceiling-as-default fallback, not a separate configured default. */ export declare function resolveModelOutputBudget(descriptor: UsageOutputBudgetDescriptor): UsageModelOutputBudget; /** Build one output option for a new request; never converts an existing wire request or recovery snapshot. */ export declare function modelOutputOptions(descriptor: UsageOutputBudgetDescriptor, options?: { tokens?: number; parameter?: UsageOutputTokenParameter; }): Partial>; /** * Optional host API; no management tools and no automatic retries. This client only meters * requests sent through the controlled service. Direct BYOK/model requests remain outside it. */ export declare class BailingHubUsageClient { private readonly options; readonly binding: Readonly; private readonly fetchImpl; private readonly timeoutMs; constructor(options: UsageClientOptions); private open; private request; private decode; capabilities(options?: UsageRequestOptions): Promise; private validateModel; /** Read the live plan/credential intersection. Labels are display text, not model identity. */ modelModels(options?: UsageRequestOptions): Promise; /** Only the authenticated account's plan tools; reading this catalog performs no generation. */ modelTools(options?: UsageRequestOptions): Promise; /** One generation operation. Unknown transport outcomes must be inspected by this original ID. */ runModelTool(input: ModelToolRequest, options?: UsageRequestOptions): Promise; modelSummary(options?: UsageRequestOptions): Promise; private validatePresentation; private modelInput; modelComplete(input: ModelRequest, options?: UsageRequestOptions): Promise; modelStream(input: ModelRequest, options?: UsageRequestOptions): AsyncGenerator; inspectModelRequest(operationId: string, options?: ModelRecoveryOptions): Promise; cancelModelRequest(operationId: string, options?: ModelRecoveryOptions): Promise; private modelOperation; } export declare function createUsageClient(options: UsageClientOptions): BailingHubUsageClient; //# sourceMappingURL=usage.d.ts.map