Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

chatnio

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

chatnio

The official Python library for the Chat Nio API

  • 0.1.4
  • PyPI
  • Socket score

Maintainers
1

====================== ChatNio Python Library

The official Python library for the Chat Nio API

  • Authors: Deeptrain Team
  • Free software: MIT license
  • Documentation: https://docs.chatnio.net

Features

  • Chat
  • Conversation
  • Quota
  • Subscription and Package

Installation

Install using pip

.. code-block:: bash

pip install --upgrade chatnio

And then import it

.. code-block:: python

import chatnio

Usage

  • Authentication

.. code-block:: python

chatnio.set_key("sk-...")
# or read from environment variable
chatnio.set_key_from_env("CHATNIO_TOKEN")

# set custom api endpoint (default: https://api.chatnio.net)
# chatnio.set_endpoint("https://example.com/api")

# clear token
chatnio.clear_key()

# get current token
chatnio.get_token()
  • Chat

.. code-block:: python

chat = await chatnio.new_chat()

async for message in chat.ask("Hello, world!"):
    print(message.message, end="")
  • Conversation

.. code-block:: python

# list conversations (100 conversations max)
for conversation in chatnio.list_conversations():
    print(conversation.id, conversation.name)

# load conversation
conversation = chatnio.load_conversation(42)
print(conversation)
for message in conversation.messages:
    print(message.role, message.content)

# delete conversation
state = chatnio.delete_conversation(42)
print(state)
  • Quota

.. code-block:: python

# get quota
quota = chatnio.get_quota()
print(quota)

# buy quota
state = chatnio.buy_quota(1000)
print(state)
  • Subscription and Package

.. code-block:: python

# get subscription
subscription = chatnio.get_subscription()
print(subscription.is_subscribed, subscription.expired)

# buy subscription
state = chatnio.buy_subscription(1, 1) # 1 month of basic plan
print(state)

# get package
package = chatnio.get_package()
print(package)
  • Error

    chatnio.AuthenticationError

Test

To run the tests, you need to set the environment variable CHATNIO_TOKEN to your secret key.

.. code-block:: bash

export CHATNIO_TOKEN="sk-..."

Then run the tests

.. code-block:: bash

pytest

======= History

  • 0.1.0 (2023-10-13)
    • First release on PyPI.
  • 0.1.1 (2023-10-14)
    • Update Documentation
  • 0.1.2 (2023-10-31)
    • Update API
  • 0.1.3 (2023-11-29)
    • Add Subscription Level
  • 0.1.4 (2023-12-01)
    • Add Customize Endpoint Option

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc