SDK integration flow
This is the advanced SDK lifecycle around job creation, decision delivery, generation reporting, and beacons. The default API lifecycle is shorter and lives under /api.
- 1
Import and initialize
CslClientInitialize the client with
baseUrl, servergetApiKeyor browsergetPublishableKey, and optionallydecisionDeliveryplus timing,wrapper_version, and error observation options. - 2
Create a job
Start with
createJob({ job_type: "chat" }), then add optional context, privacy controls, brand safety, or slot hints only when you need them. The response returnsjob_idandslot_ids. - 3
Report generation started
Report model generation start through
reportGeneration(jobId, "started", request). - 4
Retrieve the decision
Retrieve the sponsor decision for the first slot through
getDecision(slotId)usingauto,websocket,polling, or callback-driven delivery. - 5
Continue and finish generation
Continue model generation and then report
finishedor, if needed,failed. - 6
Render fill or handle no-fill
On fill, render
creative, respectconstraints, and useasset_token. The filled creative may also includeclick_through_urlandsponsor_name. On no-fill, react toreasonandcs_declaration. - 7
Send beacons after fill
Send wrapper beacon events such as
rendered,visible_started,visible_ended, orclickedthroughsendBeacon(). Important: only the complete creative-specific sequence generates revenue.
What goes into `createJob()`
Data flow: The job payload, including the prompt, is sent to the CSL, wavebird's middleware layer. It is not sent to the configured ad path. The CSL data firewall extracts only an abstract topic category and the language before any signal reaches a configured partner path. Raw prompt text never leaves the CSL.
job_typeis the only required field.slots_requesteddefaults to1.promptis optional and accepts either a string or an object withtextand an optionaltoken_count_estimate.context.topicis the lightest way to provide matching context without sharing prompt text.consent,brand_safety, andslot_configare optional expansion surfaces for privacy, blocking, and placement control.decisionDeliverycan beauto,websocket,polling, orcallbackat the client level.callback_urlopts a job into callback delivery even when the client-level mode is not"callback".- Optional fields also include publisher metadata, latency hints, client identifiers, routing hints, and callback settings for advanced delivery flows.
What comes back
- From
createJob()you get accepted job metadata, a typedrate_limit_exceededresult, ornullwhen the SDK falls back silently. - From
getDecision()you get pending or ready decisions, preservingconstraintsandcs_declaration. - From
sendBeacon()you get{ accepted, reason_code }.reportGeneration()always resolves.
node-server.ts
typescript
API first, Script Tag second, SDK third
These pages are the advanced package layer for teams that intentionally choose @csl/wrapper-sdk. Primary onboarding still lives in the API docs, and browser-first installs should start with the Script Tag. Use contact only when you want rollout review, enterprise coordination, or help with non-standard integration constraints. Beacon billing rules live in SDK Concepts.