Skip to main content
The Unbound SDK is built on top of a compatible SDK interface, allowing you to seamlessly integrate Unbound’s advanced features while retaining full compatibility with existing methods. With Unbound, you can enhance your interactions with AI providers by leveraging robust monitoring, reliability, prompt management, and more features - without modifying much of your existing code.

Usage

Prerequisites

Installing the SDK

pip install unbound-gateway

Making a Request to Unbound

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

unbound = Unbound(
    base_url="https://api.getunbound.ai",
    api_key="UNBOUND_API_KEY",
)

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

print(chat_completion)
chat_completion is a plain Python dict matching the Chat Completions API response, not a typed Pydantic model. Access fields by key — for example chat_completion["choices"][0]["message"]["content"].

Async Usage

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

unbound = AsyncUnbound(
    base_url="https://api.getunbound.ai",
    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='openai/gpt-4o'
    )

    print(chat_completion)

asyncio.run(main())