Python SDK
Install and start using the Python SDK.
Intro
The Cloudinary API v1.1 SDK provides access to the Cloudinary API v1.1 REST APIs.
Installation
Add the SDK to your project from its folder, with whichever package manager your project uses. Give each tool a path containing a slash, such as ../cloudinary-api-v1-1 — a bare folder name is looked up on PyPI instead, and resolves to whatever project holds that name there:
pip install <path-to-sdk>uv add <path-to-sdk>poetry add <path-to-sdk>Quick Start
Synchronous client
Construct CloudinaryApiV11Client with keyword arguments, and call close() when you are done. Every argument is optional.
from cloudinary_api_v1_1 import CloudinaryApiV11Client
from cloudinary_api_v1_1.auth import Oauth2Scope
from cloudinary_api_v1_1.core import AuthorizationCodeCredentials, BasicAuthCredentials
def prompt(url: str) -> str:
return input(f"Open {url}, then paste the code: ")
client = CloudinaryApiV11Client(
basic_auth=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD"),
oauth2=AuthorizationCodeCredentials[Oauth2Scope](
client_id="YOUR_CLIENT_ID", redirect_uri="YOUR_REDIRECT_URI", prompt_for_authorization_code=prompt
),
environment="production",
)
client.close()Alternatively, scope it — with CloudinaryApiV11Client(...) as client: closes the pool on exit.
Asynchronous client
AsyncCloudinaryApiV11Client mirrors CloudinaryApiV11Client with identical method names, and every endpoint method is a coroutine. It takes the same arguments, with some differences — for example, the transport argument is custom_async_http_client.
from asyncio import run, to_thread
from cloudinary_api_v1_1 import AsyncCloudinaryApiV11Client
from cloudinary_api_v1_1.auth import Oauth2Scope
from cloudinary_api_v1_1.core import AsyncAuthorizationCodeCredentials, BasicAuthCredentials
async def prompt(url: str) -> str:
print(f"Open {url}")
return await to_thread(input, "Paste the code: ")
async def main() -> None:
client = AsyncCloudinaryApiV11Client(
basic_auth=BasicAuthCredentials(username="YOUR_USERNAME", password="YOUR_PASSWORD"),
oauth2=AsyncAuthorizationCodeCredentials[Oauth2Scope](
client_id="YOUR_CLIENT_ID", redirect_uri="YOUR_REDIRECT_URI", prompt_for_authorization_code=prompt
),
environment="production",
)
await client.aclose()
run(main())Alternatively, scope it — async with AsyncCloudinaryApiV11Client(...) as client: closes the pool on exit.