prompt option of the Cloudflare Think and AI SDK 7 helpers, as event fields on the HTTP Ingestion API, as span attributes over OpenTelemetry, or as telemetry metadata with the Vercel AI SDK.
There is no SDK call that renders a prompt and attributes it automatically. The
moda-ai/think and moda-ai/ai7 helpers accept a prompt option (below). Auto-instrumented OpenAI and Anthropic calls made through the Moda SDKs carry no prompt attribution, because the SDKs expose no option to stamp these fields on auto-generated spans. For those, use one of the other mechanisms on this page.Where the identifiers come from
moda prompts sync writes .moda/prompts.lock.json with the registry IDs for every prompt:
.moda/prompts.lock.json
promptId and versionId on the calls that use that prompt.
Identifier fields
How much you send determines what you get:
- Linking to a prompt requires
prompt_idequal to the registry prompt ID, orprompt_nameequal to the prompt key. On OTLP paths,moda.prompt_keyalone is enough — the ID and name default to the key. - Per-version usage requires
prompt_version_id. Without it, calls link to the prompt but not to a specific version. - Registry coverage matches the agent name against your registered agents, so
moda registry coveragecan show which calls resolve to one. prompt_versionis a free-form display string (for example a semver or git SHA of your choosing); it defaults to the version ID when omitted.
Cloudflare Think and AI SDK 7
createThinkTelemetry (from moda-ai/think, for Cloudflare Think agents) and createAI7Telemetry (from moda-ai/ai7, for direct AI SDK 7 generateText and streamText calls) take a prompt option. Pass the lockfile entry for the prompt the call uses. The helpers read its key, promptId, and versionId and stamp them on every model span they export, so you do not set the attribute names yourself. Both need moda-ai 1.16.0 or later.
Import the lockfile at build time, so the version IDs ship with the deployed Worker:
src/agent.ts
createAI7Telemetry and hand its telemetry to the call:
app.ts
moda prompts sync and rebuild whenever a prompt changes, or new calls keep reporting the previous versionId. Create one helper per prompt-specific call (per turn for Think), so each call carries the version it actually used.
HTTP Ingestion API
Set theprompt_* fields directly on /v1/ingest events:
Response
OpenTelemetry span attributes
If you export OTLP traces to Moda from your own OpenTelemetry setup, set themoda.prompt_* attributes on each LLM span (see OpenTelemetry for exporter setup). Moda also reads gen_ai.prompt.name as a fallback for the prompt name.
With the Moda SDK for Node.js, manual capture via withLLMCall exposes the underlying OTel span, so you can stamp the attributes there. Use this for calls the SDK does not auto-instrument:
app.ts
withLLMCall is Node.js only. The Moda SDK for Python has no manual-capture equivalent; from Python, send attributed events through the HTTP API or set the attributes in your own OpenTelemetry instrumentation.
Vercel AI SDK
Pass the identifiers in themetadata of Moda.getVercelAITelemetry. The AI SDK forwards metadata keys as span attributes that Moda reads:
app.ts
What attribution unlocks
- Runtime usage per version. The prompt detail page (Dashboard → Prompts → your prompt, Versions tab) shows calls, traces, and input/output tokens grouped by version. Rows appear within minutes of ingestion.
- Version-aware analysis. Attributed traces let you compare how different versions behave in production.
prompt_version_id still count toward the prompt’s overall usage as long as they carry the prompt key or ID.
Next steps
-
Cloudflare Think setup for coding agents:
moda skills install integration-cloudflare-thinkinstalls the integration skill, which ends with this attribution step. - Prompt workflow — where the lockfile and version IDs come from.
-
HTTP API — full
/v1/ingestevent schema and limits. - OpenTelemetry — exporting OTLP traces to Moda from your own setup.