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.5.tar.gz (251.1 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.5-py3-none-any.whl (440.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: unbound_gateway-0.1.5.tar.gz
  • Upload date:
  • Size: 251.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.9.21

File hashes

Hashes for unbound_gateway-0.1.5.tar.gz
Algorithm Hash digest
SHA256 ad0df5d932b4a0158031f41498ecda4575a1c09fc2b54af1e8682fc9d0273ec0
MD5 42b0b1c7ca5150866c179d183f6f6396
BLAKE2b-256 cda0eb73949c5068cb8db50df4283f525c13201dc7ea967382d16bbd4c7d1bf3

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unbound_gateway-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a26d65cd0265306f976a9229888f1a7cdab4322aa3719bf982f2130390707f3c
MD5 298bfc1449911b3169d90d014d581c5c
BLAKE2b-256 9d30e673ed9975c32129c8b15104783619e50ff851415324d52daac04d3ea27c

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