Python Configuration Options
This section details the available configuration options for the Python SDK. All configuration is managed in the gen.yaml file under the python section.
Version and general configuration
python:
version: 1.2.3
authors: ["Author Name"]
packageName: "openapi"
moduleName: "openapi"
packageManager: "uv" # or "poetry" to switch to poetryDescription and URLs
python:
description: "Python Client SDK Generated by Speakeasy."
homepage: "https://example.com"
documentationUrl: "https://example.com/docs"Different package and module names
You can configure a different name for the PyPI package and the module users will import from:
python:
packageName: "my-package" # Users will install with: pip install my-package
moduleName: "my_module" # Users will import with: from my_module import SDKThis can be useful when you want the package name to follow PyPI conventions (using hyphens) but the module name to follow Python conventions (using underscores).
Additional dependencies
python:
additionalDependencies:
main:
requests: "^2.25.1"
dev:
pytest: "^6.2.1"Method and parameter management
python:
maxMethodParams: 4
flatteningOrder: "parameters-first"
methodArguments: "infer-optional-args"Security configuration
python:
envVarPrefix: "SPEAKEASY"
flattenGlobalSecurity: trueImport management
python:
imports:
option: "openapi"
paths:
callbacks: "models/callbacks"
errors: "models/errors"
operations: "models/operations"
shared: "models/shared"
webhooks: "models/webhooks"Import paths
Error and response handling
python:
clientServerStatusCodesAsErrors: true
responseFormat: "flat"
enumFormat: "enum"Async method configuration
python:
asyncMode: split # or "both" (default)The asyncMode setting provides two patterns for handling async operations:
Method-based (both, default): Every operation has two methods - a synchronous version and an asynchronous version with an _async suffix.
sdk = MyAPI(api_key="...")
# Synchronous operations
result = sdk.list_users()
# Asynchronous operations
result = await sdk.list_users_async()Constructor-based (split): Separate constructors for synchronous and asynchronous clients. All method names are identical between sync and async versions.
# Synchronous client
sync_sdk = MyAPI(api_key="...")
result = sync_sdk.list_users()
# Asynchronous client
async_sdk = AsyncMyAPI(api_key="...")
result = await async_sdk.list_users()The constructor-based pattern eliminates method name duplication and provides clearer IDE suggestions.
Breaking change
Switching to asyncMode: split is a breaking change. Existing SDK users will need to update their code to use the new constructor pattern.
Server-sent events configuration
python:
sseFlatResponse: truePytest configuration
python:
pytestFilterWarnings:
- error
- "ignore::DeprecationWarning"
pytestTimeout: 300Fix flags
python:
fixFlags:
asyncPaginationSep2025: trueLast updated on