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",
)

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="")


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-0.0.17.tar.gz (6.4 kB view hashes)

Uploaded Source

Built Distribution

ai71-0.0.17-py3-none-any.whl (11.2 kB view hashes)

Uploaded Python 3

Supported by

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