confsec


Nameconfsec JSON
Version 0.1.4 PyPI version JSON
download
home_pageNone
SummaryPython SDK for Confident Security - secure and anonymous AI inference
upload_time2025-09-04 18:25:02
maintainerNone
docs_urlNone
authorNone
requires_python>=3.8
license# Confident Security Limited License license.confident.security/limited/v1 ## Acceptance In order to get any license under these terms, you must agree to them as both strict obligations and conditions to all your licenses. ## Copyright License Nonvolatile Inc. d/b/a Confident Security ("Confident Security" or "licensor") grants you a copyright license to use the software internally for a period of 90 days from your or your company's first download of each version/release of such software, only for the purpose of verifying the security and privacy characteristics of the Confident Security products or services that include the software. This license grants you no right to modify or distribute the software. If you require an extension of the duration of this license, please contact Confident Security at support@confident.security. ## Patent License The licensor grants you a patent license for the software that covers patent claims the licensor can license, or becomes able to license, that you would infringe by using the software as allowed by the Copyright License above. ## No Other Rights These terms do not allow you to sublicense or transfer any of your licenses to anyone else, or prevent the licensor from granting licenses to anyone else. These terms do not imply any other licenses. Except for the express licenses set forth herein, as between you and licensor, licensor reserves all right, title and interest in and to the software. ## Patent Defense If you make any written claim that the software infringes or contributes to infringement of any patent, your licenses for the software granted under these terms end immediately. If your company makes such a claim, your licenses end immediately for work on behalf of your company. ## Violations All your licenses end immediately if you violate these terms. ## No Liability ***AS FAR AS THE LAW ALLOWS, THE SOFTWARE COMES AS IS, WITHOUT ANY WARRANTY OR CONDITION, AND THE LICENSOR WILL NOT BE LIABLE TO YOU FOR ANY DAMAGES ARISING OUT OF THESE TERMS OR THE USE OR NATURE OF THE SOFTWARE, UNDER ANY KIND OF LEGAL CLAIM.*** ## Definitions The **software** is the software the licensor makes available under these terms. **You** refers to the individual or entity agreeing to these terms. **Your company** is any legal entity, sole proprietorship, or other kind of organization that you work for, plus all organizations that have control over, are under the control of, or are under common control with that organization. **Control** means ownership of substantially all the assets of an entity, or the power to direct its management and policies by vote, contract, or otherwise. Control can be direct or indirect. **Your licenses** are all the licenses granted to you for the software under these terms. **Use** means anything you do with the software requiring one of your licenses.
keywords ai security privacy inference
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # CONFSEC Python SDK

## Overview

The CONFSEC Python SDK provides developers with a convenient way to make secure
and anonymous AI inference requests via CONFSEC. It can function as a drop-in
replacement for existing OpenAI clients, or as an HTTP client for lower-level
access to the CONFSEC API.

## Installation

```bash
pip install confsec
```

## Quickstart

Use our OpenAI wrapper as a drop-in replacement for existing OpenAI clients:

```python
# Use OpenAI wrapper
from confsec.openai import OpenAI
client = OpenAI()
```

Or, for lower-level access, use the CONFSEC-enabled HTTP client directly:

```python
# Use HTTP client
import os
from confsec import ConfsecClient

with ConfsecClient(api_key=os.environ["CONFSEC_API_KEY"]) as client:
    http = client.get_http_client()
```

## Configuration

We aim to make the SDK as config-free as possible. However, there are some
parameters you can optionally configure to control how the client interacts
with the CONFSEC backend:

- `concurrent_requests_target (int)`: Allows the client to specify the desired
  request parallelism. This primarily impacts the number of credits that the
  client will maintain cached and available to use immediately. Higher values
  for this parameter will increase the maximum request throughput that the
  client can achieve, but also increases the amount of credits that may be lost
  permanently if the client process terminates without properly closing the
  client.
- `default_node_tags (list[str])`: Allows the client to specify default filters
  for CONFSEC compute nodes that will be applied to all requests. Users should
  not need to configure this in most cases, especially when using the OpenAI
  wrapper, since the `model` field of any request will be automatically mapped
  to the appropriate CONFSEC node tags.

## Usage

### OpenAI Wrapper

The `OpenAI` class can be initialized explicitly with an API key, by passing the
`api_key` parameter to the constructor. Otherwise, it will attempt to load the
API key from the `CONFSEC_API_KEY` environment variable.

It is very important to call `client.close()` when you are done with the client
to ensure that all resources are properly released. This can be done explicitly,
or by using the `OpenAI` class as a context manager. Failure to do so may result
in credits being lost.

Currently, the following subset of APIs are supported:
- Completions
- Chat

```python
import os
client = OpenAI()

stream = client.chat.completions.create(
    model="deepseek-r1:1.5b",
    messages=[
        {
            "role": "user",
            "content": "What is the meaning of life?",
        }
    ],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content, end="")

client.close()
```

