Skip to main content

Shared utilities for the NthLayer ecosystem

Project description

nthlayer-common

Shared utilities for the NthLayer ecosystem. Model-agnostic LLM interface — one function, any provider.

Install

pip install nthlayer-common

Usage

from nthlayer_common import llm_call

result = llm_call(
    system="You are a triage agent...",
    user="Evaluate this incident...",
)
print(result.text)

Provider support

Two API formats cover the entire market:

Provider Model format API
Anthropic anthropic/claude-sonnet-4-20250514 Messages API
OpenAI openai/gpt-4o Chat Completions
Ollama ollama/llama3.1 Chat Completions
Azure azure/my-deployment Chat Completions
Together together/meta-llama/Llama-3-70b Chat Completions
Groq groq/llama-3.1-70b-versatile Chat Completions
Mistral mistral/mistral-large-latest Chat Completions
vLLM vllm/my-model Chat Completions
LM Studio lmstudio/my-model Chat Completions

Configuration

NTHLAYER_MODEL="anthropic/claude-sonnet-4-20250514"   # default
NTHLAYER_LLM_TIMEOUT="60"                              # seconds
ANTHROPIC_API_KEY="sk-ant-..."                         # for anthropic/* models
OPENAI_API_KEY="sk-..."                                # for openai/*, together/*, groq/*, etc.
OPENAI_API_BASE="http://localhost:11434/v1"            # override endpoint URL

Also includes

  • strip_markdown_fences(text) — clean LLM response parsing
  • clamp(value, low=0.0, high=1.0) — value clamping utility
  • LLMResponse — dataclass with text, model, provider, input_tokens, output_tokens
  • LLMError — structured error with provider, model, cause context

No third-party LLM libraries

One dependency: httpx. No LiteLLM, no SDKs. Raw HTTP calls to provider APIs.

License

Apache 2.0

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

nthlayer_common-0.1.2.tar.gz (6.3 kB view details)

Uploaded Source

Built Distribution

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

nthlayer_common-0.1.2-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nthlayer_common-0.1.2.tar.gz
  • Upload date:
  • Size: 6.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for nthlayer_common-0.1.2.tar.gz
Algorithm Hash digest
SHA256 963190391c6a53d3eeb2c0543d723b5577e5241dd825b4a29e6ea4ceccfd16b3
MD5 f28a00c5e5e330f944899eb65d9d3ea2
BLAKE2b-256 6ba5d3087c29c862e10615e0687006e6f699720302ba8f42d35ad6e6fcffdfdf

See more details on using hashes here.

Provenance

The following attestation bundles were made for nthlayer_common-0.1.2.tar.gz:

Publisher: release.yml on rsionnach/nthlayer-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for nthlayer_common-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 79a50108fd32309c7ffda79dadfaad17c4e803bffe46d370827a681825cb19af
MD5 2c3fc19d9eac561a9dce98a1576031f1
BLAKE2b-256 c0fb18330aeb502350732faf8cd9b6e0149268039ea05d73e0403c0dcba88f9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for nthlayer_common-0.1.2-py3-none-any.whl:

Publisher: release.yml on rsionnach/nthlayer-common

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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