Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
861dd6b
chore(tests): run tests in parallel
stainless-app[bot] Jun 13, 2025
abba5be
fix(client): correctly parse binary response | stream
stainless-app[bot] Jun 13, 2025
f853616
feat(api): update via SDK Studio
stainless-app[bot] Jun 13, 2025
8f5761b
feat(api): update via SDK Studio
stainless-app[bot] Jun 14, 2025
6254ccf
feat(api): update via SDK Studio
stainless-app[bot] Jun 14, 2025
8bd264b
feat(api): update via SDK Studio
stainless-app[bot] Jun 14, 2025
e75adfb
feat(api): update via SDK Studio
stainless-app[bot] Jun 14, 2025
0ccc62c
feat(api): update via SDK Studio
stainless-app[bot] Jun 14, 2025
6d62ab0
feat(api): update via SDK Studio
stainless-app[bot] Jun 14, 2025
cac54a8
feat(api): update via SDK Studio
stainless-app[bot] Jun 14, 2025
ed595b0
chore: update SDK settings
stainless-app[bot] Jun 16, 2025
7ecf66c
chore(tests): add tests for httpx client instantiation & proxies
stainless-app[bot] Jun 17, 2025
12e2103
chore(internal): update conftest.py
stainless-app[bot] Jun 17, 2025
b6b3f9e
chore(ci): enable for pull requests
stainless-app[bot] Jun 17, 2025
5ebec81
feat(api): update via SDK Studio
stainless-app[bot] Jun 17, 2025
c042496
feat(api): update via SDK Studio
stainless-app[bot] Jun 17, 2025
6e40dc3
chore(readme): update badges
stainless-app[bot] Jun 18, 2025
e649dcb
fix(tests): fix: tests which call HTTP endpoints directly with the ex…
stainless-app[bot] Jun 18, 2025
5f700dc
feat(api): update via SDK Studio
stainless-app[bot] Jun 18, 2025
e5c8d76
feat(api): update via SDK Studio
stainless-app[bot] Jun 18, 2025
aa2610a
feat(api): update via SDK Studio
stainless-app[bot] Jun 18, 2025
5d452d7
docs(client): fix httpx.Timeout documentation reference
stainless-app[bot] Jun 19, 2025
1fa7ebb
feat(api): update via SDK Studio
stainless-app[bot] Jun 19, 2025
eac41f1
feat(api): update via SDK Studio
stainless-app[bot] Jun 19, 2025
97e1768
feat(api): update via SDK Studio
stainless-app[bot] Jun 19, 2025
e59144c
feat(api): update via SDK Studio
stainless-app[bot] Jun 20, 2025
f27643e
feat(api): update via SDK Studio
stainless-app[bot] Jun 20, 2025
10b79fb
chore(internal): codegen related update
stainless-app[bot] Jun 21, 2025
494afde
feat(client): add support for aiohttp
stainless-app[bot] Jun 21, 2025
359c8d8
feat(api): update via SDK Studio
stainless-app[bot] Jun 21, 2025
d22592e
release: 0.1.0-alpha.4
stainless-app[bot] Jun 21, 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
10 changes: 7 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,16 @@ on:
- 'integrated/**'
- 'stl-preview-head/**'
- 'stl-preview-base/**'
pull_request:
branches-ignore:
- 'stl-preview-head/**'
- 'stl-preview-base/**'

