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.1.tar.gz (6.1 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.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nthlayer_common-0.1.1.tar.gz
  • Upload date:
  • Size: 6.1 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.1.tar.gz
Algorithm Hash digest
SHA256 da3ca9202f6dd1ac5caf9ef831f0e51808f4263ec28fdad75ed04d5cdf557c7e
MD5 2f54959d08aa2bd4375df7b53862ab28
BLAKE2b-256 65910181dfed94e7ac37e7e70aeff83cd8f57c35cf066e3a192cdd6fc2029055

See more details on using hashes here.

Provenance

The following attestation bundles were made for nthlayer_common-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for nthlayer_common-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 734c9d79e4a632a041549e60c960d103b09ab1c93b3a1b4153450060186ed730
MD5 313cc1bbd7d5a8d3bf4282be43f6df13
BLAKE2b-256 1f983a2f1fd76ea116f319f5f47981b4676df0dd340b8e7355d81e5a0c2946c7

See more details on using hashes here.

Provenance

The following attestation bundles were made for nthlayer_common-0.1.1-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