Skip to main content
CL SDK never calls a language model directly. Instead, you pass plain async functions—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.
string
required
The user-turn prompt assembled by the SDK for this pipeline step.
string
An optional system prompt. When present, pass it to your provider’s system or instructions field.
number
required
Maximum completion tokens the SDK requests for this call. Always respect this limit in your provider call.
ModelTaskKind
An optional hint identifying the logical task (e.g., query_reasoning, application_extract_fields). Use this to route different tasks to different models.
ModelBudgetResolution
Optional structured budget metadata for extended thinking providers that support token budget negotiation.
Record<string, unknown>
Pass-through options for provider-specific features. See providerOptions keys below.
Return type:
string
required
The generated text completion.
TokenUsage
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.
string
required
The user-turn prompt for this structured generation call.
string
Optional system prompt.
ZodSchema<T>
required
A Zod schema. Parse and validate the model’s JSON response against this schema before returning.
number
required
Maximum completion tokens for this call.
ModelTaskKind
Optional task kind hint for model routing. Extraction tasks include extraction_operational_profile, extraction_coverage_cleanup, and extraction_coverage_recovery.
ModelBudgetResolution
Optional structured budget metadata for extended thinking.
Record<string, unknown>
Pass-through provider options. For extraction, this carries pdfBase64 for multimodal calls.
Return type:
T
required
The parsed and schema-validated object.
TokenUsage
Optional token usage.

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

The Anthropic SDK supports multimodal document content blocks, which CL SDK uses to send the raw PDF to the model during extraction.