Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
67 lines
1.9 KiB
Python
67 lines
1.9 KiB
Python
"""Railyard client layer (Python) — env-gated, opt-in LLM metering for ReelForge.
|
|
|
|
Mirrors the VCPeer TypeScript pattern at ``vcglass/lib/railyard/{relay,abacus,
|
|
gtm-llm}.ts`` so Menivor's Python API can route its OpenAI-compatible chat calls
|
|
through the Railyard RELAY gateway (TensorZero) and, optionally, the ABACUS
|
|
per-key spend cap in front of it — so *all* AI spend is metered and capped.
|
|
|
|
Everything here is entirely OPT-IN and never a hard dependency:
|
|
|
|
* ``RELAY_URL`` unset → :func:`is_relay_enabled` is ``False``.
|
|
* ``ABACUS_URL`` (+ ``ABACUS_API_KEY``) unset → :func:`is_abacus_enabled` is
|
|
``False``.
|
|
* neither set → :func:`railyard_llm_enabled` is ``False`` and every caller keeps
|
|
its existing direct-provider path completely unchanged.
|
|
|
|
No API key is ever logged. The only failure a caller must handle is a
|
|
:class:`RailyardError` (e.g. an Abacus per-key cap breach), from which it falls
|
|
back to the direct provider path.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from .abacus import AbacusClient, create_abacus_client
|
|
from .config import (
|
|
AbacusConfig,
|
|
RelayConfig,
|
|
get_abacus_config,
|
|
get_relay_config,
|
|
is_abacus_enabled,
|
|
is_relay_enabled,
|
|
)
|
|
from .errors import RailyardError
|
|
from .llm_gateway import (
|
|
railyard_llm_enabled,
|
|
resolve_provider_key,
|
|
resolve_relay_model,
|
|
run_chat_text,
|
|
)
|
|
from .relay import (
|
|
RelayTarget,
|
|
create_relay_target,
|
|
relay_provider_for,
|
|
split_litellm_model,
|
|
to_tensorzero_model_name,
|
|
)
|
|
|
|
__all__ = [
|
|
"AbacusClient",
|
|
"AbacusConfig",
|
|
"RailyardError",
|
|
"RelayConfig",
|
|
"RelayTarget",
|
|
"create_abacus_client",
|
|
"create_relay_target",
|
|
"get_abacus_config",
|
|
"get_relay_config",
|
|
"is_abacus_enabled",
|
|
"is_relay_enabled",
|
|
"railyard_llm_enabled",
|
|
"relay_provider_for",
|
|
"split_litellm_model",
|
|
"resolve_provider_key",
|
|
"resolve_relay_model",
|
|
"run_chat_text",
|
|
"to_tensorzero_model_name",
|
|
]
|