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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for unbound_gateway-0.1.2.tar.gz
Algorithm Hash digest
SHA256 bf0710ef2569b6a2dc0af56bb2f03794fff3c95b62a7dcfc295d98dfb3ad3947
MD5 ece7182cd0ac57f08dd627374a71a2c9
BLAKE2b-256 4ac41e242ac4426042c9d6454677f86107ee6d6989b68a0433da5fbab97b7a80

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for unbound_gateway-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 82ea108a891f52246b442c8fe168f6a234b26460b9ea936b27363688da7c3470
MD5 02f030e303c9ad9feee9b425836b956b
BLAKE2b-256 cfb48857d378c7b22a8595a5b4bc71be2b4c801267c0d37f24483db7600450aa

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