Metadata-Version: 2.4
Name: speakeasy-client-sdk-python
Version: 7.0.0rc3
Summary: Speakeasy API Client SDK for Python
Author: Speakeasy
Requires-Python: >=3.10
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Requires-Dist: httpcore (>=1.0.9)
Requires-Dist: httpx (>=0.28.1)
Requires-Dist: pydantic (>=2.11.2)
Project-URL: Repository, https://github.com/speakeasy-api/speakeasy-client-sdk-python.git
Description-Content-Type: text/markdown

undefined
<!-- Start Summary [summary] -->
## Summary

Speakeasy API: The Subscriptions API manages subscriptions for CLI and registry events

For more information about the API: [The Speakeasy Platform Documentation](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/.//docs)
<!-- End Summary [summary] -->

<!-- Start Table of Contents [toc] -->
## Table of Contents
<!-- $toc-max-depth=2 -->
  * [SDK Installation](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#sdk-installation)
  * [IDE Support](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#ide-support)
  * [SDK Example Usage](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#sdk-example-usage)
  * [Authentication](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#authentication)
  * [Available Resources and Operations](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#available-resources-and-operations)
  * [Global Parameters](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#global-parameters)
  * [File uploads](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#file-uploads)
  * [Retries](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#retries)
  * [Error Handling](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#error-handling)
  * [Server Selection](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#server-selection)
  * [Custom HTTP Client](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#custom-http-client)
  * [Resource Management](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#resource-management)
  * [Debugging](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#debugging)

<!-- End Table of Contents [toc] -->

<!-- Start SDK Installation [installation] -->
## SDK Installation

> [!NOTE]
> **Python version upgrade policy**
>
> Once a Python version reaches its [official end of life date](https://devguide.python.org/versions/), a 3-month grace period is provided for users to upgrade. Following this grace period, the minimum python version supported in the SDK will be updated.

The SDK can be installed with *uv*, *pip*, or *poetry* package managers.

### uv

*uv* is a fast Python package installer and resolver, designed as a drop-in replacement for pip and pip-tools. It's recommended for its speed and modern Python tooling capabilities.

```bash
uv add speakeasy-client-sdk-python
```

### PIP

*PIP* is the default package installer for Python, enabling easy installation and management of packages from PyPI via the command line.

```bash
pip install speakeasy-client-sdk-python
```

### Poetry

*Poetry* is a modern tool that simplifies dependency management and package publishing by using a single `pyproject.toml` file to handle project metadata and dependencies.

```bash
poetry add speakeasy-client-sdk-python
```

### Shell and script usage with `uv`

You can use this SDK in a Python shell with [uv](https://docs.astral.sh/uv/) and the `uvx` command that comes with it like so:

```shell
uvx --from speakeasy-client-sdk-python python
```

It's also possible to write a standalone Python script without needing to set up a whole project like so:

```python
#!/usr/bin/env -S uv run --script
# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "speakeasy-client-sdk-python",
# ]
# ///

from speakeasy_client_sdk_python import Speakeasy

sdk = Speakeasy(
  # SDK arguments
)

# Rest of script here...
```

Once that is saved to a file, you can run it with `uv run script.py` where
`script.py` can be replaced with the actual file name.
<!-- End SDK Installation [installation] -->

<!-- Start IDE Support [idesupport] -->
## IDE Support

### PyCharm

Generally, the SDK will work well with most IDEs out of the box. However, when using PyCharm, you can enjoy much better integration with Pydantic by installing an additional plugin.

- [PyCharm Pydantic Plugin](https://docs.pydantic.dev/latest/integrations/pycharm/)
<!-- End IDE Support [idesupport] -->

<!-- Start SDK Example Usage [usage] -->
## SDK Example Usage

### Example

```python
# Synchronous Example
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared


with Speakeasy(
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:

    res = speakeasy.artifacts.create_remote_source()

    assert res is not None

    # Handle response
    print(res)
```

</br>

The same SDK client can also be used to make asynchronous requests by importing asyncio.

```python
# Asynchronous Example
import asyncio
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared

async def main():

    async with Speakeasy(
        security=shared.Security(
            api_key="<YOUR_API_KEY_HERE>",
        ),
    ) as speakeasy:

        res = await speakeasy.artifacts.create_remote_source_async()

        assert res is not None

        # Handle response
        print(res)

asyncio.run(main())
```
<!-- End SDK Example Usage [usage] -->

<!-- Start Authentication [security] -->
## Authentication

### Per-Client Security Schemes

This SDK supports the following security schemes globally:

| Name                   | Type   | Scheme      |
| ---------------------- | ------ | ----------- |
| `api_key`              | apiKey | API key     |
| `bearer`               | http   | HTTP Bearer |
| `workspace_identifier` | apiKey | API key     |

You can set the security parameters through the `security` optional parameter when initializing the SDK client instance. The selected scheme will be used by default to authenticate with the API for all operations that support it. For example:
```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared


with Speakeasy(
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:

    res = speakeasy.artifacts.create_remote_source()

    assert res is not None

    # Handle response
    print(res)

```
<!-- End Authentication [security] -->

<!-- Start Available Resources and Operations [operations] -->
## Available Resources and Operations

<details open>
<summary>Available methods</summary>

### [Artifacts](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md)

* [create_remote_source](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#create_remote_source) - Configure a new remote source
* [get_blob](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#get_blob) - Get blob for a particular digest
* [get_manifest](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#get_manifest) - Get manifest for a particular reference
* [get_namespaces](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#get_namespaces) - Each namespace contains many revisions.
* [get_revisions](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#get_revisions)
* [get_tags](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#get_tags)
* [list_remote_sources](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#list_remote_sources) - Get remote sources attached to a particular namespace
* [post_tags](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#post_tags) - Add tags to an existing revision
* [preflight](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#preflight) - Get access token for communicating with OCI distribution endpoints
* [set_archived](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#set_archived) - Set whether a namespace is archived
* [set_visibility](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/artifacts/README.md#set_visibility) - Set visibility of a namespace with an existing metadata entry

### [Auth](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/auth/README.md)

* [get_access](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/auth/README.md#get_access) - Get access allowances for a particular workspace
* [get_access_token](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/auth/README.md#get_access_token) - Get or refresh an access token for the current workspace.
* [get_user](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/auth/README.md#get_user) - Get information about the current user.
* [validate_api_key](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/auth/README.md#validate_api_key) - Validate the current api key.

### [CodeSamples](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/codesamples/README.md)

* [generate_code_sample_preview](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/codesamples/README.md#generate_code_sample_preview) - Generate Code Sample previews from a file and configuration parameters.
* [generate_code_sample_preview_asynchronous](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/codesamples/README.md#generate_code_sample_preview_asynchronous) - Initiate asynchronous Code Sample preview generation from a file and configuration parameters, receiving an async JobID response for polling.
* [get](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/codesamples/README.md#get) - Retrieve usage snippets
* [get_code_sample_preview_async](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/codesamples/README.md#get_code_sample_preview_async) - Poll for the result of an asynchronous Code Sample preview generation.

### [Events](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/events/README.md)

* [get_events_by_target](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/events/README.md#get_events_by_target) - Load recent events for a particular workspace
* [get_targets](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/events/README.md#get_targets) - Load targets for a particular workspace
* [get_targets_deprecated](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/events/README.md#get_targets_deprecated) - Load targets for a particular workspace
* [post](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/events/README.md#post) - Post events for a specific workspace
* [search](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/events/README.md#search) - Search events for a particular workspace by any field

### [Github](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md)

* [check_access](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#check_access)
* [check_publishing_p_rs](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#check_publishing_p_rs)
* [check_publishing_secrets](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#check_publishing_secrets)
* [configure_code_samples](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#configure_code_samples)
* [configure_mintlify_repo](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#configure_mintlify_repo)
* [configure_target](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#configure_target)
* [get_action](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#get_action)
* [get_setup](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#get_setup)
* [link_github](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#link_github)
* [store_publishing_secrets](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#store_publishing_secrets)
* [trigger_action](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/github/README.md#trigger_action)

### [Organizations](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md)

* [create](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#create) - Create an organization
* [create_billing_add_ons](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#create_billing_add_ons) - Create billing add ons
* [create_free_trial](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#create_free_trial) - Create a free trial for an organization
* [delete_billing_add_on](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#delete_billing_add_on) - Delete billing add ons
* [get](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#get) - Get organization
* [get_all](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#get_all) - Get organizations for a user
* [get_billing_add_ons](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#get_billing_add_ons) - Get billing add ons
* [get_usage](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/organizations/README.md#get_usage) - Get billing usage summary for a particular organization

### [PublishingTokens](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md)

* [create](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md#create) - Create a publishing token for a workspace
* [delete](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md#delete) - Delete a specific publishing token
* [get](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md#get) - Get a specific publishing token
* [list](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md#list) - Get publishing tokens for a workspace
* [resolve_metadata](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md#resolve_metadata) - Get metadata about the token
* [resolve_target](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md#resolve_target) - Get a specific publishing token target
* [update](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/publishingtokens/README.md#update) - Updates the validitity period of a publishing token

### [Reports](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/reports/README.md)

* [get_changes_report_signed_url](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/reports/README.md#get_changes_report_signed_url) - Get the signed access url for the change reports for a particular document.
* [get_linting_report_signed_url](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/reports/README.md#get_linting_report_signed_url) - Get the signed access url for the linting reports for a particular document.
* [upload_report](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/reports/README.md#upload_report) - Upload a report.

### [SchemaStore](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/schemastore/README.md)

* [create_schema_store_item](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/schemastore/README.md#create_schema_store_item) - Create a schema in the schema store
* [get_schema_store_item](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/schemastore/README.md#get_schema_store_item) - Get a OAS schema from the schema store

### [ShortURLs](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/shorturls/README.md)

* [create](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/shorturls/README.md#create) - Shorten a URL.

### [Subscriptions](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/subscriptions/README.md)

* [activate_subscription_namespace](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/subscriptions/README.md#activate_subscription_namespace) - Activate an ignored namespace for a subscription
* [ignore_subscription_namespace](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/subscriptions/README.md#ignore_subscription_namespace) - Ignored a namespace for a subscription

### [Suggest](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/suggest/README.md)

* [suggest](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/suggest/README.md#suggest) - Generate suggestions for improving an OpenAPI document.
* [suggest_items](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/suggest/README.md#suggest_items) - Generate generic suggestions for a list of items.
* [suggest_open_api](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/suggest/README.md#suggest_open_api) - (DEPRECATED) Generate suggestions for improving an OpenAPI document.
* [suggest_open_api_registry](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/suggest/README.md#suggest_open_api_registry) - Generate suggestions for improving an OpenAPI document stored in the registry.

### [Workspaces](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md)

* [create](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#create) - Create a workspace
* [create_token](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#create_token) - Create a token for a particular workspace
* [delete_token](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#delete_token) - Delete a token for a particular workspace
* [get](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#get) - Get workspace by context
* [get_all](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#get_all) - Get workspaces for a user
* [get_by_id](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#get_by_id) - Get workspace
* [get_feature_flags](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#get_feature_flags) - Get workspace feature flags
* [get_settings](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#get_settings) - Get workspace settings
* [get_team](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#get_team) - Get team members for a particular workspace
* [get_tokens](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#get_tokens) - Get tokens for a particular workspace
* [grant_access](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#grant_access) - Grant a user access to a particular workspace
* [revoke_access](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#revoke_access) - Revoke a user's access to a particular workspace
* [set_feature_flags](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#set_feature_flags) - Set workspace feature flags
* [update](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#update) - Update workspace details
* [update_settings](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./docs/sdks/workspaces/README.md#update_settings) - Update workspace settings

</details>
<!-- End Available Resources and Operations [operations] -->

<!-- Start Global Parameters [global-parameters] -->
## Global Parameters

A parameter is configured globally. This parameter may be set on the SDK client instance itself during initialization. When configured as an option during SDK initialization, This global value will be used as the default on the operations that use it. When such operations are called, there is a place in each to override the global value, if needed.

For example, you can set `workspace_id` to `"<id>"` at SDK initialization and then you do not have to pass the same value on calls to operations like `get_access_token`. But if you want to do so you may, which will locally override the global setting. See the example code below for a demonstration.


### Available Globals

The following global parameter is available.

| Name         | Type | Description                 |
| ------------ | ---- | --------------------------- |
| workspace_id | str  | The workspace_id parameter. |

### Example

```python
from speakeasy_client_sdk_python import Speakeasy


with Speakeasy(
    workspace_id="<id>",
) as speakeasy:

    res = speakeasy.auth.get_access_token(request={
        "workspace_id": "<id>",
    })

    assert res.access_token is not None

    # Handle response
    print(res.access_token)

```
<!-- End Global Parameters [global-parameters] -->

<!-- Start File uploads [file-upload] -->
## File uploads

Certain SDK methods accept file objects as part of a request body or multi-part request. It is possible and typically recommended to upload files as a stream rather than reading the entire contents into memory. This avoids excessive memory consumption and potentially crashing with out-of-memory errors when working with very large files. The following example demonstrates how to attach a file stream to a request.

> [!TIP]
>
> For endpoints that handle file uploads bytes arrays can also be used. However, using streams is recommended for large files.
>

```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared


with Speakeasy(
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:

    res = speakeasy.code_samples.generate_code_sample_preview(request={
        "language": "<value>",
        "schema_file": {
            "content": open("example.file", "rb"),
            "file_name": "example.file",
        },
    })

    assert res.usage_snippets is not None

    # Handle response
    print(res.usage_snippets)

```
<!-- End File uploads [file-upload] -->

<!-- Start Retries [retries] -->
## Retries

Some of the endpoints in this SDK support retries. If you use the SDK without any configuration, it will fall back to the default retry strategy provided by the API. However, the default retry strategy can be overridden on a per-operation basis, or across the entire SDK.

To change the default retry strategy for a single API call, simply provide a `RetryConfig` object to the call:
```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared
from speakeasy_client_sdk_python.utils import BackoffStrategy, RetryConfig


with Speakeasy(
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:

    res = speakeasy.artifacts.create_remote_source(,
        RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False))

    assert res is not None

    # Handle response
    print(res)

```

If you'd like to override the default retry strategy for all operations that support retries, you can use the `retry_config` optional parameter when initializing the SDK:
```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared
from speakeasy_client_sdk_python.utils import BackoffStrategy, RetryConfig


with Speakeasy(
    retry_config=RetryConfig("backoff", BackoffStrategy(1, 50, 1.1, 100), False),
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:

    res = speakeasy.artifacts.create_remote_source()

    assert res is not None

    # Handle response
    print(res)

```
<!-- End Retries [retries] -->

<!-- Start Error Handling [errors] -->
## Error Handling

[`SpeakeasyError`](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/././src/speakeasy_client_sdk_python/models/errors/speakeasyerror.py) is the base class for all HTTP error responses. It has the following properties:

| Property           | Type             | Description                                                                             |
| ------------------ | ---------------- | --------------------------------------------------------------------------------------- |
| `err.message`      | `str`            | Error message                                                                           |
| `err.status_code`  | `int`            | HTTP response status code eg `404`                                                      |
| `err.headers`      | `httpx.Headers`  | HTTP response headers                                                                   |
| `err.body`         | `str`            | HTTP body. Can be empty string if no body is returned.                                  |
| `err.raw_response` | `httpx.Response` | Raw HTTP response                                                                       |
| `err.data`         |                  | Optional. Some errors may contain structured data. [See Error Classes](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#error-classes). |

### Example
```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import errors, shared


with Speakeasy(
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:
    res = None
    try:

        res = speakeasy.artifacts.create_remote_source()

        assert res is not None

        # Handle response
        print(res)


    except errors.SpeakeasyError as e:
        # The base class for HTTP error responses
        print(e.message)
        print(e.status_code)
        print(e.body)
        print(e.headers)
        print(e.raw_response)

        # Depending on the method different errors may be thrown
        if isinstance(e, errors.Error):
            print(e.data.message)  # str
            print(e.data.status_code)  # int
```

### Error Classes
**Primary errors:**
* [`SpeakeasyError`](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/././src/speakeasy_client_sdk_python/models/errors/speakeasyerror.py): The base class for HTTP error responses.
  * [`Error`](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/././src/speakeasy_client_sdk_python/models/errors/error.py): The `Status` type defines a logical error model. *

<details><summary>Less common errors (5)</summary>

<br />

**Network errors:**
* [`httpx.RequestError`](https://www.python-httpx.org/exceptions/#httpx.RequestError): Base class for request errors.
    * [`httpx.ConnectError`](https://www.python-httpx.org/exceptions/#httpx.ConnectError): HTTP client was unable to make a request to a server.
    * [`httpx.TimeoutException`](https://www.python-httpx.org/exceptions/#httpx.TimeoutException): HTTP request timed out.


**Inherit from [`SpeakeasyError`](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/././src/speakeasy_client_sdk_python/models/errors/speakeasyerror.py)**:
* [`ResponseValidationError`](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/././src/speakeasy_client_sdk_python/models/errors/responsevalidationerror.py): Type mismatch between the response data and the expected Pydantic model. Provides access to the Pydantic validation error via the `cause` attribute.

</details>

\* Check [the method documentation](https://github.com/speakeasy-api/speakeasy-client-sdk-python/blob/master/./#available-resources-and-operations) to see if the error is applicable.
<!-- End Error Handling [errors] -->

<!-- Start Server Selection [server] -->
## Server Selection

### Select Server by Name

You can override the default server globally by passing a server name to the `server: str` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the names associated with the available servers:

| Name   | Server                           | Description |
| ------ | -------------------------------- | ----------- |
| `prod` | `https://api.prod.speakeasy.com` |             |

#### Example

```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared


with Speakeasy(
    server="prod",
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:

    res = speakeasy.artifacts.create_remote_source()

    assert res is not None

    # Handle response
    print(res)

```

### Override Server URL Per-Client

The default server can also be overridden globally by passing a URL to the `server_url: str` optional parameter when initializing the SDK client instance. For example:
```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared


with Speakeasy(
    server_url="https://api.prod.speakeasy.com",
    security=shared.Security(
        api_key="<YOUR_API_KEY_HERE>",
    ),
) as speakeasy:

    res = speakeasy.artifacts.create_remote_source()

    assert res is not None

    # Handle response
    print(res)

```
<!-- End Server Selection [server] -->

<!-- Start Custom HTTP Client [http-client] -->
## Custom HTTP Client

The Python SDK makes API calls using the [httpx](https://www.python-httpx.org/) HTTP library.  In order to provide a convenient way to configure timeouts, cookies, proxies, custom headers, and other low-level configuration, you can initialize the SDK client with your own HTTP client instance.
Depending on whether you are using the sync or async version of the SDK, you can pass an instance of `HttpClient` or `AsyncHttpClient` respectively, which are Protocol's ensuring that the client has the necessary methods to make API calls.
This allows you to wrap the client with your own custom logic, such as adding custom headers, logging, or error handling, or you can just pass an instance of `httpx.Client` or `httpx.AsyncClient` directly.

For example, you could specify a header for every request that this sdk makes as follows:
```python
from speakeasy_client_sdk_python import Speakeasy
import httpx

http_client = httpx.Client(headers={"x-custom-header": "someValue"})
s = Speakeasy(client=http_client)
```

or you could wrap the client with your own custom logic:
```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.httpclient import AsyncHttpClient
import httpx

class CustomClient(AsyncHttpClient):
    client: AsyncHttpClient

    def __init__(self, client: AsyncHttpClient):
        self.client = client

    async def send(
        self,
        request: httpx.Request,
        *,
        stream: bool = False,
        auth: Union[
            httpx._types.AuthTypes, httpx._client.UseClientDefault, None
        ] = httpx.USE_CLIENT_DEFAULT,
        follow_redirects: Union[
            bool, httpx._client.UseClientDefault
        ] = httpx.USE_CLIENT_DEFAULT,
    ) -> httpx.Response:
        request.headers["Client-Level-Header"] = "added by client"

        return await self.client.send(
            request, stream=stream, auth=auth, follow_redirects=follow_redirects
        )

    def build_request(
        self,
        method: str,
        url: httpx._types.URLTypes,
        *,
        content: Optional[httpx._types.RequestContent] = None,
        data: Optional[httpx._types.RequestData] = None,
        files: Optional[httpx._types.RequestFiles] = None,
        json: Optional[Any] = None,
        params: Optional[httpx._types.QueryParamTypes] = None,
        headers: Optional[httpx._types.HeaderTypes] = None,
        cookies: Optional[httpx._types.CookieTypes] = None,
        timeout: Union[
            httpx._types.TimeoutTypes, httpx._client.UseClientDefault
        ] = httpx.USE_CLIENT_DEFAULT,
        extensions: Optional[httpx._types.RequestExtensions] = None,
    ) -> httpx.Request:
        return self.client.build_request(
            method,
            url,
            content=content,
            data=data,
            files=files,
            json=json,
            params=params,
            headers=headers,
            cookies=cookies,
            timeout=timeout,
            extensions=extensions,
        )

s = Speakeasy(async_client=CustomClient(httpx.AsyncClient()))
```
### httpx2 (Pydantic's httpx fork)

[httpx2](https://httpx2.pydantic.dev/) is Pydantic's maintained fork of `httpx`. To run this SDK on httpx2, call `alias_httpx()` at your program's entry point, before importing the SDK, so every `import httpx` — including the ones inside the SDK — resolves to `httpx2`:
```python
import httpx2

httpx2.alias_httpx()

from speakeasy_client_sdk_python import Speakeasy

s = Speakeasy()
```

An SDK can also be generated against httpx2 directly, so it depends on the fork instead of `httpx`, by setting `python.httpClientLibrary: httpx2` in `gen.yaml`.
<!-- End Custom HTTP Client [http-client] -->

<!-- Start Resource Management [resource-management] -->
## Resource Management

The `Speakeasy` class implements the context manager protocol and registers a finalizer function to close the underlying sync and async HTTPX clients it uses under the hood. This will close HTTP connections, release memory and free up other resources held by the SDK. In short-lived Python programs and notebooks that make a few SDK method calls, resource management may not be a concern. However, in longer-lived programs, it is beneficial to create a single SDK instance via a [context manager][context-manager] and reuse it across the application.

[context-manager]: https://docs.python.org/3/reference/datamodel.html#context-managers

```python
from speakeasy_client_sdk_python import Speakeasy
from speakeasy_client_sdk_python.models import shared
def main():

    with Speakeasy(
        security=shared.Security(
            api_key="<YOUR_API_KEY_HERE>",
        ),
    ) as speakeasy:
        # Rest of application here...
        pass


# Or when using async:
async def amain():

    async with Speakeasy(
        security=shared.Security(
            api_key="<YOUR_API_KEY_HERE>",
        ),
    ) as speakeasy:
        # Rest of application here...
        pass
```
<!-- End Resource Management [resource-management] -->

<!-- Start Debugging [debug] -->
## Debugging

You can setup your SDK to emit debug logs for SDK requests and responses.

You can pass your own logger class directly into your SDK.
```python
from speakeasy_client_sdk_python import Speakeasy
import logging

logging.basicConfig(level=logging.DEBUG)
s = Speakeasy(debug_logger=logging.getLogger("speakeasy_client_sdk_python"))
```
<!-- End Debugging [debug] -->

<!-- Placeholder for Future Speakeasy SDK Sections -->

