Python Configuration
You can customize the behavior of the Python SDK generator in generators.yml
:
SDK Configuration Options
additional_init_exports
client
default_bytes_stream_chunk_size
The chunk size to use (if any) when processing a response bytes stream within iter_bytes
or aiter_bytes
results in: for chunk in response.iter_bytes(chunk_size=<default_bytes_stream_chunk_size>):
exclude_types_from_init_exports
extra_dependencies
If you want to add custom dependencies to your generated SDK, you can specify them using this configuration. For example, to add a dependency on boto3, your config would look like:
extra_dev_dependencies
extras
flat_layout
follow_redirects_by_default
Whether to follow redirects by default in HTTP requests.
improved_imports
Feature flag that improves imports in the Python SDK by removing nested resources
directory
include_legacy_wire_tests
Whether or not to include legacy wire tests in the generated SDK
include_union_utils
inline_path_params
If true, treats path parameters as named parameters in endpoint functions.
inline_request_params
Feature flag that removes the usage of request objects, and instead uses parameters in function signatures where possible.
package_name
pydantic_config
pydantic_config.include_union_utils
When enabled, the generator will output a Pydantic __root__
class that will contain utilities to visit the union. For example, for the following union type:
you will get a generated Shape
class that has a factory and visitor:
When enabled, the python generator will not run Black formatting in the generated code. Black is slow so this can potentially speed up code generation quite a bit.
pydantic_config.version
By default, the generator generates pydantic models that are v1 and v2 compatible. However you can override them to:
v1
: strictly use Pydantic v1v2
: strictly use Pydantic v2both
: maintain compatibility with both versionsv1_on_v2
: use Pydantic v1 compatibility layer on v2
Example:
pyproject_python_version
pyproject_toml
should_generate_websocket_clients
Feature flag that enables generation of Python websocket clients.
skip_formatting
timeout_in_seconds
By default, the generator generates a client that times out after 60 seconds. You can customize this value by providing a different number or setting to infinity
to get rid of timeouts.
use_api_name_in_package
use_inheritance_for_extended_models
Whether to generate Pydantic models that implement inheritance when a model utilizes the Fern extends
keyword.
use_typeddict_requests
Whether or not to generate TypedDicts
instead of Pydantic Models for request objects.
use_typeddict_requests_for_file_upload
Whether or not to generate TypedDicts instead of Pydantic Models for file upload request objects. Note that this flag was only introduced due to an oversight in the use_typeddict_requests
flag implementation; it should be removed in the future.