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: ["Your Name"]
packageName: "openapi"

NameRequiredDefault ValueDescription
versiontrue0.0.1The current version of the SDK.
packageNametrueopenapiThe distribution name of the PyPI package. See Python Package Metadata (opens in a new tab).
authorstrue["Speakeasy"]Authors of the published package. See Poetry Authors Field (opens in a new tab).

Description and URLs


python:
description: "Python Client SDK Generated by Speakeasy."
homepage: "https://example.com"
documentationUrl: "https://example.com/docs"

NameRequiredDefault ValueDescription
descriptionfalse"Python Client SDK Generated by Speakeasy."A short description of the project. See Poetry Description Field (opens in a new tab).
homepagefalsenullThe URL for the homepage of the project.
documentationUrlfalsenullThe URL for the project documentation.

Additional Dependencies


python:
additionalDependencies:
main:
requests: "^2.25.1"
dev:
pytest: "^6.2.1"

NameRequiredDefault ValueDescription
additionalDependenciesfalse{}Specify additional dependencies to include in the generated pyproject.toml file.

Method and Paramater Management


python:
maxMethodParams: 4
flatteningOrder: "parameters-first"
methodArguments: "infer-optional-args"

NameRequiredDefault ValueDescription
flattenRequestsfalsetrueTurn request parameters and body fields into a flat list of method arguments. This takes precedence over maxMethodParams. If there is no request body then maxMethodParams will be respected.
maxMethodParamsfalse9999Maximum number of parameters before an input object is created. 0 means input objects are always used.
flatteningOrderfalseparameters-firstDetermines the ordering of method arguments when flattening parameters and body fields. parameters-first or body-first
methodArgumentsfalserequire-security-and-requestDetermines how arguments for SDK methods are generated.

Security Configuratiaon


python:
envVarPrefix: "SPEAKEASY"
flattenGlobalSecurity: true

NameRequiredDefault ValueDescription
flattenGlobalSecurityfalsetrueEnables inline security credentials during SDK instantiation.
envVarPrefixfalse""Sets a prefix for environment variables that allows users to configure global parameters and security.

Import Management


python:
imports:
option: "openapi"
paths:
callbacks: "models/callbacks"
errors: "models/errors"
operations: "models/operations"
shared: "models/shared"
webhooks: "models/webhooks"

FieldRequiredDefault ValueDescription
optionfalse"openapi"Defines the type of import strategy. Typically set to "openapi", indicating that the structure is based on the OpenAPI document.
pathsfalse{}Customizes where different parts of the SDK (e.g., callbacks, errors, operations) will be imported from.

Import Paths

ComponentDefault ValueDescription
callbacksmodels/callbacksThe directory where callback models will be imported from.
errorsmodels/errorsThe directory where error models will be imported from.
operationsmodels/operationsThe directory where operation models (i.e., API endpoints) will be imported from.
sharedmodels/componentsThe directory for shared components, such as reusable schemas and data models, imported from the OpenAPI spec.
webhooksmodels/webhooksThe directory for webhook models, if your SDK includes support for webhooks.

Error and Response Handling


python:
clientServerStatusCodesAsErrors: true
responseFormat: "flat"
enumFormat: "enum"

NameRequiredDefault ValueDescription
clientServerStatusCodesAsErrorsfalsetrueWhether to treat 4XX and 5XX status codes as errors.
responseFormatfalseflatDefines how responses are structured. Options: envelope, envelope-http, or flat.
enumFormatfalseenumDetermines how enums are generated. Options: enum (Python enums) or union (union types).