Nerif
Program with both Python and Natural Language.
LLMs can be tricky to work with. They sometimes give overly formal responses or get confused when they're unsure, making them challenging to use in real applications.
That's why we built Nerif - a simple tool that connects LLMs with Python code. We want to make it better than existing tools like Langchain and Dify.
Nerif helps you:
- Control exactly how LLMs work in your code
- Convert LLM responses into usable data formats
- Track performance with metrics like cost and success rate
- Build multi-agent workflows with observable execution traces
Our goal is to make LLMs easier to use for developers, turning complex AI capabilities into practical programming tools.
How to install
Pre-requisite
- Python >= 3.10
- Environment variable
OPENAI_API_KEYor other LLM API keys, for more details, see here - Set default model and embedding model with
NERIF_DEFAULT_LLM_MODELandNERIF_DEFAULT_EMBEDDING_MODEL, for more details, see here
Example:
export OPENAI_API_KEY=`your_api_key`
export NERIF_DEFAULT_LLM_MODEL=gpt-4o
export NERIF_DEFAULT_EMBEDDING_MODEL=text-embedding-3-small
Install
pip install nerif
Optional feature groups:
pip install "nerif[rag]" # NumPy vector store for RAG
pip install "nerif[img-gen]" # Image generation (Pillow)
pip install "nerif[viz]" # HTML trace reports (Jinja2)
pip install "nerif[otel]" # OpenTelemetry adapter
For local development setup, see docs/setup_guide.md.
QuickStart
from nerif.core import nerif
from nerif.model import SimpleChatModel
model = SimpleChatModel()
# Default model is `gpt-4o`
# Use nerif judge "natural language statement"
if nerif("the sky is blue"):
print("True")
else:
# Call a simple model
print("No", end=", ")
print(model.chat("what is the color of the sky?"))
Changelog
v1.4.0
- Opt-in
nerif.observabilitypackage for workflow tracing, trace storage, recording, budget controls, dashboards, exports, and reports - Agent and orchestrator tracing integration for multi-agent workflows
- Callback coverage for LLM, tool, fallback, retry, and memory events
- Public observability exports and optional
viz/otelextras
v1.3.0
- Async agent:
NerifAgent.arun()with concurrent tool execution - Model fallback chain: automatic failover on transient errors
- Callback/hook system: 7 event types for observability
PromptTemplate: variable substitution, defaults, conditional sections- Rate limiting: per-model/provider request throttling
- Enhanced ASR:
Transcriberwith language/format/translate support - Enhanced TTS:
Synthesizerwith voice/speed/format/file output - Streaming now supports token counting and retry
v1.2.0
ConversationMemory: sliding window with auto-summarizationNerifTokenCounter: latency, cost, success rate tracking- Lightweight RAG with
NumpyVectorStore - Custom exception hierarchy (
NerifError,ProviderError, etc.) - CLI tools:
nerif check,nerif test-model,nerif models
v1.1.0
- Streaming and async support (
stream_chat,achat) - Pydantic structured output (
response_model=) - Retry with exponential backoff (
RetryConfig) - Optional embedding model
- Multi-provider routing (OpenAI, Anthropic, Gemini, Ollama, etc.)
Documentation
More detailed documentation is on the official website.
License
Nerif is licensed under the GNU General Public License v3.0.
Metadata
Release files for nerif 1.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| nerif-1.4.0.tar.gz | 7.6 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| nerif-1.4.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 7.7 MB
Release files / nerif-1.4.0.tar.gz
| Download URL | nerif-1.4.0.tar.gz |
|---|---|
| Size | 7.6 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5e2f896e4d02bc85102876755539533a86a2af86d40e1394ddb1641056051a20
|
|
BLAKE2b-256 checksum How to use checksums |
cf4a8df3b40ed400919f0e83cb971661ed4ad00141d0e5c17782cd7ecd508802
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.
Transparency logRelease files / nerif-1.4.0-py3-none-any.whl
| Download URL | nerif-1.4.0-py3-none-any.whl |
|---|---|
| Size | 126.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
606d7caa020e2c3753b877221a53024b59c6f41e855ab86c5495e2e8d13a972f
|
|
BLAKE2b-256 checksum How to use checksums |
6333d0b807a8a2f857e511823f7e28f4ec10d48a4eb966e3828ff946eb93f1e3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 8, 2026.
Transparency log