Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
03a7211
chore(tests): improve ci test names
jdreamerz May 22, 2025
c00212f
Merge branch 'next' of github.com:stainless-sdks/togetherai-python in…
jdreamerz May 24, 2025
145d6aa
Move the files upload into files resource.
jdreamerz May 29, 2025
abd41e8
Format
jdreamerz May 29, 2025
67bef5b
Fix circular import
jdreamerz May 29, 2025
271e713
Add async upload support
jdreamerz May 29, 2025
65ee27b
Remove top level exports of UploadManager, DownloadManager
jdreamerz May 29, 2025
16d6546
Merge pull request #15 from stainless-sdks/justindriemeyer/eng-30156-…
jdreamerz May 29, 2025
80d5ae0
feat(api): move upload to be a method of existing files resource
jdreamerz May 29, 2025
b7c43be
feat(api): move upload to be a method of existing files resource
jdreamerz May 29, 2025
d2a4b38
Merge branch 'next' of github.com:stainless-sdks/togetherai-python in…
jdreamerz May 29, 2025
b8bc101
fix(api): correct file reroute handling, error message
jdreamerz May 29, 2025
54839f2
Merge branch 'next' of github.com:stainless-sdks/togetherai-python in…
jdreamerz May 31, 2025
1931f17
chore(docs): remove reference to rye shell
stainless-app[bot] Jun 2, 2025
6ed818e
chore(docs): remove unnecessary param examples
stainless-app[bot] Jun 2, 2025
b515197
feat(client): add follow_redirects request option
stainless-app[bot] Jun 2, 2025
9172d87
Merge branch 'next' of github.com:stainless-sdks/togetherai-python in…
jdreamerz Jun 3, 2025
3cff5ae
feat(api): api update
stainless-app[bot] Jun 3, 2025
48986d2
feat(api): update spec / config to remove remaining codegen warnings
stainless-app[bot] Jun 3, 2025
a766a20
Merge branch 'next' of github.com:stainless-sdks/togetherai-python in…
jdreamerz Jun 9, 2025
33f1198
codegen metadata
stainless-app[bot] Jun 11, 2025
fb53416
codegen metadata
stainless-app[bot] Jun 11, 2025
dd20ba6
Merge branch 'next' of github.com:stainless-sdks/togetherai-python in…
jdreamerz Jun 15, 2025
7efb923
chore(tests): run tests in parallel
stainless-app[bot] Jun 16, 2025
7b9486c
fix(client): correctly parse binary response | stream
stainless-app[bot] Jun 12, 2025
249669c
feat(api): api update
stainless-app[bot] Jun 16, 2025
30ba23e
chore(tests): add tests for httpx client instantiation & proxies
stainless-app[bot] Jun 16, 2025
2b13ac4
chore(internal): update conftest.py
stainless-app[bot] Jun 16, 2025
6e4d972
chore(ci): enable for pull requests
stainless-app[bot] Jun 17, 2025
acfabb5
chore(readme): update badges
stainless-app[bot] Jun 17, 2025
82b2dcb
fix(tests): fix: tests which call HTTP endpoints directly with the ex…
stainless-app[bot] Jun 17, 2025
bed4e88
docs(client): fix httpx.Timeout documentation reference
stainless-app[bot] Jun 18, 2025
8fac9f3
chore: change publish docs url
stainless-app[bot] Jun 20, 2025
8e4cedf
feat(client): add support for aiohttp
stainless-app[bot] Jun 20, 2025
07299cc
feat(api): add batch api to config
stainless-app[bot] Jun 20, 2025
eac08ce
release: 0.1.0-alpha.13
stainless-app[bot] Jun 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
Expand Down
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "0.1.0-alpha.12"
".": "0.1.0-alpha.13"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 30
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-653a4aa26fdd2b335d1ead9c2ea0672cbe48a7616b76bf350a2421a8def4e08d.yml
openapi_spec_hash: 1d5af8ab9d8c11d7f5225e19ebd1654a
config_hash: d15dd709dd3f87b0a8b83b00b4abc881
configured_endpoints: 33
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/togetherai%2Ftogetherai-9ca24c17ccf9b0b4c2d27c09881dc74bf4cb44efc7a5ccb7d54fa15caee095d1.yml
openapi_spec_hash: 306c08678a0677f1deb1d35def6f8713
config_hash: fa59b4c1ab0a2e74aa855e7227b10c7d
31 changes: 31 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,36 @@
# Changelog

## 0.1.0-alpha.13 (2025-06-20)

