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 .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "5.24.0"
".": "5.25.0"
}
2 changes: 1 addition & 1 deletion .stats.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
configured_endpoints: 73
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/retell%2Fretell-56de19127afbdf111fd60a0aa1188496712acbcf9069d535396af6e66a0afd70.yml
openapi_spec_hash: a56e1bcb7ab38d9fade4a42840e7e15f
config_hash: bf63cd880955c4d6be170f4c6c68959e
config_hash: 5936ef3375d1ec06069b8f2794dd1dd2
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 5.25.0 (2026-04-02)

Full Changelog: [v5.24.0...v5.25.0](https://github.com/RetellAI/retell-python-sdk/compare/v5.24.0...v5.25.0)

### Features

* **api:** api update ([2718f4b](https://github.com/RetellAI/retell-python-sdk/commit/2718f4b8f33771777048d98734b577430dc0abad))

## 5.24.0 (2026-04-01)

Full Changelog: [v5.23.0...v5.24.0](https://github.com/RetellAI/retell-python-sdk/compare/v5.23.0...v5.24.0)
Expand Down
14 changes: 11 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,11 @@ pip install retell-sdk
The full API of this library can be found in [api.md](api.md).

```python
import os
from retell import Retell

client = Retell(
api_key="YOUR_RETELL_API_KEY",
api_key=os.environ.get("RETELL_API_KEY"), # This is the default and can be omitted
)

agent_response = client.agent.create(
Expand All @@ -48,16 +49,22 @@ agent_response = client.agent.create(
print(agent_response.agent_id)
```

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

## Async usage

Simply import `AsyncRetell` instead of `Retell` and use `await` with each API call:

```python
import os
import asyncio
from retell import AsyncRetell

client = AsyncRetell(
api_key="YOUR_RETELL_API_KEY",
api_key=os.environ.get("RETELL_API_KEY"), # This is the default and can be omitted
)


Expand Down Expand Up @@ -91,14 +98,15 @@ pip install retell-sdk[aiohttp]
Then you can enable it by instantiating the client with `http_client=DefaultAioHttpClient()`:

```python
import os
import asyncio
from retell import DefaultAioHttpClient
from retell import AsyncRetell


async def main() -> None:
async with AsyncRetell(
api_key="YOUR_RETELL_API_KEY",
api_key=os.environ.get("RETELL_API_KEY"), # This is the default and can be omitted
http_client=DefaultAioHttpClient(),
) as client:
agent_response = await client.agent.create(
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "retell-sdk"
version = "5.24.0"
version = "5.25.0"
description = "The official Python library for the retell API"
dynamic = ["readme"]
license = "Apache-2.0"
Expand Down
28 changes: 23 additions & 5 deletions src/retell/_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from ._compat import cached_property
from ._version import __version__
from ._streaming import Stream as Stream, AsyncStream as AsyncStream
from ._exceptions import APIStatusError
from ._exceptions import RetellError, APIStatusError
from ._base_client import (
DEFAULT_MAX_RETRIES,
SyncAPIClient,
Expand Down Expand Up @@ -76,7 +76,7 @@ class Retell(SyncAPIClient):
def __init__(
self,
*,
api_key: str,
api_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand All @@ -96,7 +96,16 @@ def __init__(
# part of our public interface in the future.
_strict_response_validation: bool = False,
) -> None:
"""Construct a new synchronous Retell client instance."""
"""Construct a new synchronous Retell client instance.

This automatically infers the `api_key` argument from the `RETELL_API_KEY` environment variable if it is not provided.
"""
if api_key is None:
api_key = os.environ.get("RETELL_API_KEY")
if api_key is None:
raise RetellError(
"The api_key client option must be set either by passing api_key to the client or by setting the RETELL_API_KEY environment variable"
)
self.api_key = api_key
self.verify = verify # type: ignore

Expand Down Expand Up @@ -320,7 +329,7 @@ class AsyncRetell(AsyncAPIClient):
def __init__(
self,
*,
api_key: str,
api_key: str | None = None,
base_url: str | httpx.URL | None = None,
timeout: float | Timeout | None | NotGiven = not_given,
max_retries: int = DEFAULT_MAX_RETRIES,
Expand All @@ -340,7 +349,16 @@ def __init__(
# part of our public interface in the future.
_strict_response_validation: bool = False,
) -> None:
"""Construct a new async AsyncRetell client instance."""
"""Construct a new async AsyncRetell client instance.

This automatically infers the `api_key` argument from the `RETELL_API_KEY` environment variable if it is not provided.
"""
if api_key is None:
api_key = os.environ.get("RETELL_API_KEY")
if api_key is None:
raise RetellError(
"The api_key client option must be set either by passing api_key to the client or by setting the RETELL_API_KEY environment variable"
)
self.api_key = api_key

if base_url is None:
Expand Down
2 changes: 1 addition & 1 deletion src/retell/_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__ = "retell"
__version__ = "5.24.0" # x-release-please-version
__version__ = "5.25.0" # x-release-please-version
12 changes: 11 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from retell._types import Omit
from retell._utils import asyncify
from retell._models import BaseModel, FinalRequestOptions
from retell._exceptions import APIStatusError, APITimeoutError, APIResponseValidationError
from retell._exceptions import RetellError, APIStatusError, APITimeoutError, APIResponseValidationError
from retell._base_client import (
DEFAULT_TIMEOUT,
HTTPX_DEFAULT_TIMEOUT,
Expand Down Expand Up @@ -402,6 +402,11 @@ def test_validate_headers(self) -> None:
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
assert request.headers.get("Authorization") == f"Bearer {api_key}"

with pytest.raises(RetellError):
with update_env(**{"RETELL_API_KEY": Omit()}):
client2 = Retell(base_url=base_url, api_key=None, _strict_response_validation=True)
_ = client2

def test_default_query_option(self) -> None:
client = Retell(
base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
Expand Down Expand Up @@ -1316,6 +1321,11 @@ def test_validate_headers(self) -> None:
request = client._build_request(FinalRequestOptions(method="get", url="/foo"))
assert request.headers.get("Authorization") == f"Bearer {api_key}"

with pytest.raises(RetellError):
with update_env(**{"RETELL_API_KEY": Omit()}):
client2 = AsyncRetell(base_url=base_url, api_key=None, _strict_response_validation=True)
_ = client2

async def test_default_query_option(self) -> None:
client = AsyncRetell(
base_url=base_url, api_key=api_key, _strict_response_validation=True, default_query={"query_param": "bar"}
Expand Down