Skip to content

Options

typescript
const result = await generate(model, schema, prompt, {
  maxRetries: 3,        // default: 2
  temperature: 0.2,
  systemPrompt: "You are a data extraction assistant.",
});
OptionPurpose
maxRetriesattempts before throwing MaxRetriesExceededError (default: 2)
temperatureforwarded to the backend, where supported
systemPromptprepended instruction, combined with the schema-derived prompt
timeoutMsbound a single attempt's wall-clock time - see Timeouts & Cancellation
signalan AbortSignal to cancel an in-flight attempt - see Timeouts & Cancellation
jsonSchemaValidatoroverride the built-in jsonSchema structural check - see Pluggable JSON Schema Validation
semanticValidatorcontent/grounding check after structural validation passes - see Staged Validation Pipeline
confidenceScorerassigns a 0-1 score to result.confidence - see Staged Validation Pipeline
minConfidencefails and retries the attempt if confidenceScorer's score is below this
postProcessorsarray of transforms applied in order to an already-validated value - see Staged Validation Pipeline

Released under the Apache-2.0 License.