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
2 changes: 1 addition & 1 deletion .github/workflows/publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
run: |
bash ./bin/publish-pypi
env:
PYPI_TOKEN: ${{ secrets.REPLICATE_CLIENT_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.REPLICATE_PYPI_TOKEN || secrets.PYPI_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ jobs:
run: |
bash ./bin/check-release-environment
env:
PYPI_TOKEN: ${{ secrets.REPLICATE_CLIENT_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.REPLICATE_PYPI_TOKEN || secrets.PYPI_TOKEN }}
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.8"
".": "0.1.0-alpha.9"
}
2 changes: 1 addition & 1 deletion .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/replicate%2Freplicate-client-0d7d82bff8a18b03e0cd1cbf8609c3026bb07db851bc6f9166032045a9925eea.yml
openapi_spec_hash: 8ce211dfa6fece24b1413e91ba55210a
config_hash: 2e6a171ce57a4a6a8e8dcd3dd893d8cc
config_hash: c784c102324b1d027c6ce40e17fe9590
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

## 0.1.0-alpha.9 (2025-05-06)

Full Changelog: [v0.1.0-alpha.8...v0.1.0-alpha.9](https://github.com/replicate/replicate-python-stainless/compare/v0.1.0-alpha.8...v0.1.0-alpha.9)

### Bug Fixes

* change organization.name to replicate ([04b0797](https://github.com/replicate/replicate-python-stainless/commit/04b079729cd431cad9e992c5c0a0d82ad838f5ef))


### Chores

* use lazy imports for module level client ([14f6cfc](https://github.com/replicate/replicate-python-stainless/commit/14f6cfcad3045d1bde023d1896b369057d3f6b77))
* use lazy imports for resources ([b2a0246](https://github.com/replicate/replicate-python-stainless/commit/b2a024612fc8b5a1bc7a15038cd33ab29e728b58))

## 0.1.0-alpha.8 (2025-04-30)

Full Changelog: [v0.1.0-alpha.7...v0.1.0-alpha.8](https://github.com/replicate/replicate-python-stainless/compare/v0.1.0-alpha.7...v0.1.0-alpha.8)
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier
identification within third-party archives.

Copyright 2025 Replicate Client
Copyright 2025 Replicate

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Replicate Client Python API library
# Replicate Python API library

[![PyPI version](https://img.shields.io/pypi/v/replicate-stainless.svg)](https://pypi.org/project/replicate-stainless/)

The Replicate Client Python library provides convenient access to the Replicate Client REST API from any Python 3.8+
The Replicate Python library provides convenient access to the Replicate REST API from any Python 3.8+
application. The library includes type definitions for all request params and response fields,
and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).

Expand All @@ -25,9 +25,9 @@ The full API of this library can be found in [api.md](api.md).

```python
import os
from replicate import ReplicateClient
from replicate import Replicate

client = ReplicateClient(
client = Replicate(
bearer_token=os.environ.get("REPLICATE_API_TOKEN"), # This is the default and can be omitted
)

Expand All @@ -42,14 +42,14 @@ so that your Bearer Token is not stored in source control.

## Async usage

Simply import `AsyncReplicateClient` instead of `ReplicateClient` and use `await` with each API call:
Simply import `AsyncReplicate` instead of `Replicate` and use `await` with each API call:

```python
import os
import asyncio
from replicate import AsyncReplicateClient
from replicate import AsyncReplicate

client = AsyncReplicateClient(
client = AsyncReplicate(
bearer_token=os.environ.get("REPLICATE_API_TOKEN"), # This is the default and can be omitted
)

Expand All @@ -75,14 +75,14 @@ Typed requests and responses provide autocomplete and documentation within your

## Pagination

List methods in the Replicate Client API are paginated.
List methods in the Replicate API are paginated.

This library provides auto-paginating iterators with each list response, so you do not have to request successive pages manually:

```python
from replicate import ReplicateClient
from replicate import Replicate

client = ReplicateClient()
client = Replicate()

all_predictions = []
# Automatically fetches more pages as needed.
Expand All @@ -96,9 +96,9 @@ Or, asynchronously:

```python
import asyncio
from replicate import AsyncReplicateClient
from replicate import AsyncReplicate

client = AsyncReplicateClient()
client = AsyncReplicate()


async def main() -> None:
Expand Down Expand Up @@ -147,9 +147,9 @@ All errors inherit from `replicate.APIError`.

```python
import replicate
from replicate import ReplicateClient
from replicate import Replicate

client = ReplicateClient()
client = Replicate()

try:
client.account.get()
Expand Down Expand Up @@ -186,10 +186,10 @@ Connection errors (for example, due to a network connectivity problem), 408 Requ
You can use the `max_retries` option to configure or disable retry settings:

```python
from replicate import ReplicateClient
from replicate import Replicate

# Configure the default for all requests:
client = ReplicateClient(
client = Replicate(
# default is 2
max_retries=0,
)
Expand All @@ -204,16 +204,16 @@ By default requests time out after 1 minute. You can configure this with a `time
which accepts a float or an [`httpx.Timeout`](https://www.python-httpx.org/advanced/#fine-tuning-the-configuration) object:

```python
from replicate import ReplicateClient
from replicate import Replicate

# Configure the default for all requests:
client = ReplicateClient(
client = Replicate(
# 20 seconds (default is 1 minute)
timeout=20.0,
)

# More granular control:
client = ReplicateClient(
client = Replicate(
timeout=httpx.Timeout(60.0, read=5.0, write=10.0, connect=2.0),
)

Expand All @@ -231,10 +231,10 @@ Note that requests that time out are [retried twice by default](#retries).

We use the standard library [`logging`](https://docs.python.org/3/library/logging.html) module.

You can enable logging by setting the environment variable `REPLICATE_CLIENT_LOG` to `info`.
You can enable logging by setting the environment variable `REPLICATE_LOG` to `info`.

```shell
$ export REPLICATE_CLIENT_LOG=info
$ export REPLICATE_LOG=info
```

Or to `debug` for more verbose logging.
Expand All @@ -256,9 +256,9 @@ if response.my_field is None:
The "raw" Response object can be accessed by prefixing `.with_raw_response.` to any HTTP method call, e.g.,

```py
from replicate import ReplicateClient
from replicate import Replicate

client = ReplicateClient()
client = Replicate()
response = client.account.with_raw_response.get()
print(response.headers.get('X-My-Header'))

Expand Down Expand Up @@ -330,10 +330,10 @@ You can directly override the [httpx client](https://www.python-httpx.org/api/#c

```python
import httpx
from replicate import ReplicateClient, DefaultHttpxClient
from replicate import Replicate, DefaultHttpxClient

client = ReplicateClient(
# Or use the `REPLICATE_CLIENT_BASE_URL` env var
client = Replicate(
# Or use the `REPLICATE_BASE_URL` env var
base_url="http://my.test.server.example.com:8083",
http_client=DefaultHttpxClient(
proxy="http://my.test.proxy.example.com",
Expand All @@ -353,9 +353,9 @@ client.with_options(http_client=DefaultHttpxClient(...))
By default the library closes underlying HTTP connections whenever the client is [garbage collected](https://docs.python.org/3/reference/datamodel.html#object.__del__). You can manually close the client using the `.close()` method if desired, or with a context manager that closes when exiting.

```py
from replicate import ReplicateClient
from replicate import Replicate

with ReplicateClient() as client:
with Replicate() as client:
# make requests here
...

Expand Down
4 changes: 2 additions & 2 deletions SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ before making any information public.
## Reporting Non-SDK Related Security Issues

If you encounter security issues that are not directly related to SDKs but pertain to the services
or products provided by Replicate Client please follow the respective company's security reporting guidelines.
or products provided by Replicate please follow the respective company's security reporting guidelines.

### Replicate Client Terms and Policies
### Replicate Terms and Policies

Please contact team@replicate.com for any questions or concerns regarding security of our services.

Expand Down
2 changes: 1 addition & 1 deletion bin/check-release-environment
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
errors=()

if [ -z "${PYPI_TOKEN}" ]; then
errors+=("The REPLICATE_CLIENT_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
errors+=("The REPLICATE_PYPI_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets.")
fi

lenErrors=${#errors[@]}
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[project]
name = "replicate-stainless"
version = "0.1.0-alpha.8"
description = "The official Python library for the replicate-client API"
version = "0.1.0-alpha.9"
description = "The official Python library for the replicate API"
dynamic = ["readme"]
license = "Apache-2.0"
authors = [
{ name = "Replicate Client", email = "team@replicate.com" },
{ name = "Replicate", email = "team@replicate.com" },
]
dependencies = [
"httpx>=0.23.0, <1",
Expand Down
18 changes: 9 additions & 9 deletions src/replicate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
Client,
Stream,
Timeout,
Replicate,
Transport,
AsyncClient,
AsyncStream,
AsyncReplicate,
RequestOptions,
ReplicateClient,
AsyncReplicateClient,
)
from ._models import BaseModel
from ._version import __title__, __version__
Expand All @@ -28,12 +28,12 @@
NotFoundError,
APIStatusError,
RateLimitError,
ReplicateError,
APITimeoutError,
BadRequestError,
APIConnectionError,
AuthenticationError,
InternalServerError,
ReplicateClientError,
PermissionDeniedError,
UnprocessableEntityError,
APIResponseValidationError,
Expand All @@ -51,7 +51,7 @@
"NotGiven",
"NOT_GIVEN",
"Omit",
"ReplicateClientError",
"ReplicateError",
"APIError",
"APIStatusError",
"APITimeoutError",
Expand All @@ -71,8 +71,8 @@
"AsyncClient",
"Stream",
"AsyncStream",
"ReplicateClient",
"AsyncReplicateClient",
"Replicate",
"AsyncReplicate",
"file_from_path",
"BaseModel",
"DEFAULT_TIMEOUT",
Expand Down Expand Up @@ -119,7 +119,7 @@
http_client: _httpx.Client | None = None


class _ModuleClient(ReplicateClient):
class _ModuleClient(Replicate):
# Note: we have to use type: ignores here as overriding class members
# with properties is technically unsafe but it is fine for our use case

Expand Down Expand Up @@ -202,10 +202,10 @@ def _client(self, value: _httpx.Client) -> None: # type: ignore
http_client = value


_client: ReplicateClient | None = None
_client: Replicate | None = None


def _load_client() -> ReplicateClient: # type: ignore[reportUnusedFunction]
def _load_client() -> Replicate: # type: ignore[reportUnusedFunction]
global _client

if _client is None:
Expand Down
Loading