Skip to main content

The official Python library for the AI71 API

Project description

Developers building Python 3.8+ apps can now interact seamlessly with the AI71 API thanks to the ai71 Python library. It includes built-in type checking for both requests and responses, and provides both synchronous and asynchronous HTTP clients powered by httpx.

Documentation

The API documentation can be found here.

Installation

pip install ai71

Usage

Define AI71_API_KEY environment variable or provide api_key in AI71 and AsyncAI71.

import os
from ai71 import AI71

client = AI71()

chat_completion = client.chat.completions.create(
    messages=[{"role": "user", "content": "What is your name?"}],
    model="tiiuae/falcon-180B-chat",
)

# Fetch supported models
model_list = client.models.list()

Async Usage

import asyncio

from ai71 import AsyncAI71

client = AsyncAI71()


async def main():
    stream = await client.chat.completions.create(
        messages=[{"role": "user", "content": "What is your name?"}],
        model="tiiuae/falcon-180B-chat",
        stream=True,
    )
    async for chunk in stream:
        print(chunk.choices[0].delta.content or "", end="")

    # Fetch supported models
    model_list = await client.models.list()


asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai71-1.0.1.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai71-1.0.1-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file ai71-1.0.1.tar.gz.

File metadata

  • Download URL: ai71-1.0.1.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for ai71-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5d851ba972e8ee82782df96a103617dd62b2eb3b9e3c26f3fd521969e4dbd1e3
MD5 31542dec4e94814da83fe6da826c9104
BLAKE2b-256 ba127a6cf87cd57e9637c09d0443400d2b937d9746b5c76b95703dd999408547

See more details on using hashes here.

File details

Details for the file ai71-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: ai71-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for ai71-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6b121b4725732c1798c4d1400435bc08a0f96828613b4c3ffd3dfe8289b546df
MD5 f3dcf877fa63a2cadee6d1b29d9c62aa
BLAKE2b-256 d94c81495f2cee3059a4f7fb5740a5e59641a582d4b2315b83d6098cb1b34183

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page