GenerateText, GenerateObject, and optionally EmbedText—to each factory. This keeps the SDK provider-agnostic: you own the model client, the retry logic, the token budget, and any observability instrumentation.
Callback type reference
GenerateText
Used by query, application, PCE, and agent prompt workflows for free-text LLM generation.
An optional system prompt. When present, pass it to your provider’s system or instructions field.
Maximum completion tokens the SDK requests for this call. Always respect this limit in your provider call.
An optional hint identifying the logical task (e.g.,
query_reasoning, application_extract_fields). Use this to route different tasks to different models.Optional structured budget metadata for extended thinking providers that support token budget negotiation.
Pass-through options for provider-specific features. See providerOptions keys below.
Optional token usage object with
inputTokens and outputTokens fields. The SDK aggregates these for pipeline-level tokenUsage reporting.GenerateObject
Used by the extraction pipeline and all structured workflow steps that need a typed, schema-validated response.
A Zod schema. Parse and validate the model’s JSON response against this schema before returning.
Optional task kind hint for model routing. Extraction tasks include
extraction_operational_profile, extraction_coverage_cleanup, and extraction_coverage_recovery.Pass-through provider options. For extraction, this carries
pdfBase64 for multimodal calls.EmbedText
Used by MemoryStore implementations that support vector retrieval. Only required if you use semantic memory search.
providerOptions keys
The SDK populates providerOptions with structured data that your callback can forward to the provider. The keys you’re most likely to use are:
taskKind values
Use taskKind to route heavy extraction tasks to a more capable model and lighter tasks to a faster one:
Callback usage by feature
Provider examples
- Anthropic
- OpenAI
- Vercel AI SDK
The Anthropic SDK supports multimodal
document content blocks, which CL SDK uses to send the raw PDF to the model during extraction.