nagents¶
nagents (pronounced "N-agents") is a lightweight Python agents library with direct
HTTP-based provider integration, paired with ngn (pronounced "engine")—available as a native Rust harness with
a terminal UI, and as an existing Python headless and web client.
Choose your starting point¶
| I want… | Start here |
|---|---|
| The native Rust CLI/TUI/browser bundle, without installing Python or build tools | Native installer and usage |
| Python APIs for providers, agents, tools and sessions | Python library installation and quick start |
| The existing Python headless/React client, voice, plugins and integrations | Python ngn client installation |
Install native ngn
curl -fsSL https://github.com/abi-jey/nagents/releases/latest/download/install.sh | sh
(Linux x86_64 (glibc 2.39+) and macOS 11+ (Apple silicon or Intel)). The Python client has its own support matrix.
Both clients use the name ngn, but configuration, auth and feature sets differ.
The native installer refuses to overwrite an existing Python/foreign command.
It does not migrate legacy state or claim full parity; see
native migration and safety. Existing Python
library and client documentation remains available below.
-
Minimal Dependencies
Three direct base dependencies:
aiohttp,aiosqliteandPyYAML. No mandatory provider SDKs. -
Multi-Provider
OpenAI, Anthropic Claude, and Google Gemini with unified API.
-
Tool Execution
Register Python functions as tools with automatic schema generation.
-
Session Persistence
SQLite-based conversation history with session management.
Python library features¶
- Multi-Provider Support - OpenAI, Anthropic Claude, and Google Gemini APIs
- Streaming Events - Real-time text chunks, tool calls, and usage statistics
- Tool Execution - Register Python functions as tools with automatic schema generation
- Session Management - SQLite-based conversation persistence
- Context Compaction - Automatic summarization to stay within context limits
- Batch Processing - Process multiple requests efficiently
- HTTP Logging - Debug with full HTTP/SSE traffic logging
- Tool Hallucination Handling - Graceful handling of unknown tool calls
Python library quick start¶
Install the Python package first. Set
OPENAI_API_KEY and OPENAI_MODEL securely for your own account before running
this model-calling example; importing the library requires neither.
import asyncio
import os
from pathlib import Path
from nagents import Agent, ErrorEvent, Provider, ProviderType, SessionManager, TextChunkEvent
async def main():
# Create a provider
provider = Provider(
provider_type=ProviderType.OPENAI_COMPATIBLE,
api_key=os.environ["OPENAI_API_KEY"],
model=os.environ["OPENAI_MODEL"],
)
# Create session manager for conversation persistence
session_manager = SessionManager(Path("sessions.db"))
# Create an agent
agent = Agent(
provider=provider,
session_manager=session_manager,
streaming=True,
)
# Run a conversation
try:
async for event in agent.run("Hello, how are you?"):
if isinstance(event, TextChunkEvent):
print(event.chunk, end="", flush=True)
elif isinstance(event, ErrorEvent):
print(f"\nError: {event.message}")
finally:
await agent.close()
asyncio.run(main())
Python package installation¶
Use a new or existing selected virtual environment, not a global pip install. Do not recreate an environment already managed by Poetry or another tool.
Providers¶
nagents supports multiple LLM providers with a unified interface:
| Provider | Type | Model selection |
|---|---|---|
| OpenAI | ProviderType.OPENAI / OpenAIProvider |
A model available to your API-key or separate ChatGPT connection |
| Anthropic | ProviderType.ANTHROPIC |
An account-supported model ID |
ProviderType.GEMINI_NATIVE |
An account-supported model ID | |
| Compatible services, gateways and Azure | See providers | Your endpoint's model ID or deployment name |
This is not an exhaustive or current upstream model catalog. Use explicit model discovery where supported; catalog visibility does not guarantee generation entitlement or capabilities.
OpenAI Compatible
OPENAI_COMPATIBLE supports compatible services such as local Ollama/vLLM
endpoints; protocol and tool/media capabilities depend on that service.
Azure also has explicit provider routes; see the provider guide rather than
assuming all endpoints/authentication modes are interchangeable.
Next Steps¶
-
Getting Started
Install nagents and create your first agent in minutes.
-
User Guide
Learn about providers, tools, sessions, and events.
-
Examples
See complete working examples with tools and sessions.