Skip to Content
SDKInstallation

Installation

Three steps: create an API key, install the package, and call init() (or just set an env var — init() is optional).

⚠️

The morse-ai package publishes with MHQ-541 — commands are final but not yet installable from PyPI.

1. Create an API key

Go to Settings → Workspace (/settings/workspace in the app), open the Environments & API Keys tab, and generate a key. Copy it when it’s shown — you won’t see the full key again.

2. Install

pip install morse-ai

Optional extras add framework-specific adapters — see Frameworks for the full list (morse-ai[anthropic], morse-ai[langgraph], morse-ai[openai_agents], or morse-ai[all]).

3. Initialize

The simplest path is zero-code: set MORSE_API_KEY in your environment and don’t call init() at all. Every public SDK function lazily auto-initializes from the env var on first use.

export MORSE_API_KEY=your-morse-key

Or call init() explicitly at startup if you want to pass the key directly, override the endpoint, or configure redaction:

import morse_ai morse_ai.init() # reads MORSE_API_KEY from your environment

init() resolves api_key from the argument first, then MORSE_API_KEY; if neither is set it raises ValueError. It resolves the ingest endpoint from an explicit endpoint arg, then MORSE_ENDPOINT, then the default https://api.morsehq.dev/api/v1/traces/batch.

Setting MORSE_DISABLED=1 makes init() (and every submission call) a no-op — useful for local dev or CI.

Verify

with morse_ai.run("my-agent") as r: result = "Hello, world!" r.record(success=True, outcome="completed", cost=0.04)

Run your script, then check the Traces list on the dashboard for the run.

  • Overview — what the SDK does and its non-invasive guarantee.
  • Frameworks — install commands and snippets for LangChain, LangGraph, OpenAI Agents, Anthropic, and Claude Agent SDK.
  • set_context() — attach cost-attribution dimensions to a trace.
Last updated on