Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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.43.0"
".": "0.44.0"
}
6 changes: 3 additions & 3 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 91
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-32aaecf1da425c37d534ed04df36003ab9d766a7755cd18f96541929a2a3ea59.yml
openapi_spec_hash: e326c47b99943cbbab473fde3b257221
config_hash: 421e8d0e71c7ef71fdfebede08ea7271
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/runloop-ai%2Frunloop-ecb3d41adaf06e76fd95f11d6da77c7aa0119387a3f372e736edd1579ec2aa03.yml
openapi_spec_hash: 2671664b7d6b0107a6402746033a65ac
config_hash: c4d0f5cf7262a18f9254da07d289f3ec
28 changes: 28 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
# Changelog

## 0.44.0 (2025-06-21)

Full Changelog: [v0.43.0...v0.44.0](https://github.com/runloopai/api-client-python/compare/v0.43.0...v0.44.0)

### Features

* **api:** api update ([8bd0a39](https://github.com/runloopai/api-client-python/commit/8bd0a3937ff3d5b3e03a34ab2fc291377bbc4203))
* **api:** api update ([8ebd055](https://github.com/runloopai/api-client-python/commit/8ebd055bb3760c7a01193df890ca7e56d7ff9c01))
* **client:** add support for aiohttp ([4237321](https://github.com/runloopai/api-client-python/commit/4237321688934fcc89a17588800ce33fb47d9633))


### Bug Fixes

* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([038fe71](https://github.com/runloopai/api-client-python/commit/038fe71f5d0bee93bdcad12af69a8f5b09b6664f))


### Chores

* **ci:** enable for pull requests ([f64b8a2](https://github.com/runloopai/api-client-python/commit/f64b8a2a52a28a86f25d8b8ad1998e9ce4dda542))
* **internal:** update conftest.py ([d840c86](https://github.com/runloopai/api-client-python/commit/d840c863eb3b080202874080e44b8ab0baa379c4))
* **readme:** update badges ([4b5af3f](https://github.com/runloopai/api-client-python/commit/4b5af3faf2f3cfbcee8474b864335eb0a4c0a78b))
* **tests:** add tests for httpx client instantiation & proxies ([938b9aa](https://github.com/runloopai/api-client-python/commit/938b9aa33ef7ae52809ca6e9111fc3265d70263d))


### Documentation

* **client:** fix httpx.Timeout documentation reference ([b8df915](https://github.com/runloopai/api-client-python/commit/b8df91557df34f77ce5a6f85769305628d9f2a1d))

## 0.43.0 (2025-06-14)

Full Changelog: [v0.42.0...v0.43.0](https://github.com/runloopai/api-client-python/compare/v0.42.0...v0.43.0)
Expand Down
36 changes: 34 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Runloop Python API library

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

The Runloop Python library provides convenient access to the Runloop REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
Expand Down Expand Up @@ -64,6 +64,38 @@ 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 PyPI
pip install runloop_api_client[aiohttp]
```

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

```python
import os
import asyncio
from runloop_api_client import DefaultAioHttpClient
from runloop_api_client import AsyncRunloop


async def main() -> None:
async with AsyncRunloop(
bearer_token=os.environ.get("RUNLOOP_API_KEY"), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
devbox_view = await client.devboxes.create()
print(devbox_view.id)


asyncio.run(main())
```

## Using types

Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:
Expand Down Expand Up @@ -235,7 +267,7 @@ client.with_options(max_retries=5).devboxes.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 runloop_api_client import Runloop
Expand Down
1 change: 1 addition & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ from runloop_api_client.types import (
ScenarioEnvironment,
ScenarioRunListView,
ScenarioRunView,
ScenarioUpdateParameters,
ScenarioView,
ScoringContract,
ScoringContractResultView,
Expand Down
4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "runloop_api_client"
version = "0.43.0"
version = "0.44.0"
description = "The official Python library for the runloop API"
dynamic = ["readme"]
license = "MIT"
Expand Down Expand Up @@ -37,6 +37,8 @@ classifiers = [
Homepage = "https://github.com/runloopai/api-client-python"
Repository = "https://github.com/runloopai/api-client-python"

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

[tool.rye]
managed = true
Expand Down
27 changes: 27 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.8
# via httpx-aiohttp
# via runloop-api-client
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via runloop-api-client
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 @@ -34,23 +45,33 @@ execnet==2.1.1
# via pytest-xdist
filelock==3.12.4
# via virtualenv
frozenlist==1.6.2
# 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 runloop-api-client
httpx-aiohttp==0.1.6
# via runloop-api-client
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.4.4
# via aiohttp
# via yarl
mypy==1.14.1
mypy-extensions==1.0.0
# via mypy
Expand All @@ -65,6 +86,9 @@ platformdirs==3.11.0
# via virtualenv
pluggy==1.5.0
# via pytest
propcache==0.3.1
# via aiohttp
# via yarl
pydantic==2.10.3
# via runloop-api-client
pydantic-core==2.27.1
Expand Down Expand Up @@ -97,12 +121,15 @@ tomli==2.0.2
# via pytest
typing-extensions==4.12.2
# via anyio
# via multidict
# via mypy
# via pydantic
# via pydantic-core
# via pyright
# via runloop-api-client
virtualenv==20.24.5
# via nox
yarl==1.20.0
# 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,27 +10,51 @@
# universal: false

-e file:.
aiohappyeyeballs==2.6.1
# via aiohttp
aiohttp==3.12.8
# via httpx-aiohttp
# via runloop-api-client
aiosignal==1.3.2
# via aiohttp
annotated-types==0.6.0
# via pydantic
anyio==4.4.0
# via httpx
# via runloop-api-client
async-timeout==5.0.1
# via aiohttp
attrs==25.3.0
# via aiohttp
certifi==2023.7.22
# via httpcore
# via httpx
distro==1.8.0
# via runloop-api-client
exceptiongroup==1.2.2
# via anyio
frozenlist==1.6.2
# via aiohttp
# via aiosignal
h11==0.14.0
# via httpcore
httpcore==1.0.2
# via httpx
httpx==0.28.1
# via httpx-aiohttp
# via runloop-api-client
httpx-aiohttp==0.1.6
# via runloop-api-client
idna==3.4
# via anyio
# via httpx
# via yarl
multidict==6.4.4
# via aiohttp
# via yarl
propcache==0.3.1
# via aiohttp
# via yarl
pydantic==2.10.3
# via runloop-api-client
pydantic-core==2.27.1
Expand All @@ -40,6 +64,9 @@ sniffio==1.3.0
# via runloop-api-client
typing-extensions==4.12.2
# via anyio
# via multidict
# via pydantic
# via pydantic-core
# via runloop-api-client
yarl==1.20.0
# via aiohttp
3 changes: 2 additions & 1 deletion src/runloop_api_client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,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 @@ -68,6 +68,7 @@
"DEFAULT_CONNECTION_LIMITS",
"DefaultHttpxClient",
"DefaultAsyncHttpxClient",
"DefaultAioHttpClient",
]

if not _t.TYPE_CHECKING:
Expand Down
22 changes: 22 additions & 0 deletions src/runloop_api_client/_base_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,6 +1289,24 @@ def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs)


try:
import httpx_aiohttp
except ImportError:

class _DefaultAioHttpClient(httpx.AsyncClient):
def __init__(self, **_kwargs: Any) -> None:
raise RuntimeError("To use the aiohttp client you must have installed the package with the `aiohttp` extra")
else:

class _DefaultAioHttpClient(httpx_aiohttp.HttpxAiohttpClient): # type: ignore
def __init__(self, **kwargs: Any) -> None:
kwargs.setdefault("timeout", DEFAULT_TIMEOUT)
kwargs.setdefault("limits", DEFAULT_CONNECTION_LIMITS)
kwargs.setdefault("follow_redirects", True)

super().__init__(**kwargs)


if TYPE_CHECKING:
DefaultAsyncHttpxClient = httpx.AsyncClient
"""An alias to `httpx.AsyncClient` that provides the same defaults that this SDK
Expand All @@ -1297,8 +1315,12 @@ def __init__(self, **kwargs: Any) -> None:
This is useful because overriding the `http_client` with your own instance of
`httpx.AsyncClient` will result in httpx's defaults being used, not ours.
"""

DefaultAioHttpClient = httpx.AsyncClient
"""An alias to `httpx.AsyncClient` that changes the default HTTP transport to `aiohttp`."""
else:
DefaultAsyncHttpxClient = _DefaultAsyncHttpxClient
DefaultAioHttpClient = _DefaultAioHttpClient


class AsyncHttpxClientWrapper(DefaultAsyncHttpxClient):
Expand Down
2 changes: 1 addition & 1 deletion src/runloop_api_client/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.

__title__ = "runloop_api_client"
__version__ = "0.43.0" # x-release-please-version
__version__ = "0.44.0" # x-release-please-version
Loading
Loading