Skip to main content
This guide takes you from an empty project to a conversation visible in the Moda dashboard. It uses the Moda SDK for Python or Node.js to auto-instrument the OpenAI client library; an Anthropic variant follows at the end.

Prerequisites

  • A Moda workspace. Accounts are provisioned by the Moda team; teammates join by invitation (Settings → Members & roles).
  • A Moda API key. Create one in the dashboard at Settings → Ingestion keys — the full key is shown once, at creation.
  • An OpenAI API key (or an Anthropic API key for the variant below).
  • Python 3.10 or later, or Node.js 18 or later.
1

Install the SDK

Install moda-ai alongside the provider client you already use:
The PyPI package is named moda-ai, but you import it as moda.
2

Initialize Moda and make a call

Initialize the SDK before you construct the provider client, make the call as usual, and flush before the process exits.
In Node.js, Moda.init() is asynchronous and must be awaited. If it is not awaited, calls made before initialization completes are not captured. The Node.js SDK also requires the API key as an explicit argument — it does not read a MODA_API_KEY environment variable. Python’s moda.init() is synchronous and falls back to MODA_API_KEY when no key is passed.
The Node.js sample uses top-level await, which requires ES modules ("type": "module" in package.json). In a CommonJS project, wrap the code in an async function.
3

Add conversation and user context

Set a conversation ID and a user ID before the first model call of a session — use an identifier your application already has, such as a session, thread, or run ID — so every call is attributed to the right conversation and user:
Calls made while these are set are attributed to that conversation and user. Both SDKs also offer scoped forms that are safe in concurrent servers: with moda.set_conversation_id(...) in Python, and withConversationId(...) / withContext(...) (imported from moda-ai) in Node.js. See the Python SDK and Node.js SDK pages for details.
4

Verify in the dashboard

Open https://moda.dev/dashboard and go to Conversations. Your conversation appears within minutes of the flush; click the row to open its Full Trace view showing the prompt and the model’s response. Emotion, tool-failure, laziness, and hallucination analyses appear on the Signals page within minutes.

Anthropic variant

The SDKs also auto-instrument the Anthropic client libraries. Install with pip install moda-ai anthropic or npm install moda-ai @anthropic-ai/sdk, then:

Troubleshooting

Next steps