Skip to main content

Python client library for the Unbound API

Project description

Features

The Unbound SDK is built on top of the OpenAI SDK, allowing you to seamlessly integrate Unbound's advanced features while retaining full compatibility with OpenAI methods. With Unbound, you can enhance your interactions with OpenAI or any other OpenAI-like provider by leveraging robust monitoring, reliability, prompt management, and more features - without modifying much of your existing code.

Usage

Prerequisites

  1. Sign up on Unbound and grab your Unbound API Key
  2. Add your API Keys to Unbound's API Keys page and keep it handy
# Installing the SDK

$ pip install unbound-gateway

Making a Request to OpenAI

  • Unbound fully adheres to the OpenAI SDK signature. You can instantly switch to Unbound and start using our production features right out of the box.
  • Just replace from openai import OpenAI with from unbound import Unbound:
from unbound import Unbound

unbound = Unbound(
    base_url="UNBOUND_BASE_URL",
    api_key="UNBOUND_API_KEY",
)

chat_completion = unbound.chat.completions.create(
    messages = [{ "role": 'user', "content": 'Say this is a test' }],
    model = 'gpt-4'
)

print(chat_completion)

Async Usage

  • Use AsyncUnbound instead of Unbound with await:
import asyncio
from unbound import AsyncUnbound

unbound = AsyncUnbound(
    base_url="UNBOUND_BASE_URL",
    api_key="UNBOUND_API_KEY"
)

async def main():
    chat_completion = await unbound.chat.completions.create(
        messages=[{'role': 'user', 'content': 'Say this is a test'}],
        model='gpt-4'
    )

    print(chat_completion)

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

unbound_gateway-0.1.7.tar.gz (251.2 kB view details)

Uploaded Source

Built Distribution

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

unbound_gateway-0.1.7-py3-none-any.whl (440.7 kB view details)

Uploaded Python 3

File details

Details for the file unbound_gateway-0.1.7.tar.gz.

File metadata

  • Download URL: unbound_gateway-0.1.7.tar.gz
  • Upload date:
  • Size: 251.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for unbound_gateway-0.1.7.tar.gz
Algorithm Hash digest
SHA256 0c8c2a6f62302b12a71e6fd6fc5e398035327ee7941f35aac278ef3fda3bdd5b
MD5 f52cad071c43ce3708a3f5baa36129da
BLAKE2b-256 92c7b121e59dfdf72bb4563e3c1c9b15db68d58b0f063d911636772c0caf1950

See more details on using hashes here.

File details

Details for the file unbound_gateway-0.1.7-py3-none-any.whl.

File metadata

File hashes

Hashes for unbound_gateway-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 1e851ee041d6013747b313bbbbd0bd67c6503231bf911eaf0eaeb6dbb2a3d439
MD5 e7380fcc07d7fb1d4efbdc53eae55399
BLAKE2b-256 2704c487a0a8d319ede8d7288a9af59aa62c5cf7202e8133e5a7b3f2358211b2

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