/** * `ai` namespace — project-scoped AI add-ons (translation, moderation) and * wallet-scoped image generation. */ import type { Client, PaymentSettlement } from "../kernel.js"; export interface TranslateOptions { text: string; to: string; from?: string; context?: string; } export interface TranslateResult { text: string; from: string; to: string; } export interface ModerateResult { flagged: boolean; categories: Record; category_scores: Record; } export interface AiUsageResult { translation: { active: boolean; used_words: number; included_words: number; remaining_words: number; billing_cycle_start: string; }; } export type ImageAspect = "square" | "landscape" | "portrait"; export interface GenerateImageOptions { prompt: string; aspect?: ImageAspect; /** * The paying organization. Needed only on the MPP Lightning rail when the * calling principal belongs to more than one organization; x402 ignores it. * * When omitted and the gateway answers `ORGANIZATION_SELECTION_REQUIRED`, * the SDK retries ONCE with the one candidate from * `details.organization_ids` that matches a local context — the * provider's active organization (`run402 org use`) or the active * project's cached owning org, else any locally stored project's owning * org. Zero or several matches surface the error with the candidate ids * and a next action naming `--org` / `orgId`. Nothing is ever inferred * from membership count alone. */ orgId?: string; } /** The gateway's answer when a multi-org principal names no paying org on the Lightning rail. */ export declare const ORGANIZATION_SELECTION_REQUIRED = "ORGANIZATION_SELECTION_REQUIRED"; /** `details.organization_ids` off an `ORGANIZATION_SELECTION_REQUIRED` error, else `[]`. */ export declare function organizationCandidatesFromError(err: unknown): string[]; export interface GenerateImageResult { /** Base64-encoded bytes. */ image: string; content_type: string; aspect: string; /** * What actually settled for THIS call, from the seller's settlement receipt. * * `null` when the response carried no receipt — meaning no payment was made * on this request (e.g. a prepaid allowance), NOT that one failed. Callers * that report a purchase to a human or an agent should surface `network`: * the documented quickstart faucet-funds Base Sepolia, so a caller can * otherwise watch a payment succeed with no way to know it was test money. */ payment: PaymentSettlement | null; } export declare class Ai { private readonly client; constructor(client: Client); /** Translate text. Requires the AI Translation add-on on the project. */ translate(projectId: string, opts: TranslateOptions): Promise; /** Run content moderation on text. Free for all projects; requires service key. */ moderate(projectId: string, text: string): Promise; /** Get AI translation usage for the current billing cycle. */ usage(projectId: string): Promise; /** * Generate an image from a text prompt. Costs $0.03 via x402, MPP on * Tempo, or MPP Lightning. No project scope — payment flows through the * allowance-based fetch. See {@link GenerateImageOptions.orgId} for how a * multi-org principal's paying organization is chosen on Lightning. */ generateImage(opts: GenerateImageOptions): Promise; } //# sourceMappingURL=ai.d.ts.map