Skip to content

Function: createConfig()

Prefactor TypeScript SDK


Prefactor TypeScript SDK / @prefactor/core / createConfig

createConfig(options?): object

Defined in: packages/core/src/config.ts:135

Creates a validated configuration object by merging provided options with environment variables and defaults.

Partial<{ transportType: "http"; sampleRate: number; captureInputs: boolean; captureOutputs: boolean; maxInputLength: number; maxOutputLength: number; httpConfig?: { apiUrl: string; apiToken: string; agentId?: string; agentIdentifier?: string; agentName?: string; agentDescription?: string; agentSchema?: Record<string, unknown>; requestTimeout?: number; maxRetries?: number; initialRetryDelay?: number; maxRetryDelay?: number; retryMultiplier?: number; retryOnStatusCodes?: number[]; }; failureHandling?: { onFatalError?: (error) => void; }; }>

Partial configuration options

Validated configuration object

transportType: "http"

Transport type to use for span emission

sampleRate: number

Sampling rate (0.0 to 1.0)

captureInputs: boolean

Whether to capture span inputs

captureOutputs: boolean

Whether to capture span outputs

maxInputLength: number

Maximum length for input strings

maxOutputLength: number

Maximum length for output strings

optional httpConfig: object

HTTP transport configuration (required if transportType is ‘http’)

apiUrl: string

apiToken: string

optional agentId: string

optional agentIdentifier: string

optional agentName: string

optional agentDescription: string

optional agentSchema: Record<string, unknown>

optional requestTimeout: number

optional maxRetries: number

optional initialRetryDelay: number

optional maxRetryDelay: number

optional retryMultiplier: number

optional retryOnStatusCodes: number[]

optional failureHandling: object

Optional failure handling callbacks.

optional onFatalError: (error) => void

PrefactorFatalError

void

If configuration is invalid

const config = createConfig({
transportType: 'http',
httpConfig: {
apiUrl: 'https://app.prefactorai.com',
apiToken: process.env.PREFACTOR_API_TOKEN!,
}
});