Full Changelog: [v0.1.0-alpha.12...v0.1.0-alpha.13](https://github.com/togethercomputer/together-py/compare/v0.1.0-alpha.12...v0.1.0-alpha.13)

### Features

* **api:** add batch api to config ([07299cc](https://github.com/togethercomputer/together-py/commit/07299cc337cb356076643df7fc070b2fd8e85c54))
* **api:** api update ([249669c](https://github.com/togethercomputer/together-py/commit/249669c03db384d71c04fe69f78a579b5235c54c))
* **client:** add support for aiohttp ([8e4cedf](https://github.com/togethercomputer/together-py/commit/8e4cedf646520031811a97f65460f41b61894dd9))


### Bug Fixes

* **client:** correctly parse binary response | stream ([7b9486c](https://github.com/togethercomputer/together-py/commit/7b9486c29ef0eeb862460d1ee82417db9a8f801f))
* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([82b2dcb](https://github.com/togethercomputer/together-py/commit/82b2dcb43af96a7339b2305d02486d3084850303))


### Chores

* change publish docs url ([8fac9f3](https://github.com/togethercomputer/together-py/commit/8fac9f3e12630ed88b68c6cb7d798ebcc6a88833))
* **ci:** enable for pull requests ([6e4d972](https://github.com/togethercomputer/together-py/commit/6e4d972a3a3094fb2d8d468d1e3e89b173ce6ffd))
* **internal:** update conftest.py ([2b13ac4](https://github.com/togethercomputer/together-py/commit/2b13ac4298cc44c0515a3aa348cfdb4bc63d9cb2))
* **readme:** update badges ([acfabb5](https://github.com/togethercomputer/together-py/commit/acfabb57a60aab2853283f62d72897a8bb95a778))
* **tests:** add tests for httpx client instantiation & proxies ([30ba23e](https://github.com/togethercomputer/together-py/commit/30ba23e549ed87a82a7e49164b1809388486754b))
* **tests:** run tests in parallel ([7efb923](https://github.com/togethercomputer/together-py/commit/7efb923a6802382cdfe676c1124e6b9dafd8e233))


### Documentation

* **client:** fix httpx.Timeout documentation reference ([bed4e88](https://github.com/togethercomputer/together-py/commit/bed4e88653ff35029c1921bd2d940abade5b00c0))

## 0.1.0-alpha.12 (2025-06-10)

Full Changelog: [v0.1.0-alpha.11...v0.1.0-alpha.12](https://github.com/togethercomputer/together-py/compare/v0.1.0-alpha.11...v0.1.0-alpha.12)
Expand Down
46 changes: 43 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Together Python API library

[![PyPI version](https://img.shields.io/pypi/v/together.svg)](https://pypi.org/project/together/)
[![PyPI version](<https://img.shields.io/pypi/v/together.svg?label=pypi%20(stable)>)](https://pypi.org/project/together/)

The Together Python library provides convenient access to the Together REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand All @@ -20,7 +20,7 @@ pip install git+ssh://git@github.com/togethercomputer/together-py.git
```

> [!NOTE]
> Once this package is [published to PyPI](https://app.stainless.com/docs/guides/publish), this will become: `pip install --pre together`
> Once this package is [published to PyPI](https://www.stainless.com/docs/guides/publish), this will become: `pip install --pre together`

## Usage

Expand Down Expand Up @@ -83,6 +83,46 @@ asyncio.run(main())

Functionality between the synchronous and asynchronous clients is otherwise identical.

### With aiohttp

By default, the async client uses `httpx` for HTTP requests. However, for improved concurrency performance you may also use `aiohttp` as the HTTP backend.

You can enable this by installing `aiohttp`:

```sh
# install from the production repo
pip install 'together[aiohttp] @ git+ssh://git@github.com/togethercomputer/together-py.git'
```

Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from together import DefaultAioHttpClient
from together import AsyncTogether


async def main() -> None:
async with AsyncTogether(
api_key=os.environ.get("TOGETHER_API_KEY"), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
chat_completion = await client.chat.completions.create(
messages=[
{
"role": "user",
"content": "Say this is a test!",
}
],
model="mistralai/Mixtral-8x7B-Instruct-v0.1",
)
print(chat_completion.choices)


asyncio.run(main())
```

## Streaming responses

We provide support for streaming responses using Server Side Events (SSE).
Expand Down Expand Up @@ -258,7 +298,7 @@ client.with_options(max_retries=5).chat.completions.create(
### Timeouts

By default requests time out after 1 minute. You can configure this with a `timeout` option,
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/timeouts/#fine-tuning-the-configuration) object:

```python
from together import Together
Expand Down
14 changes: 14 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -220,3 +220,17 @@ from together.types import HardwareListResponse
Methods:

- <code title="get /hardware">client.hardware.<a href="./src/together/resources/hardware.py">list</a>(\*\*<a href="src/together/types/hardware_list_params.py">params</a>) -> <a href="./src/together/types/hardware_list_response.py">HardwareListResponse</a></code>

# Batches

Types:

```python
from together.types import BatchCreateResponse, BatchRetrieveResponse, BatchListResponse
```

Methods:

- <code title="post /batches">client.batches.<a href="./src/together/resources/batches.py">create</a>(\*\*<a href="src/together/types/batch_create_params.py">params</a>) -> <a href="./src/together/types/batch_create_response.py">BatchCreateResponse</a></code>
- <code title="get /batches/{id}">client.batches.<a href="./src/together/resources/batches.py">retrieve</a>(id) -> <a href="./src/together/types/batch_retrieve_response.py">BatchRetrieveResponse</a></code>
- <code title="get /batches">client.batches.<a href="./src/together/resources/batches.py">list</a>() -> <a href="./src/together/types/batch_list_response.py">BatchListResponse</a></code>
8 changes: 6 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "together"
version = "0.1.0-alpha.12"
version = "0.1.0-alpha.13"
description = "The official Python library for the together API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down Expand Up @@ -45,6 +45,9 @@ classifiers = [
Homepage = "https://github.com/togethercomputer/together-py"
Repository = "https://github.com/togethercomputer/together-py"

[project.optional-dependencies]
aiohttp = ["aiohttp", "httpx_aiohttp>=0.1.6"]

[project.scripts]
together = "together.lib.cli.cli:main"

Expand All @@ -64,6 +67,7 @@ dev-dependencies = [
"importlib-metadata>=6.7.0",
"rich>=13.7.1",
"nest_asyncio==1.6.0",
"pytest-xdist>=3.6.1",
"pytest-mock>=3.14.0",
]

Expand Down Expand Up @@ -136,7 +140,7 @@ replacement = '[\1](https://github.com/togethercomputer/together-py/tree/main/\g

[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--tb=short"
addopts = "--tb=short -n auto"
xfail_strict = true
asyncio_mode = "auto"
asyncio_default_fixture_loop_scope = "session"
Expand Down
31 changes: 31 additions & 0 deletions requirements-dev.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,24 @@
# universal: false

-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.13
# via httpx-aiohttp
# via together
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via together
argcomplete==3.1.2
# via nox
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -32,25 +43,37 @@ distro==1.8.0
exceptiongroup==1.2.2
# via anyio
# via pytest
execnet==2.1.1
# via pytest-xdist
filelock==3.12.4
# via virtualenv
frozenlist==1.7.0
# via aiohttp
# via aiosignal
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via httpx-aiohttp
# via respx
# via together
httpx-aiohttp==0.1.6
# via together
idna==3.4
# via anyio
# via httpx
# via yarl
importlib-metadata==7.0.0
iniconfig==2.0.0
# via pytest
markdown-it-py==3.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
multidict==6.5.0
# via aiohttp
# via yarl
mypy==1.14.1
mypy-extensions==1.0.0
# via mypy
Expand All @@ -69,6 +92,9 @@ platformdirs==3.11.0
# via virtualenv
pluggy==1.5.0
# via pytest
propcache==0.3.2
# via aiohttp
# via yarl
pyarrow==16.1.0
# via together
pyarrow-stubs==10.0.1.7
Expand All @@ -83,8 +109,10 @@ pyright==1.1.399
pytest==8.3.3
# via pytest-asyncio
# via pytest-mock
# via pytest-xdist
pytest-asyncio==0.24.0
pytest-mock==3.14.0
pytest-xdist==3.7.0
python-dateutil==2.8.2
# via time-machine
pytz==2023.3.post1
Expand Down Expand Up @@ -115,6 +143,7 @@ types-tqdm==4.67.0.20250516
# via together
typing-extensions==4.12.2
# via anyio
# via multidict
# via mypy
# via pydantic
# via pydantic-core
Expand All @@ -124,5 +153,7 @@ urllib3==2.4.0
# via types-requests
virtualenv==20.24.5
# via nox
yarl==1.20.1
# via aiohttp
zipp==3.17.0
# via importlib-metadata
27 changes: 27 additions & 0 deletions requirements.lock
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,22 @@
# universal: false

-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.13
# via httpx-aiohttp
# via together
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via together
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
certifi==2023.7.22
# via httpcore
# via httpx
Expand All @@ -24,19 +35,32 @@ distro==1.8.0
# via together
exceptiongroup==1.2.2
# via anyio
frozenlist==1.7.0
# via aiohttp
# via aiosignal
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via httpx-aiohttp
# via together
httpx-aiohttp==0.1.6
# via together
idna==3.4
# via anyio
# via httpx
# via yarl
multidict==6.5.0
# via aiohttp
# via yarl
numpy==2.0.0
# via pyarrow
pillow==10.4.0
# via together
propcache==0.3.2
# via aiohttp
# via yarl
pyarrow==16.1.0
# via together
pyarrow-stubs==10.0.1.7
Expand All @@ -60,8 +84,11 @@ types-tqdm==4.67.0.20250516
# via together
typing-extensions==4.12.2
# via anyio
# via multidict
# via pydantic
# via pydantic-core
# via together
urllib3==2.4.0
# via types-requests
yarl==1.20.1
# via aiohttp
3 changes: 2 additions & 1 deletion src/together/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
UnprocessableEntityError,
APIResponseValidationError,
)
from ._base_client import DefaultHttpxClient, DefaultAsyncHttpxClient
from ._base_client import DefaultHttpxClient, DefaultAioHttpClient, DefaultAsyncHttpxClient
from ._utils._logs import setup_logging as _setup_logging

__all__ = [
Expand Down Expand Up @@ -84,6 +84,7 @@
"DEFAULT_CONNECTION_LIMITS",
"DefaultHttpxClient",
"DefaultAsyncHttpxClient",
"DefaultAioHttpClient",
"create_finetune_request",
"FinetuneTrainingLimits",
"DownloadError",
Expand Down
Loading
Loading