niyoos — Python SDK
Niyoos is the model gateway for your AI agents: every LLM call they make goes through the Niyoos proxy, where it is recorded, priced and governed. This SDK labels each call with the run it belongs to, so you can see what an agent did, step by step.
Beta — the API may change before 1.0.
Labels every LLM call your agent makes through the Niyoos proxy with the run it belongs to, its
step, and the run that spawned it. Your agent keeps its own openai client.
Install
pip install "niyoos[openai]"
Quickstart
Create an agent in the Niyoos dashboard, copy its agent key, and wrap your own OpenAI client with it:
import niyoos
from openai import OpenAI
client = niyoos.wrap(OpenAI(api_key=NIYOOS_AGENT_KEY)) # points at https://api.niyoos.com/proxy/v1
with niyoos.run(): # new run: a UUIDv7 id, steps counted 1, 2, 3 …
client.chat.completions.create(model="gpt-4o", messages=[...])
with niyoos.run(): # a sub-agent: its own run, parent linked automatically
client.chat.completions.create(model="gpt-4o", messages=[...])
pool.submit(niyoos.bind(tool_call)) # thread pools need bind() to stay in the run
@niyoos.run() works as a decorator, and async with niyoos.run(): works for async code.
niyoos.run(run_id="order-1234", parent_run_id=parent_id) continues a run, or links a sub-agent
that runs in another process; pass it niyoos.current_run_id() from the parent.
What goes on the wire
| Header | Value |
|---|---|
x-niyoos-run-id |
the run id, 8–64 of A-Z a-z 0-9 _ - |
x-niyoos-step |
1, 2, 3 … within the run; a retry repeats its step |
x-niyoos-parent-run-id |
the parent run, for a nested run |
x-niyoos-client |
sdk-python, on every request |
User-Agent |
the openai library's own, with niyoos-python/0.1.0 appended |
Outside a run, none of the three run headers is sent. Run headers also work without this SDK: any HTTP client can send them; the SDK only mints the ids, counts steps and links parents for you.
Behaviour you should know
- Labels are advisory. Every policy (kill switch, rate and cost limits) is enforced by the server whether or not a call is labelled. If the SDK ever fails to build a label, the call goes out unlabelled, with one warning, and is not otherwise affected.
wrap()changes the client you pass and returns it. It sets the Niyoos base URL only when the client still points at the OpenAI default. Abase_urlyou set yourself is left alone.ThreadPoolExecutor.submitandloop.run_in_executordo not carry the run. Wrap the function withniyoos.bind(fn). (asyncio.gather,create_taskandasyncio.to_threaddo carry it.)- A generator that makes calls belongs to whichever run is open when it is resumed.
- Retries are recognised from the openai library's
x-stainless-retry-countheader. A client that does not send it counts each retry as a new step. - The request body is never modified.
- For other libraries, pass
niyoos.httpx_client()/niyoos.async_httpx_client()as their HTTP client, e.g.Anthropic(http_client=niyoos.httpx_client(), base_url="https://api.niyoos.com/proxy"). There are no dedicated Anthropic or LangChain adapters in v0.1.
Python 3.9 or later. The only required dependency is httpx; pip install niyoos[openai] adds
the openai library (>=1.0).
Licence
Apache-2.0. Questions: support@niyoos.com · https://niyoos.com
Metadata
Release files for niyoos 0.1.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 | Provenance | Actions |
|---|---|---|---|---|
| niyoos-0.1.0.tar.gz | 13.5 kB | Without provenance | Details for niyoos-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| niyoos-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for niyoos-0.1.0-py3-none-any.whl |
Total release size: 29.1 kB
Release files / niyoos-0.1.0.tar.gz
| Download URL | niyoos-0.1.0.tar.gz |
|---|---|
| Size | 13.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
04753fd2df5d6bd0b9f7f29f8c79900d1175aa25e57af3fdf02816ebe08bba21
|
|
BLAKE2b-256 checksum How to use checksums |
57652a126471bec2d6c60a6eb95e684a73d8e560af5512e80c2f5adfd4e71a39
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / niyoos-0.1.0-py3-none-any.whl
| Download URL | niyoos-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
190d841a5f8eec35686d9ab76a35f39dcd51ab692d2fc8bac3cb6b58139ffbf0
|
|
BLAKE2b-256 checksum How to use checksums |
581d55bcb9b288a40a20e9dc9354a423caca48ed0a8537437454e43f59f61e78
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for niyoos 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.