Skip to main content
Syncing gives every prompt an immutable version; attribution tells Moda which version served each production call. You attribute calls by stamping prompt identifiers on the data you already send: with the 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
Read the lockfile at startup (or bake the values in at build time) and stamp 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_id equal to the registry prompt ID, or prompt_name equal to the prompt key. On OTLP paths, moda.prompt_key alone 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 coverage can show which calls resolve to one.
  • prompt_version is a free-form display string (for example a semver or git SHA of your choosing); it defaults to the version ID when omitted.
Stamp the fields on the assistant events or LLM spans produced by the prompt.

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
Without Think, pass the same option to createAI7Telemetry and hand its telemetry to the call:
app.ts
Keep rendering the prompt in your own code; the option only attributes the call. Re-run 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 the prompt_* fields directly on /v1/ingest events:
Response
See HTTP API for the full event schema, batch limits, and error envelope.

OpenTelemetry span attributes

If you export OTLP traces to Moda from your own OpenTelemetry setup, set the moda.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 the metadata of Moda.getVercelAITelemetry. The AI SDK forwards metadata keys as span attributes that Moda reads:
app.ts
Moda.getVercelAITelemetry() snapshots the trace and user context at the moment it is called. Set Moda.conversationId (or wrap the call in withConversationId) before creating the telemetry config, or the call is grouped without your trace ID.
See Vercel AI SDK for the full integration, including streaming and tool calls.

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.
Calls without 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-think installs the integration skill, which ends with this attribution step.
  • Prompt workflow — where the lockfile and version IDs come from.
  • HTTP API — full /v1/ingest event schema and limits.
  • OpenTelemetry — exporting OTLP traces to Moda from your own setup.