jobs:
lint:
timeout-minutes: 10
name: lint
runs-on: ${{ github.repository == 'stainless-sdks/digitalocean-genai-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ github.repository == 'stainless-sdks/gradientai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

Expand All @@ -31,7 +35,7 @@ jobs:
run: ./scripts/lint

upload:
if: github.repository == 'stainless-sdks/digitalocean-genai-sdk-python'
if: github.repository == 'stainless-sdks/gradientai-python'
timeout-minutes: 10
name: upload
permissions:
Expand All @@ -57,7 +61,7 @@ jobs:
test:
timeout-minutes: 10
name: test
runs-on: ${{ github.repository == 'stainless-sdks/digitalocean-genai-sdk-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
runs-on: ${{ github.repository == 'stainless-sdks/gradientai-python' && 'depot-ubuntu-24.04' || 'ubuntu-latest' }}
steps:
- uses: actions/checkout@v4

Expand Down
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.DIGITALOCEAN_GENAI_SDK_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.GRADIENT_AI_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.DIGITALOCEAN_GENAI_SDK_PYPI_TOKEN || secrets.PYPI_TOKEN }}
PYPI_TOKEN: ${{ secrets.GRADIENT_AI_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.3"
".": "0.1.0-alpha.4"
}
8 changes: 4 additions & 4 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 60
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/digitalocean%2Fdigitalocean-genai-sdk-17838dec38ee8475c4bf4695b8dc70fe42a8f4da8ae9ffd415dc895b6628a952.yml
openapi_spec_hash: cfe5453e150989c8a9dbc9d7b4d1f76a
config_hash: 565bf6264bdf2a317cc5e2f02d02a702
configured_endpoints: 58
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/digitalocean%2Fgradientai-e40feaac59c85aace6aa42d2749b20e0955dbbae58b06c3a650bc03adafcd7b5.yml
openapi_spec_hash: 825c1a4816938e9f594b7a8c06692667
config_hash: 48e21c88c078b1d478257b2da0c840b2
49 changes: 49 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,54 @@
# Changelog

## 0.1.0-alpha.4 (2025-06-21)

Full Changelog: [v0.1.0-alpha.3...v0.1.0-alpha.4](https://github.com/digitalocean/genai-python/compare/v0.1.0-alpha.3...v0.1.0-alpha.4)

### Features

* **api:** update via SDK Studio ([359c8d8](https://github.com/digitalocean/genai-python/commit/359c8d88cec1d60f0beb810b5a0139443d0a3348))
* **api:** update via SDK Studio ([f27643e](https://github.com/digitalocean/genai-python/commit/f27643e1e00f606029be919a7117801facc6e5b7))
* **api:** update via SDK Studio ([e59144c](https://github.com/digitalocean/genai-python/commit/e59144c2d474a4003fd28b8eded08814ffa8d2f3))
* **api:** update via SDK Studio ([97e1768](https://github.com/digitalocean/genai-python/commit/97e17687a348b8ef218c23a06729b6edb1ac5ea9))
* **api:** update via SDK Studio ([eac41f1](https://github.com/digitalocean/genai-python/commit/eac41f12912b8d32ffa23d225f4ca56fa5c72505))
* **api:** update via SDK Studio ([1fa7ebb](https://github.com/digitalocean/genai-python/commit/1fa7ebb0080db9087b82d29e7197e44dfbb1ebed))
* **api:** update via SDK Studio ([aa2610a](https://github.com/digitalocean/genai-python/commit/aa2610afe7da79429e05bff64b4796de7f525681))
* **api:** update via SDK Studio ([e5c8d76](https://github.com/digitalocean/genai-python/commit/e5c8d768388b16c06fcc2abee71a53dcc8b3e8c5))
* **api:** update via SDK Studio ([5f700dc](https://github.com/digitalocean/genai-python/commit/5f700dc7a4e757015d3bd6f2e82a311114b82d77))
* **api:** update via SDK Studio ([c042496](https://github.com/digitalocean/genai-python/commit/c04249614917198b1eb2324438605d99b719a1cf))
* **api:** update via SDK Studio ([5ebec81](https://github.com/digitalocean/genai-python/commit/5ebec81604a206eba5e75a7e8990bd7711ba8f47))
* **api:** update via SDK Studio ([cac54a8](https://github.com/digitalocean/genai-python/commit/cac54a81a3f22d34b2de0ebfac3c68a982178cad))
* **api:** update via SDK Studio ([6d62ab0](https://github.com/digitalocean/genai-python/commit/6d62ab00594d70df0458a0a401f866af15a9298e))
* **api:** update via SDK Studio ([0ccc62c](https://github.com/digitalocean/genai-python/commit/0ccc62cb8ef387e0aaf6784db25d5f99a587e5da))
* **api:** update via SDK Studio ([e75adfb](https://github.com/digitalocean/genai-python/commit/e75adfbd2d035e57ae110a1d78ea40fb116975e5))
* **api:** update via SDK Studio ([8bd264b](https://github.com/digitalocean/genai-python/commit/8bd264b4b4686ca078bf4eb4b5462f058406df3e))
* **api:** update via SDK Studio ([6254ccf](https://github.com/digitalocean/genai-python/commit/6254ccf45cbe50ca8191c7149824964f5d00d82f))
* **api:** update via SDK Studio ([8f5761b](https://github.com/digitalocean/genai-python/commit/8f5761b1d18fb48ad7488e6f0ad771c077eb7961))
* **api:** update via SDK Studio ([f853616](https://github.com/digitalocean/genai-python/commit/f8536166320d1d5bacf1d10a5edb2f71691dde8b))
* **client:** add support for aiohttp ([494afde](https://github.com/digitalocean/genai-python/commit/494afde754f735d1ba95011fc83d23d2410fcfdd))


### Bug Fixes

* **client:** correctly parse binary response | stream ([abba5be](https://github.com/digitalocean/genai-python/commit/abba5be958d03a7e5ce7d1cbf8069c0bcf52ee20))
* **tests:** fix: tests which call HTTP endpoints directly with the example parameters ([e649dcb](https://github.com/digitalocean/genai-python/commit/e649dcb0f9416e9bf568cc9f3480d7e222052391))


### Chores

* **ci:** enable for pull requests ([b6b3f9e](https://github.com/digitalocean/genai-python/commit/b6b3f9ea85918cfc6fc7304b2d21c340d82a0083))
* **internal:** codegen related update ([10b79fb](https://github.com/digitalocean/genai-python/commit/10b79fb1d51bcff6ed0d18e5ccd18fd1cd75af9f))
* **internal:** update conftest.py ([12e2103](https://github.com/digitalocean/genai-python/commit/12e210389204ff74f504e1ec3aa5ba99f1b4971c))
* **readme:** update badges ([6e40dc3](https://github.com/digitalocean/genai-python/commit/6e40dc3fa4e33082be7b0bbf65d07e9ae9ac6370))
* **tests:** add tests for httpx client instantiation & proxies ([7ecf66c](https://github.com/digitalocean/genai-python/commit/7ecf66c58a124c153a32055967beacbd1a3bbcf3))
* **tests:** run tests in parallel ([861dd6b](https://github.com/digitalocean/genai-python/commit/861dd6b75956f2c12814ad32b05624d8d8537d52))
* update SDK settings ([ed595b0](https://github.com/digitalocean/genai-python/commit/ed595b0a23df125ffba733d7339e771997c3f149))


### Documentation

* **client:** fix httpx.Timeout documentation reference ([5d452d7](https://github.com/digitalocean/genai-python/commit/5d452d7245af6c80f47f8395f1c03493dfb53a52))

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

Full Changelog: [v0.1.0-alpha.2...v0.1.0-alpha.3](https://github.com/digitalocean/genai-python/compare/v0.1.0-alpha.2...v0.1.0-alpha.3)
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ $ pip install -r requirements-dev.lock

Most of the SDK is generated code. Modifications to code will be persisted between generations, but may
result in merge conflicts between manual patches and changes from the generator. The generator will never
modify the contents of the `src/digitalocean_genai_sdk/lib/` and `examples/` directories.
modify the contents of the `src/gradientai/lib/` and `examples/` directories.

## Adding and running examples

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 Digitalocean Genai SDK
Copyright 2025 Gradient AI

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
118 changes: 77 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Digitalocean Genai SDK Python API library
# Gradient AI Python API library

[![PyPI version](https://img.shields.io/pypi/v/c63a5cfe-b235-4fbe-8bbb-82a9e02a482a-python.svg)](https://pypi.org/project/c63a5cfe-b235-4fbe-8bbb-82a9e02a482a-python/)
[![PyPI version](<https://img.shields.io/pypi/v/c63a5cfe-b235-4fbe-8bbb-82a9e02a482a-python.svg?label=pypi%20(stable)>)](https://pypi.org/project/c63a5cfe-b235-4fbe-8bbb-82a9e02a482a-python/)

The Digitalocean Genai SDK Python library provides convenient access to the Digitalocean Genai SDK REST API from any Python 3.8+
The Gradient AI Python library provides convenient access to the Gradient AI 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,11 +25,11 @@ The full API of this library can be found in [api.md](api.md).

```python
import os
from digitalocean_genai_sdk import DigitaloceanGenaiSDK
from gradientai import GradientAI

client = DigitaloceanGenaiSDK(
client = GradientAI(
api_key=os.environ.get(
"DIGITALOCEAN_GENAI_SDK_API_KEY"
"DIGITALOCEAN_GRADIENTAI_API_KEY"
), # This is the default and can be omitted
)

Expand All @@ -41,21 +41,21 @@ print(versions.agent_versions)

While you can provide an `api_key` keyword argument,
we recommend using [python-dotenv](https://pypi.org/project/python-dotenv/)
to add `DIGITALOCEAN_GENAI_SDK_API_KEY="My API Key"` to your `.env` file
to add `DIGITALOCEAN_GRADIENTAI_API_KEY="My API Key"` to your `.env` file
so that your API Key is not stored in source control.

## Async usage

Simply import `AsyncDigitaloceanGenaiSDK` instead of `DigitaloceanGenaiSDK` and use `await` with each API call:
Simply import `AsyncGradientAI` instead of `GradientAI` and use `await` with each API call:

```python
import os
import asyncio
from digitalocean_genai_sdk import AsyncDigitaloceanGenaiSDK
from gradientai import AsyncGradientAI

client = AsyncDigitaloceanGenaiSDK(
client = AsyncGradientAI(
api_key=os.environ.get(
"DIGITALOCEAN_GENAI_SDK_API_KEY"
"DIGITALOCEAN_GRADIENTAI_API_KEY"
), # This is the default and can be omitted
)

Expand All @@ -72,6 +72,42 @@ 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 --pre c63a5cfe-b235-4fbe-8bbb-82a9e02a482a-python[aiohttp]
```

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

```python
import os
import asyncio
from gradientai import DefaultAioHttpClient
from gradientai import AsyncGradientAI


async def main() -> None:
async with AsyncGradientAI(
api_key=os.environ.get(
"DIGITALOCEAN_GRADIENTAI_API_KEY"
), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
versions = await client.agents.versions.list(
uuid="REPLACE_ME",
)
print(versions.agent_versions)


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 All @@ -86,9 +122,9 @@ Typed requests and responses provide autocomplete and documentation within your
Nested parameters are dictionaries, typed using `TypedDict`, for example:

```python
from digitalocean_genai_sdk import DigitaloceanGenaiSDK
from gradientai import GradientAI

client = DigitaloceanGenaiSDK()
client = GradientAI()

data_source = client.knowledge_bases.data_sources.create(
path_knowledge_base_uuid="knowledge_base_uuid",
Expand All @@ -99,29 +135,29 @@ print(data_source.aws_data_source)

## Handling errors

When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `digitalocean_genai_sdk.APIConnectionError` is raised.
When the library is unable to connect to the API (for example, due to network connection problems or a timeout), a subclass of `gradientai.APIConnectionError` is raised.

When the API returns a non-success status code (that is, 4xx or 5xx
response), a subclass of `digitalocean_genai_sdk.APIStatusError` is raised, containing `status_code` and `response` properties.
response), a subclass of `gradientai.APIStatusError` is raised, containing `status_code` and `response` properties.

All errors inherit from `digitalocean_genai_sdk.APIError`.
All errors inherit from `gradientai.APIError`.

```python
import digitalocean_genai_sdk
from digitalocean_genai_sdk import DigitaloceanGenaiSDK
import gradientai
from gradientai import GradientAI

client = DigitaloceanGenaiSDK()
client = GradientAI()

try:
client.agents.versions.list(
uuid="REPLACE_ME",
)
except digitalocean_genai_sdk.APIConnectionError as e:
except gradientai.APIConnectionError as e:
print("The server could not be reached")
print(e.__cause__) # an underlying Exception, likely raised within httpx.
except digitalocean_genai_sdk.RateLimitError as e:
except gradientai.RateLimitError as e:
print("A 429 status code was received; we should back off a bit.")
except digitalocean_genai_sdk.APIStatusError as e:
except gradientai.APIStatusError as e:
print("Another non-200-range status code was received")
print(e.status_code)
print(e.response)
Expand Down Expand Up @@ -149,10 +185,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 digitalocean_genai_sdk import DigitaloceanGenaiSDK
from gradientai import GradientAI

# Configure the default for all requests:
client = DigitaloceanGenaiSDK(
client = GradientAI(
# default is 2
max_retries=0,
)
Expand All @@ -166,19 +202,19 @@ client.with_options(max_retries=5).agents.versions.list(
### 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 digitalocean_genai_sdk import DigitaloceanGenaiSDK
from gradientai import GradientAI

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

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

Expand All @@ -198,10 +234,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 `DIGITALOCEAN_GENAI_SDK_LOG` to `info`.
You can enable logging by setting the environment variable `GRADIENT_AI_LOG` to `info`.

```shell
$ export DIGITALOCEAN_GENAI_SDK_LOG=info
$ export GRADIENT_AI_LOG=info
```

Or to `debug` for more verbose logging.
Expand All @@ -223,9 +259,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 digitalocean_genai_sdk import DigitaloceanGenaiSDK
from gradientai import GradientAI

client = DigitaloceanGenaiSDK()
client = GradientAI()
response = client.agents.versions.with_raw_response.list(
uuid="REPLACE_ME",
)
Expand All @@ -235,9 +271,9 @@ version = response.parse() # get the object that `agents.versions.list()` would
print(version.agent_versions)
```

These methods return an [`APIResponse`](https://github.com/digitalocean/genai-python/tree/main/src/digitalocean_genai_sdk/_response.py) object.
These methods return an [`APIResponse`](https://github.com/digitalocean/genai-python/tree/main/src/gradientai/_response.py) object.

The async client returns an [`AsyncAPIResponse`](https://github.com/digitalocean/genai-python/tree/main/src/digitalocean_genai_sdk/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.
The async client returns an [`AsyncAPIResponse`](https://github.com/digitalocean/genai-python/tree/main/src/gradientai/_response.py) with the same structure, the only difference being `await`able methods for reading the response content.

#### `.with_streaming_response`

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

```python
import httpx
from digitalocean_genai_sdk import DigitaloceanGenaiSDK, DefaultHttpxClient
from gradientai import GradientAI, DefaultHttpxClient

client = DigitaloceanGenaiSDK(
# Or use the `DIGITALOCEAN_GENAI_SDK_BASE_URL` env var
client = GradientAI(
# Or use the `GRADIENT_AI_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 @@ -324,9 +360,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 digitalocean_genai_sdk import DigitaloceanGenaiSDK
from gradientai import GradientAI

with DigitaloceanGenaiSDK() as client:
with GradientAI() as client:
# make requests here
...

Expand All @@ -352,8 +388,8 @@ If you've upgraded to the latest version but aren't seeing any new features you
You can determine the version that is being used at runtime with:

```py
import digitalocean_genai_sdk
print(digitalocean_genai_sdk.__version__)
import gradientai
print(gradientai.__version__)
```

## Requirements
Expand Down
Loading