### HTTP Client

The `ConfsecClient` class can also be initialized explicitly for lower-level
access to the CONFSEC API. It's recommended to create an HTTP client using the
`get_http_client` method of the `ConfsecClient` class which will use the client
as the transport, instead of calling `ConfsecClient`'s methods directly.

As with the `OpenAI` class, it is very important to call `client.close()` when
you are done with the client to ensure that all resources are properly released.
This can be done explicitly, or by using the `ConfsecClient` class as a context
manager. Failure to do so may result in credits being lost.

```python
import os
from confsec import ConfsecClient

with ConfsecClient(api_key=os.environ["CONFSEC_API_KEY"]) as client:
    http = client.get_http_client()
    response = http.request(
        "POST",
        "https://api.openai.com/v1/chat/completions",
        json={
            "model": "deepseek-r1:1.5b",
            "messages": [
                {"role": "user", "content": "What is the meaning of life?"}
            ]
        }
    )
    print(response.json())
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "confsec",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "ai, security, privacy, inference",
    "author": null,
    "author_email": "Confident Security <support@confidentsecurity.ai>",
    "download_url": "https://files.pythonhosted.org/packages/95/be/473b7262353922b48c3df34bb0b3c1d25c7e28b74b8dab78682580746ef2/confsec-0.1.4.tar.gz",
    "platform": null,
    "description": "# CONFSEC Python SDK\n\n## Overview\n\nThe CONFSEC Python SDK provides developers with a convenient way to make secure\nand anonymous AI inference requests via CONFSEC. It can function as a drop-in\nreplacement for existing OpenAI clients, or as an HTTP client for lower-level\naccess to the CONFSEC API.\n\n## Installation\n\n```bash\npip install confsec\n```\n\n## Quickstart\n\nUse our OpenAI wrapper as a drop-in replacement for existing OpenAI clients:\n\n```python\n# Use OpenAI wrapper\nfrom confsec.openai import OpenAI\nclient = OpenAI()\n```\n\nOr, for lower-level access, use the CONFSEC-enabled HTTP client directly:\n\n```python\n# Use HTTP client\nimport os\nfrom confsec import ConfsecClient\n\nwith ConfsecClient(api_key=os.environ[\"CONFSEC_API_KEY\"]) as client:\n    http = client.get_http_client()\n```\n\n## Configuration\n\nWe aim to make the SDK as config-free as possible. However, there are some\nparameters you can optionally configure to control how the client interacts\nwith the CONFSEC backend:\n\n- `concurrent_requests_target (int)`: Allows the client to specify the desired\n  request parallelism. This primarily impacts the number of credits that the\n  client will maintain cached and available to use immediately. Higher values\n  for this parameter will increase the maximum request throughput that the\n  client can achieve, but also increases the amount of credits that may be lost\n  permanently if the client process terminates without properly closing the\n  client.\n- `default_node_tags (list[str])`: Allows the client to specify default filters\n  for CONFSEC compute nodes that will be applied to all requests. Users should\n  not need to configure this in most cases, especially when using the OpenAI\n  wrapper, since the `model` field of any request will be automatically mapped\n  to the appropriate CONFSEC node tags.\n\n## Usage\n\n### OpenAI Wrapper\n\nThe `OpenAI` class can be initialized explicitly with an API key, by passing the\n`api_key` parameter to the constructor. Otherwise, it will attempt to load the\nAPI key from the `CONFSEC_API_KEY` environment variable.\n\nIt is very important to call `client.close()` when you are done with the client\nto ensure that all resources are properly released. This can be done explicitly,\nor by using the `OpenAI` class as a context manager. Failure to do so may result\nin credits being lost.\n\nCurrently, the following subset of APIs are supported:\n- Completions\n- Chat\n\n```python\nimport os\nclient = OpenAI()\n\nstream = client.chat.completions.create(\n    model=\"deepseek-r1:1.5b\",\n    messages=[\n        {\n            \"role\": \"user\",\n            \"content\": \"What is the meaning of life?\",\n        }\n    ],\n    stream=True,\n)\nfor chunk in stream:\n    print(chunk.choices[0].delta.content, end=\"\")\n\nclient.close()\n```\n\n### HTTP Client\n\nThe `ConfsecClient` class can also be initialized explicitly for lower-level\naccess to the CONFSEC API. It's recommended to create an HTTP client using the\n`get_http_client` method of the `ConfsecClient` class which will use the client\nas the transport, instead of calling `ConfsecClient`'s methods directly.\n\nAs with the `OpenAI` class, it is very important to call `client.close()` when\nyou are done with the client to ensure that all resources are properly released.\nThis can be done explicitly, or by using the `ConfsecClient` class as a context\nmanager. Failure to do so may result in credits being lost.\n\n```python\nimport os\nfrom confsec import ConfsecClient\n\nwith ConfsecClient(api_key=os.environ[\"CONFSEC_API_KEY\"]) as client:\n    http = client.get_http_client()\n    response = http.request(\n        \"POST\",\n        \"https://api.openai.com/v1/chat/completions\",\n        json={\n            \"model\": \"deepseek-r1:1.5b\",\n            \"messages\": [\n                {\"role\": \"user\", \"content\": \"What is the meaning of life?\"}\n            ]\n        }\n    )\n    print(response.json())\n```\n",
    "bugtrack_url": null,
    "license": "# Confident Security Limited License\n        \n        license.confident.security/limited/v1\n        \n        ## Acceptance\n        \n        In order to get any license under these terms, you must agree\n        to them as both strict obligations and conditions to all\n        your licenses.\n        \n        ## Copyright License\n        \n        Nonvolatile Inc. d/b/a Confident Security (\"Confident Security\" or \"licensor\")\n        grants you a copyright license to use the software internally for a period\n        of 90 days from your or your company's first download of each version/release of such software,\n        only for the purpose of verifying the security and privacy\n        characteristics of the Confident Security products or services that include\n        the software. This license grants you no right to modify or distribute\n        the software. If you require an extension of the duration of this license,\n        please contact Confident Security at support@confident.security.\n        \n        ## Patent License\n        \n        The licensor grants you a patent license for the software that\n        covers patent claims the licensor can license, or becomes able\n        to license, that you would infringe by using the software\n        as allowed by the Copyright License above.\n        \n        ## No Other Rights\n        \n        These terms do not allow you to sublicense or transfer any of\n        your licenses to anyone else, or prevent the licensor from\n        granting licenses to anyone else.  These terms do not imply\n        any other licenses. Except for the express licenses set forth\n        herein, as between you and licensor, licensor reserves all\n        right, title and interest in and to the software.\n        \n        ## Patent Defense\n        \n        If you make any written claim that the software infringes or\n        contributes to infringement of any patent, your licenses\n        for the software granted under these terms end immediately. If\n        your company makes such a claim, your licenses end\n        immediately for work on behalf of your company.\n        \n        ## Violations\n        \n        All your licenses\n        end immediately if you violate these terms.\n        \n        ## No Liability\n        \n        ***AS FAR AS THE LAW ALLOWS, THE SOFTWARE COMES AS IS, WITHOUT\n        ANY WARRANTY OR CONDITION, AND THE LICENSOR WILL NOT BE LIABLE\n        TO YOU FOR ANY DAMAGES ARISING OUT OF THESE TERMS OR THE USE\n        OR NATURE OF THE SOFTWARE, UNDER ANY KIND OF LEGAL CLAIM.***\n        \n        ## Definitions\n        \n        The **software** is the software the licensor makes\n        available under these terms.\n        \n        **You** refers to the individual or entity agreeing to these\n        terms.\n        \n        **Your company** is any legal entity, sole proprietorship,\n        or other kind of organization that you work for, plus all\n        organizations that have control over, are under the control of,\n        or are under common control with that organization.\n        \n        **Control** means ownership of substantially all the assets of an entity,\n        or the power to direct its management and policies by vote,\n        contract, or otherwise.  Control can be direct or indirect.\n        \n        **Your licenses** are all the licenses granted to you for the\n        software under these terms.\n        \n        **Use** means anything you do with the software requiring one\n        of your licenses.\n        ",
    "summary": "Python SDK for Confident Security - secure and anonymous AI inference",
    "version": "0.1.4",
    "project_urls": {
        "Documentation": "https://github.com/confidentsecurity/confsec-py",
        "Homepage": "https://github.com/confidentsecurity/confsec-py",
        "Issues": "https://github.com/confidentsecurity/confsec-py/issues",
        "Repository": "https://github.com/confidentsecurity/confsec-py"
    },
    "split_keywords": [
        "ai",
        " security",
        " privacy",
        " inference"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "95be473b7262353922b48c3df34bb0b3c1d25c7e28b74b8dab78682580746ef2",
                "md5": "8aacb85b59076b15bded0933d5609c52",
                "sha256": "e9f0461234fbf43454721e896761d5b7b666be24fdf05960eefef8e8b944d68c"
            },
            "downloads": -1,
            "filename": "confsec-0.1.4.tar.gz",
            "has_sig": false,
            "md5_digest": "8aacb85b59076b15bded0933d5609c52",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 14118265,
            "upload_time": "2025-09-04T18:25:02",
            "upload_time_iso_8601": "2025-09-04T18:25:02.383845Z",
            "url": "https://files.pythonhosted.org/packages/95/be/473b7262353922b48c3df34bb0b3c1d25c7e28b74b8dab78682580746ef2/confsec-0.1.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-04 18:25:02",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "confidentsecurity",
    "github_project": "confsec-py",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "confsec"
}
        
Elapsed time: 1.08053s