Python SDK

Install and start using the Python SDK.

Intro

The Together APIs SDK provides access to the Together APIs REST APIs.

The Together REST API. See https://docs.together.ai for more details.

Installation

To install the SDK from PyPI, with whichever package manager your project uses:

Terminal
pip install t-ai-apimatic-sdk
Terminal
uv add t-ai-apimatic-sdk
Terminal
poetry add t-ai-apimatic-sdk

To install from the SDK source instead, give the tool a path containing a slash — a bare folder name is looked up on PyPI, and resolves to whatever project holds that name there:

Terminal
pip install <path-to-sdk>

Quick Start

Synchronous client

Construct TogetherApisClient with keyword arguments, and call close() when you are done. Every argument is optional.

Python
from together_apis import TogetherApisClient

client = TogetherApisClient(bearer_auth="YOUR_BEARER_TOKEN", environment="production")

client.close()

Alternatively, scope it — with TogetherApisClient(...) as client: closes the pool on exit.

Asynchronous client

AsyncTogetherApisClient mirrors TogetherApisClient with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences — for example, the transport argument is custom_async_http_client.

Python
from asyncio import run

from together_apis import AsyncTogetherApisClient


async def main() -> None:
    client = AsyncTogetherApisClient(bearer_auth="YOUR_BEARER_TOKEN", environment="production")
    await client.aclose()


run(main())

Alternatively, scope it — async with AsyncTogetherApisClient(...) as client: closes the pool on exit.

On this page