> ## Documentation Index
> Fetch the complete documentation index at: https://developers.telnyx.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK requests and types

> Typed request params and response models, nested params, and file uploads in the Telnyx Python SDK.

## Using types

Nested request parameters are [TypedDicts](https://docs.python.org/3/library/typing.html#typing.TypedDict). Responses are [Pydantic models](https://docs.pydantic.dev) which also provide helper methods for things like:

* Serializing back into JSON, `model.to_json()`
* Converting to a dictionary, `model.to_dict()`

Typed requests and responses provide autocomplete and documentation within your editor. If you would like to see type errors in VS Code to help catch bugs earlier, set `python.analysis.typeCheckingMode` to `basic`.

## Nested params

Nested parameters are dictionaries, typed using `TypedDict`, for example:

```python theme={null}
from telnyx import Telnyx

client = Telnyx()

response = client.calls.dial(
    connection_id="7267xxxxxxxxxxxxxx",
    from_="+18005550101",
    to="+18005550100 or sip:username@sip.telnyx.com",
    answering_machine_detection_config={
        "after_greeting_silence_millis": 1000,
        "between_words_silence_millis": 1000,
        "greeting_duration_millis": 1000,
        "greeting_silence_duration_millis": 2000,
        "greeting_total_analysis_time_millis": 50000,
        "initial_silence_millis": 1000,
        "maximum_number_of_words": 1000,
        "maximum_word_length_millis": 2000,
        "silence_threshold": 512,
        "total_analysis_time_millis": 5000,
    },
)
print(response.answering_machine_detection_config)
```

## File uploads

Request parameters that correspond to file uploads can be passed as `bytes`, or a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance or a tuple of `(filename, contents, media type)`.

```python theme={null}
from pathlib import Path
from telnyx import Telnyx

client = Telnyx()

client.ai.audio.transcribe(
    model="distil-whisper/distil-large-v2",
    file=Path("/path/to/file"),
)
```

The async client uses the exact same interface. If you pass a [`PathLike`](https://docs.python.org/3/library/os.html#os.PathLike) instance, the file contents will be read asynchronously automatically.
