Skip to main content

uOpenAI

uOpenAI is a lightweight, asynchronous Python library designed to interact with the OpenAI API. Leveraging the power of httpx for async HTTP requests and pydantic for data validation and settings management, it aims to provide a seamless and efficient way to access OpenAI's capabilities in modern async Python applications.

Features

  • Fully Asynchronous: Built from the ground up for asyncio compatibility.
  • Type-Hinted: Ensures robust code through comprehensive type annotations.
  • Simple and Intuitive: A straightforward API to access OpenAI's features with minimal boilerplate.

Installation

To install uOpenAI, run:

pip install uopenai

Quick Start

Here's a quick example to get you started:

import asyncio
from uopenai import OpenAI, Message

async def main():
    api = OpenAI("your-api-key")
    # Complete a prompt with options
    res = await api.complete([Message("system", "You are a chat bot"), Message("user", "What’s on your mind?")], max_tokens=50)
    print(res.choices[0].message.content)

    # easy version

    res = await api.easy_complete("What’s on your mind?", "You are a chat bot")

    res = await api.easy_complete("What’s on your mind?",
                    "You are a JSON answering machine, give the answer in JSON only.", json=True)

if __name__ == "__main__":
    asyncio.run(main())

Replace "your-api-key" with your actual OpenAI API key.

Requirements

  • Python 3.7+
  • OpenAI API key
  • httpx
  • pydantic

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

uOpenAI is released under the The Unlicense. See the LICENSE file for more details.

Release files for uopenai 0.2.3

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

Source distribution (sdist)

Source distribution for uopenai 0.2.3
File Size Uploaded
uopenai-0.2.3.tar.gz 4.4 kB Details

Built distribution (wheel)

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

Total release size: 8.9 kB

Release files / uopenai-0.2.3.tar.gz

Download URL uopenai-0.2.3.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
a2838ab2176e528d04d5c6be2cf81126de36dc203db81defd069012ed16fe7be
BLAKE2b-256 checksum
How to use checksums
b13e6c74033177f39b527d8e8a806f444a063909815cf9da208c1f8e8fe8f862
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release files / uopenai-0.2.3-py3-none-any.whl

Download URL uopenai-0.2.3-py3-none-any.whl
Size 4.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
13a82ea96f96b8db281a179f318f5457c657e80b6d522e436be2d8c3a450e54a
BLAKE2b-256 checksum
How to use checksums
42e9171db096b6847c40d121f7ef8fc62da853ecce0f728450ac7170f4c87e67
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.19

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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