Skip to main content

Refario Python telemetry SDK for LLM run and span ingestion

Project description

Python SDK

Refario Python ingestion SDK package: refario-sdk. This package publishes Refario telemetry helpers for LLM run/span ingestion and MCP telemetry emission from Python services.

Install

pip install refario-sdk

Usage

from refario_sdk import refario

client = refario.init(
    endpoint="http://localhost:3000",
    api_key="YOUR_API_KEY",
)

run = client.start_run(workflow="example-workflow", environment="prod")

run.llm_call(
    name="openai-call",
    provider="openai",
    model="gpt-4o",
    status="success",
    prompt_tokens=120,
    completion_tokens=80,
    latency_ms=900,
)

run.end(success=True)

MCP helper

from refario_sdk import create_mcp_telemetry_emitter

mcp = create_mcp_telemetry_emitter(
    endpoint="http://localhost:3000",
    api_key="YOUR_API_KEY",
    default_workflow="mcp-session",
    default_environment="production",
    default_transport="http",
)

session = mcp.start_session(session_id="session_123", request_id="req_abc")
session.tool_call(tool_name="search_docs", correlation_id="req_abc")
session.tool_result(tool_name="search_docs", correlation_id="req_abc", latency_ms=120)
session.flush(success=True)

TS-Style Compatibility Helpers

  • refario.init({ "endpoint": "...", "apiKey": "..." })
  • client.startRun({ "workflow": "...", "environment": "..." })
  • run.llmCall({ ... }), run.toolCall({ ... }), run.chainCall({ ... })
  • create_mcp_telemetry_emitter({ "endpoint": "...", "apiKey": "..." })
  • mcp.startSession({ ... }), session.toolCall({ ... }), session.toolResult({ ... })

Local tests

From python-sdk/:

PYTHONPATH=src python3 -m unittest discover -s tests -p "test_*.py"

Local package checks

From repo root:

python3 -m pip install --upgrade build twine
PYTHONPATH=python-sdk/src python3 -m unittest discover -s python-sdk/tests -p "test_*.py"
python3 -m build python-sdk
python3 -m twine check python-sdk/dist/*

Release process

  1. Bump version in python-sdk/pyproject.toml.
  2. Commit and push to main.
  3. Create and push a release tag matching the package version (for example python-sdk-v0.1.0):
git tag python-sdk-v<version>
git push origin python-sdk-v<version>

The Release Python SDK GitHub Action publishes to PyPI when the tag is pushed. You can also run the workflow manually via workflow_dispatch and optionally select a version bump (patch, minor, major, or custom) before publishing.

Required GitHub secret

  • PYPI_API_TOKEN with publish access to the refario-sdk package on PyPI.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

refario_sdk-0.1.2.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

refario_sdk-0.1.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file refario_sdk-0.1.2.tar.gz.

File metadata

  • Download URL: refario_sdk-0.1.2.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for refario_sdk-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4759a015b49ade0ec0e900e036e1593cb3e4242cd3f0ea5b461875163f552130
MD5 c6fd125aa7c714c110330aa507e168b8
BLAKE2b-256 ff2d3527b6ca131882d0b2b314cbe762af8cfc579419a1832504da6cb260632c

See more details on using hashes here.

File details

Details for the file refario_sdk-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: refario_sdk-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for refario_sdk-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d5486d37fd602b59b1f2a504228c690a2850f4105210b320d03311592290e1f
MD5 b944c77e9b3d9ed390e36410df0e55fd
BLAKE2b-256 8e51145a56caea1f982d8467c769b92f07075ef48c74d34c14f6cd303a237116

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page