Skip to content

Bitfold Wallet API

interface AIWallet {
constructor(defaults: { model: ModelPreference }): AIWallet;
/** Returns the models that the wallet owner has approved for the app. */
getAvailableModels(): Promise<ModelProperties[]>;
/** Makes a request of the wallet owner to share or configure a model matching the provided set of preferences. */
requestModel(preference: ModelPreference): Promise<void>;
/** Requests that the wallet owner grant read-only access to memories in the wallet. */
requestMemories(memories: MemoryRequest[]): Promise<boolean[]>;
/** OpenAI-compatible chat completions endpoint */
completions: { chat: { create: CreateChatRequest } };
/** Anthropic-compatible chat completions endpoint */
messages: { create: CreateChatRequest };
}
/**
* A an exact model name or a description of the model's preferred properties.
* The wallet will make a best-effort attempt at supplying a suitable model.
*/
type ModelPreference = string | ModelProperties;
/**
* A set of conditions on the model that is used to fulfill a generation request
*/
type ModelProperties = Partial<{
/** The model's reasoning ability, which relates to cost/speed. Default: medium */
reasoningAbility: 'none' | 'low' | 'medium' | 'high' | 'maximum';
/** The minimum necessary context window of the model, in tokens. Default: 4000 */
minContextSize: number;
/** The model's specialization(s), if any. Default: undefined (general purpose) */
specializations: Array<'code'>;
/** ISO-639 codes of additional languages that the model should support. */
languages: string[];
/** Additional features that the model should support. */
features: Array<'structured_output' | 'tool_calling'>;
/**
* The minimum level of privacy that the model must support.
* The privacy level of a model is determined by the wallet owner.
* Default: 'low'
*/
privacyLevel: 'none' | 'low' | 'medium' | 'high' | 'maximum';
}>;
type MemoryRequest = {
/** The contents of the memories to be accessed. */
prompt: string;
/**
* The maximum level of sensitivity of memory requested.
* A lower value is more likely to be accepted and with a lower specificity.
*/
maxSensitivity?: 'low' | 'medium' | 'high';
/**
* How close to the embedded prompt the memory should be on the interval [0,1].
* This can be overridden by the wallet owner.
* Default: 0.5
*/
specificity?: number;
/**
* The superset of domains from which memories will be sourced.
* Most applications will not need to use this feature.
* Default: ['global']
*/
domains?: string[];
};
type CreateChatRequest = (request: ChatRequest) => Promise<ChatResponse>;
/** @see https://openrouter.ai/docs/requests */
type ChatRequest = OpenRouter.Request & { model?: ModelPreference };
/** @see https://openrouter.ai/docs/responses */
type ChatResponse = OpenRouter.Response;