Capture is fire-and-forget and engineered to never raise into your application. Respects
MAITAI_LOGGING_ENABLED and MAITAI_LOG_SAMPLE_RATE. First log with an unknown ref auto-creates a shell workflow — no pre-registration.Python SDK
Context manager
maitai.log(...) / proxied LLM calls automatically inherit the run’s session_id, so the cost card and View Session populate without extra wiring.
Decorator
One-shot
LangGraph / observe as workflow
When instrumenting withmaitai.observe(), declare which graphs are workflows so they persist as workflow_run rows instead of observed agents:
Raw HTTP
session_id. Prefer a write-only ingest token (WORKFLOW_INGEST) from Portal → Forge → Workflows → Connect external when pasting into third-party SaaS.
n8n
- Open Portal → Forge → Workflows → Connect external.
- Pick n8n, choose application + workflow ref, mint an ingest token.
- Add an HTTP Request node as the last step, or import the starter workflow from the repo (
docs/external/sdk/n8n/maitai-byow-log.json) and replace placeholders:- Method:
PUT - URL:
https://api.trymaitai.ai/workflow/runs/log(or your localhttp://host.docker.internal:5000/workflow/runs/log) - Header
x-api-key: your ingest token - Body (JSON). In the Portal wizard artifact, n8n uses expression fields with an
=prefix. Never send bare$execution.idassession_id(values like"1"collide with other traffic and cost backfill). Namespace it:The API rejects numeric-only / short (< 8char) externalsession_idvalues.
- Method:
- Optional: Error Workflow HTTP node with
"status": "FAILED"anderror_message. - Use Wait for first run in the Portal wizard — it navigates to the rendered run when it lands.
Local verify (Docker)
docs/external/sdk/n8n/maitai-byow-log.json → set x-api-key, workflow_ref, and application → Execute. Confirm the run appears under the workflow in Portal (or via the wizard listener). From Docker Desktop on Mac/Windows, host.docker.internal reaches a backend on the host at :5000.
TypeScript SDK
What appears in the Portal
External runs show under the linked application and workflow withsource=EXTERNAL. Input/output panels, cost (when LLM calls share the session), and execution timeline (when a profile/spans are sent) match native runs. Flow-tab graph import for external definitions is a follow-up.