Skip to main content

fennas

OpenAI and Anthropic clients for Python, already pointed at a Fennas gateway. Fennas is a policy and audit gateway for LLM traffic.

pip install "fennas[openai]"
pip install "fennas[anthropic]"

Install the extra for the SDK you use. Then import it as fennas. Python 3.10 or later.

import fennas

client = fennas.openai()
reply = client.chat.completions.create(model="qwen3", messages=[{"role": "user", "content": "Hi"}])

The address comes from the argument, then FENNAS_BASE_URL, then http://localhost:8080. The key comes from the argument, then FENNAS_API_KEY. The library reads no other variable, so OPENAI_API_KEY and ANTHROPIC_API_KEY never reach Fennas. async_openai() and async_anthropic() are the async clients.

Headers

data_class and user on a client are sent with every call. The user goes in X-Fennas-User, and is recorded when the tenant's userHeader names that header. For one call, fennas.headers() builds the headers, and dry_run asks for a cost estimate without calling the model. Costs and dry runs are for tenants with showCosts: true:

claude = fennas.anthropic(data_class="confidential", user="u-17")
claude.messages.create(
    model="claude-sonnet",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hi"}],
    extra_headers=fennas.headers(dry_run=True),
)

Receipt

fennas.receipt(raw) reads what Fennas said about a call from a raw response: trace_id, cost, cost_max and output_limited. The two costs are None unless the tenant has showCosts: true.

raw = claude.messages.with_raw_response.create(
    model="claude-sonnet", max_tokens=1024, messages=[{"role": "user", "content": "Hi"}]
)
print(fennas.receipt(raw).trace_id, raw.parse().content)

Refusal

fennas.refusal(error) reads why Fennas refused a call from the SDK's error: code, message, status, trace_id and retry_after. It returns None for an error that didn't come from Fennas.

try:
    client.chat.completions.create(model="qwen3", messages=[{"role": "user", "content": "Hi"}])
except Exception as error:
    why = fennas.refusal(error)
    if why is not None:
        print(why.code, why.trace_id)

The library retries nothing, logs nothing and decides nothing: a call made without it gets the same guards, budget and audit.

More

Source, documentation and the gateway itself: https://github.com/Jamal-Akhras/fennas

The client libraries are described in https://github.com/Jamal-Akhras/fennas/blob/main/docs/client-libraries.md

Licensed under the Apache License 2.0: https://github.com/Jamal-Akhras/fennas/blob/main/LICENSE

Metadata

Release files for fennas 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fennas 0.1.0
File Size Uploaded Provenance Actions
fennas-0.1.0.tar.gz 7.5 kB With provenance Details for fennas-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for fennas 0.1.0
File Interpreter ABI Platform Actions
fennas-0.1.0-py3-none-any.whl Python 3 none any Details for fennas-0.1.0-py3-none-any.whl

Total release size: 15.4 kB

Release files / fennas-0.1.0.tar.gz

Download URL fennas-0.1.0.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
d94f2b73ed241ca84ebf4f988f17cb28780c4050288c92a84a0f683f08db8794
BLAKE2b-256 checksum
How to use checksums
8acd7336a3a073e81e3876422e2a3eb5b841b31b9a484413922b3d3ff11a80ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Release files / fennas-0.1.0-py3-none-any.whl

Download URL fennas-0.1.0-py3-none-any.whl
Size 7.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
91d67a0838b36ad1f13fcbaf357f7b73ce0d3e925318983e69224cbd88744657
BLAKE2b-256 checksum
How to use checksums
2b0108c8db7abc85ab40fdccfbab02a20b61556b93255dbc0cf34b775ef21a73
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Dec 1, 2026.

Transparency log

Security for fennas 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for fennas-0.1.0.tar.gz

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 Dec 1, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page