Meridian AI SDK
Python SDK for Meridian, an AI observability product. The SDK collects trace events from your AI application and sends them to the Meridian backend for storage and analysis.
- PyPI install name:
meridian-ai - Python import package:
meridian_ai
import meridian_ai
from meridian_ai import Meridian
[!NOTE] This project is in early development. The public API may change.
Installation
pip install meridian-ai
Requires Python 3.9 or newer. The SDK has no required third-party dependencies.
Quick start
from meridian_ai import Meridian
meridian = Meridian()
with meridian.trace("my-ai-request"):
result = my_application()
meridian.flush()
With no configuration the client is disabled: trace(...) still runs so your
instrumentation never breaks the application, and flush() sends nothing until
an endpoint and project are configured.
Configuration
endpoint, project_id, and api_key can be passed explicitly or read from the
environment. Explicit arguments always take precedence; the environment is only
consulted for arguments you omit.
| Argument | Environment variable | Required for submission |
|---|---|---|
endpoint |
MERIDIAN_ENDPOINT |
yes |
project_id |
MERIDIAN_PROJECT_ID |
yes |
api_key |
MERIDIAN_API_KEY |
no |
The project_id refers to an existing Meridian project. Projects are created
and managed in the Meridian web application, never from the SDK.
Environment variables
export MERIDIAN_ENDPOINT="https://meridian.example.com"
export MERIDIAN_PROJECT_ID="my-project"
export MERIDIAN_API_KEY="your-api-key"
from meridian_ai import Meridian
meridian = Meridian() # reads MERIDIAN_* from the environment
Explicit configuration
from meridian_ai import Meridian
meridian = Meridian(
endpoint="https://meridian.example.com", # placeholder; use your endpoint
project_id="my-project",
api_key="your-api-key", # optional; sent as a Bearer token
ingest_path="/v1/traces", # configurable; this is the default
timeout=10.0, # seconds
)
The API key is stored privately and never appears in logs, repr(), or error
messages.
Basic tracing
Wrap a block of work in meridian.trace(...). The trace records its start time,
end time, and latency, and is marked successful or failed automatically.
with meridian.trace("customer-question"):
answer = run_pipeline(question)
All metadata is optional:
with meridian.trace(
"customer-question",
model="example-model",
provider="example-provider",
input_tokens=120,
output_tokens=48,
metadata={"conversation_id": "abc123"},
):
answer = run_pipeline(question)
total_tokens is derived from input_tokens and output_tokens when you
provide them; you never have to compute it yourself.
Completed traces are buffered in memory. Call meridian.flush() to send the
buffered events to the Meridian backend as JSON.
meridian.flush()
Error behavior
Telemetry problems should not take down your application, so by default
flush() never raises for a transport or backend failure:
- transport failures (connection errors, DNS failures) → recorded as a connection error
- timeouts → recorded as a timeout error
- backend error responses (HTTP 4xx/5xx) → recorded as an API error
- malformed responses → ignored safely
Exceptions raised inside a with meridian.trace(...) block are never
swallowed — they propagate to your application unchanged, and the trace is
marked as an error.
Inspect the outcome of the most recent flush():
meridian.flush()
if meridian.last_result and not meridian.last_result.ok:
print(meridian.last_error) # a MeridianError; never contains the api_key
retry_later(meridian.last_result.events)
Failures are also logged on the meridian_ai logger. To make failures raise
instead, enable strict mode:
meridian = Meridian(strict=True)
MeridianError is the base class for every SDK exception and is importable from
the top level. The specific subclasses live in meridian_ai.exceptions.
Development
git clone <repository-url>
cd meridian-ai
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
pytest
Build distributions:
python -m build
The project uses a src-based layout and setuptools for packaging. See RELEASE.md for the step-by-step release checklist.
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file meridian_ai-0.1.0.tar.gz.
File metadata
- Download URL: meridian_ai-0.1.0.tar.gz
- Upload date:
- Size: 25.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6cdd15e1e633d9f0abcf07b5c9a76017a7a3c80c8c71a0c1ce10e016ffeb1469
|
|
| MD5 |
0d62753239071cd2800f182eaae2c2f7
|
|
| BLAKE2b-256 |
a63c0572488f0e40eec7e12264c64d681b41c7bb592296bc30152e17fd9a576f
|
File details
Details for the file meridian_ai-0.1.0-py3-none-any.whl.
File metadata
- Download URL: meridian_ai-0.1.0-py3-none-any.whl
- Upload date:
- Size: 16.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4e0d4c9262ec44a3929101b5eec825e8f361f580c7155cbcf84ea90138fe9cd7
|
|
| MD5 |
bb97ac16775d34bed56b48f9ec07a551
|
|
| BLAKE2b-256 |
df718f52edb757edb485ddc051f554e01ad57f104cc9e83520f5b67a4db581c2
|