@relayplane/sdk
Version:
RelayPlane SDK - Local-first AI workflow engine for building multi-step AI workflows
68 lines • 2.14 kB
TypeScript
/**
* RelayPlane SDK v3 - Policy Execution
*
* Provides policy-based execution with fallback and cost controls.
* Policies encapsulate model selection, retry behavior, and cost limits
* for standardized AI execution patterns.
*
* @packageDocumentation
*/
import type { Policy, PolicyExecuteInput, PolicyExecuteResult } from './v3-types';
/**
* Executes a prompt using a policy configuration.
*
* Policies provide standardized execution patterns with:
* - Primary model selection
* - Automatic fallback on failure
* - Cost controls and limits
* - Retry configuration
*
* @param policyId - ID of the policy to use (must be configured via relay.configure())
* @param input - Execution input (prompt, variables, schema)
* @returns Execution result with output, usage, and metadata
*
* @throws Error if policy is not found
* @throws Error if required provider is not configured
*
* @example
* ```typescript
* import { relay } from '@relayplane/sdk';
*
* // Configure policies
* relay.configure({
* providers: {
* openai: { apiKey: process.env.OPENAI_API_KEY! },
* anthropic: { apiKey: process.env.ANTHROPIC_API_KEY! }
* },
* policies: {
* 'fast-analysis': {
* id: 'fast-analysis',
* model: 'openai:gpt-4o',
* fallback: ['anthropic:claude-sonnet-4-20250514'],
* costCaps: { maxCostPerExecution: 0.10 }
* }
* }
* });
*
* // Execute using policy
* const result = await relay.execute('fast-analysis', {
* prompt: 'Analyze this document and extract key points',
* variables: { document: docText }
* });
*
* if (result.success) {
* console.log(result.output);
* console.log(`Cost: $${result.usage.estimatedCostUsd}`);
* }
* ```
*/
export declare function execute(policyId: string, input: PolicyExecuteInput): Promise<PolicyExecuteResult>;
/**
* Gets details about a policy.
* Useful for introspection and debugging.
*
* @param policyId - ID of the policy
* @returns Policy configuration or undefined if not found
*/
export declare function getPolicyDetails(policyId: string): Policy | undefined;
//# sourceMappingURL=v3-policy.d.ts.map