tapra 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. tapra-0.1.1/.gitignore +64 -0
  2. tapra-0.1.1/PKG-INFO +60 -0
  3. tapra-0.1.1/README.md +44 -0
  4. tapra-0.1.1/pyproject.toml +30 -0
  5. tapra-0.1.1/src/tapra/.fernignore +1 -0
  6. tapra-0.1.1/src/tapra/CONTRIBUTING.md +125 -0
  7. tapra-0.1.1/src/tapra/README.md +205 -0
  8. tapra-0.1.1/src/tapra/__init__.py +214 -0
  9. tapra-0.1.1/src/tapra/_default_clients.py +30 -0
  10. tapra-0.1.1/src/tapra/client.py +331 -0
  11. tapra-0.1.1/src/tapra/core/__init__.py +127 -0
  12. tapra-0.1.1/src/tapra/core/api_error.py +23 -0
  13. tapra-0.1.1/src/tapra/core/client_wrapper.py +142 -0
  14. tapra-0.1.1/src/tapra/core/datetime_utils.py +70 -0
  15. tapra-0.1.1/src/tapra/core/file.py +67 -0
  16. tapra-0.1.1/src/tapra/core/force_multipart.py +18 -0
  17. tapra-0.1.1/src/tapra/core/http_client.py +965 -0
  18. tapra-0.1.1/src/tapra/core/http_response.py +63 -0
  19. tapra-0.1.1/src/tapra/core/http_sse/__init__.py +42 -0
  20. tapra-0.1.1/src/tapra/core/http_sse/_api.py +455 -0
  21. tapra-0.1.1/src/tapra/core/http_sse/_decoders.py +74 -0
  22. tapra-0.1.1/src/tapra/core/http_sse/_exceptions.py +7 -0
  23. tapra-0.1.1/src/tapra/core/http_sse/_models.py +17 -0
  24. tapra-0.1.1/src/tapra/core/jsonable_encoder.py +133 -0
  25. tapra-0.1.1/src/tapra/core/logging.py +107 -0
  26. tapra-0.1.1/src/tapra/core/parse_error.py +36 -0
  27. tapra-0.1.1/src/tapra/core/pydantic_utilities.py +486 -0
  28. tapra-0.1.1/src/tapra/core/query_encoder.py +58 -0
  29. tapra-0.1.1/src/tapra/core/remove_none_from_dict.py +11 -0
  30. tapra-0.1.1/src/tapra/core/request_options.py +40 -0
  31. tapra-0.1.1/src/tapra/core/serialization.py +347 -0
  32. tapra-0.1.1/src/tapra/diarization/__init__.py +4 -0
  33. tapra-0.1.1/src/tapra/diarization/client.py +128 -0
  34. tapra-0.1.1/src/tapra/diarization/raw_client.py +328 -0
  35. tapra-0.1.1/src/tapra/environment.py +7 -0
  36. tapra-0.1.1/src/tapra/errors/__init__.py +59 -0
  37. tapra-0.1.1/src/tapra/errors/bad_request_error.py +11 -0
  38. tapra-0.1.1/src/tapra/errors/content_too_large_error.py +11 -0
  39. tapra-0.1.1/src/tapra/errors/forbidden_error.py +11 -0
  40. tapra-0.1.1/src/tapra/errors/internal_server_error.py +11 -0
  41. tapra-0.1.1/src/tapra/errors/payment_required_error.py +11 -0
  42. tapra-0.1.1/src/tapra/errors/service_unavailable_error.py +11 -0
  43. tapra-0.1.1/src/tapra/errors/too_many_requests_error.py +11 -0
  44. tapra-0.1.1/src/tapra/errors/unauthorized_error.py +11 -0
  45. tapra-0.1.1/src/tapra/models/__init__.py +4 -0
  46. tapra-0.1.1/src/tapra/models/client.py +96 -0
  47. tapra-0.1.1/src/tapra/models/raw_client.py +95 -0
  48. tapra-0.1.1/src/tapra/realtime.py +295 -0
  49. tapra-0.1.1/src/tapra/reference.md +811 -0
  50. tapra-0.1.1/src/tapra/script/__init__.py +34 -0
  51. tapra-0.1.1/src/tapra/script/client.py +138 -0
  52. tapra-0.1.1/src/tapra/script/raw_client.py +330 -0
  53. tapra-0.1.1/src/tapra/script/types/__init__.py +34 -0
  54. tapra-0.1.1/src/tapra/script/types/conversion_request_direction.py +5 -0
  55. tapra-0.1.1/src/tapra/speech/__init__.py +49 -0
  56. tapra-0.1.1/src/tapra/speech/client.py +274 -0
  57. tapra-0.1.1/src/tapra/speech/raw_client.py +466 -0
  58. tapra-0.1.1/src/tapra/speech/types/__init__.py +47 -0
  59. tapra-0.1.1/src/tapra/speech/types/create_speech_request_engine.py +5 -0
  60. tapra-0.1.1/src/tapra/speech/types/create_speech_request_pronunciation_mode.py +5 -0
  61. tapra-0.1.1/src/tapra/speech/types/create_speech_request_pronunciation_style.py +5 -0
  62. tapra-0.1.1/src/tapra/speech/types/create_speech_request_response_format.py +5 -0
  63. tapra-0.1.1/src/tapra/transcriptions/__init__.py +34 -0
  64. tapra-0.1.1/src/tapra/transcriptions/client.py +203 -0
  65. tapra-0.1.1/src/tapra/transcriptions/raw_client.py +399 -0
  66. tapra-0.1.1/src/tapra/transcriptions/types/__init__.py +36 -0
  67. tapra-0.1.1/src/tapra/transcriptions/types/create_transcriptions_request_timestamps.py +5 -0
  68. tapra-0.1.1/src/tapra/translations/__init__.py +37 -0
  69. tapra-0.1.1/src/tapra/translations/client.py +386 -0
  70. tapra-0.1.1/src/tapra/translations/raw_client.py +875 -0
  71. tapra-0.1.1/src/tapra/translations/types/__init__.py +38 -0
  72. tapra-0.1.1/src/tapra/translations/types/create_translations_request_direction.py +5 -0
  73. tapra-0.1.1/src/tapra/translations/types/create_translations_stream_request_direction.py +5 -0
  74. tapra-0.1.1/src/tapra/types/__init__.py +128 -0
  75. tapra-0.1.1/src/tapra/types/conversion.py +26 -0
  76. tapra-0.1.1/src/tapra/types/conversion_direction.py +5 -0
  77. tapra-0.1.1/src/tapra/types/diarization.py +30 -0
  78. tapra-0.1.1/src/tapra/types/error.py +24 -0
  79. tapra-0.1.1/src/tapra/types/error_object.py +21 -0
  80. tapra-0.1.1/src/tapra/types/error_object_type.py +18 -0
  81. tapra-0.1.1/src/tapra/types/model.py +23 -0
  82. tapra-0.1.1/src/tapra/types/model_list.py +22 -0
  83. tapra-0.1.1/src/tapra/types/model_list_object.py +5 -0
  84. tapra-0.1.1/src/tapra/types/model_object.py +5 -0
  85. tapra-0.1.1/src/tapra/types/model_owned_by.py +5 -0
  86. tapra-0.1.1/src/tapra/types/realtime_client_message.py +24 -0
  87. tapra-0.1.1/src/tapra/types/realtime_client_message_type.py +5 -0
  88. tapra-0.1.1/src/tapra/types/realtime_event.py +64 -0
  89. tapra-0.1.1/src/tapra/types/realtime_event_type.py +5 -0
  90. tapra-0.1.1/src/tapra/types/segment.py +30 -0
  91. tapra-0.1.1/src/tapra/types/speaker.py +23 -0
  92. tapra-0.1.1/src/tapra/types/speaker_turn.py +21 -0
  93. tapra-0.1.1/src/tapra/types/speech.py +37 -0
  94. tapra-0.1.1/src/tapra/types/speech_audio_format.py +5 -0
  95. tapra-0.1.1/src/tapra/types/transcription.py +47 -0
  96. tapra-0.1.1/src/tapra/types/translation.py +30 -0
  97. tapra-0.1.1/src/tapra/types/translation_language.py +22 -0
  98. tapra-0.1.1/src/tapra/types/translation_language_list.py +23 -0
  99. tapra-0.1.1/src/tapra/types/translation_language_list_object.py +5 -0
  100. tapra-0.1.1/src/tapra/types/translation_request.py +41 -0
  101. tapra-0.1.1/src/tapra/types/translation_request_direction.py +5 -0
  102. tapra-0.1.1/src/tapra/types/translation_stream_event.py +26 -0
  103. tapra-0.1.1/src/tapra/types/translation_stream_event_type.py +5 -0
  104. tapra-0.1.1/src/tapra/types/usage.py +28 -0
  105. tapra-0.1.1/src/tapra/types/word.py +34 -0
tapra-0.1.1/.gitignore ADDED
@@ -0,0 +1,64 @@
1
+ # See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2
+
3
+ # dependencies
4
+ /node_modules
5
+ /.pnp
6
+ .pnp.js
7
+ package-lock.json
8
+ yarn.lock
9
+ pnpm-lock.yaml
10
+
11
+ # testing
12
+ /coverage
13
+
14
+ # next.js
15
+ /.next/
16
+ /out/
17
+
18
+ # production
19
+ /build
20
+
21
+ # misc
22
+ .DS_Store
23
+ *.pem
24
+
25
+ # debug
26
+ npm-debug.log*
27
+ yarn-debug.log*
28
+ yarn-error.log*
29
+
30
+ # local env files
31
+ .env*
32
+ .env*.local
33
+
34
+ # vercel
35
+ .vercel
36
+
37
+ # typescript
38
+ *.tsbuildinfo
39
+ next-env.d.ts
40
+
41
+ .idea/
42
+ # clerk configuration (can include secrets)
43
+ /.clerk/
44
+
45
+ # agent tooling
46
+ .agents/
47
+ skills-lock.json
48
+
49
+ # cursor
50
+ .cursorrules
51
+ /memory-bank
52
+
53
+ # Sentry Config File
54
+ .env.sentry-build-plugin
55
+
56
+ # Fern scratch output (fern write-definition)
57
+ fern/.definition
58
+ # Fern generation metadata embeds the source commit, so it never matches
59
+ sdks/**/.fern/
60
+ # SDK build and test artifacts
61
+ sdks/**/node_modules/
62
+ sdks/**/dist/
63
+ sdks/**/__pycache__/
64
+ sdks/**/*.egg-info/
tapra-0.1.1/PKG-INFO ADDED
@@ -0,0 +1,60 @@
1
+ Metadata-Version: 2.5
2
+ Name: tapra
3
+ Version: 0.1.1
4
+ Summary: Official Python SDK for the Tapra API: Tunisian code-switching transcription, speech, translation, and script conversion.
5
+ License: Proprietary
6
+ Requires-Python: >=3.10
7
+ Requires-Dist: httpx>=0.21.2
8
+ Requires-Dist: pydantic>=1.9.2
9
+ Requires-Dist: typing-extensions>=4.0.0
10
+ Provides-Extra: aiohttp
11
+ Requires-Dist: aiohttp<4,>=3.10.0; extra == 'aiohttp'
12
+ Requires-Dist: httpx-aiohttp>=0.1.8; extra == 'aiohttp'
13
+ Provides-Extra: realtime
14
+ Requires-Dist: websockets>=13; extra == 'realtime'
15
+ Description-Content-Type: text/markdown
16
+
17
+ # Tapra Python SDK
18
+
19
+ Official Python client for the Tapra API: Tunisian Arabic / French / English code-switching
20
+ transcription, speech, translation, and Arabizi ↔ Arabic conversion.
21
+
22
+ ```bash
23
+ pip install "tapra[realtime]" # drop [realtime] if you only use the REST endpoints
24
+ ```
25
+
26
+ ```python
27
+ from tapra import Tapra
28
+
29
+ client = Tapra(base_url="https://api.example.com") # api_key defaults to TAPRA_API_KEY
30
+
31
+ with open("meeting.m4a", "rb") as audio:
32
+ transcript = client.transcriptions.create(file=audio, timestamps="word")
33
+ print(transcript.text)
34
+
35
+ client.script.convert(text="3lech 7abit l9anoun?", direction="ZI2AR")
36
+ for event in client.translations.create_stream(input="عندي برشا خدمة", target="French"):
37
+ print(event.type, event.delta)
38
+ ```
39
+
40
+ Async: `AsyncTapra` has the same methods. Errors raise typed exceptions
41
+ (`PaymentRequiredError` for HTTP 402, `UnauthorizedError`, …) whose `.body.error` holds
42
+ `type` and `message`. Pass `idempotency_key=` to retry metered requests safely, and use
43
+ `client.<resource>.with_raw_response.<method>()` to read `x-tapra-cost-tnd`.
44
+
45
+ ## Realtime transcription
46
+
47
+ ```python
48
+ from tapra import connect_realtime
49
+
50
+ async with connect_realtime(base_url="https://api.example.com", language="ar-AR") as session:
51
+ for chunk in pcm_chunks: # mono pcm_s16le, 16 kHz
52
+ await session.send_audio(chunk)
53
+ final = await session.stop()
54
+ print(final.text, final.usage)
55
+ ```
56
+
57
+ ## Development
58
+
59
+ `src/tapra/` is generated by Fern from `openapi/tapra-api.json`; do not edit it by hand.
60
+ `src/tapra/realtime.py` is hand-written (kept by `.fernignore`). Tests: `sdks/tests/python`.
tapra-0.1.1/README.md ADDED
@@ -0,0 +1,44 @@
1
+ # Tapra Python SDK
2
+
3
+ Official Python client for the Tapra API: Tunisian Arabic / French / English code-switching
4
+ transcription, speech, translation, and Arabizi ↔ Arabic conversion.
5
+
6
+ ```bash
7
+ pip install "tapra[realtime]" # drop [realtime] if you only use the REST endpoints
8
+ ```
9
+
10
+ ```python
11
+ from tapra import Tapra
12
+
13
+ client = Tapra(base_url="https://api.example.com") # api_key defaults to TAPRA_API_KEY
14
+
15
+ with open("meeting.m4a", "rb") as audio:
16
+ transcript = client.transcriptions.create(file=audio, timestamps="word")
17
+ print(transcript.text)
18
+
19
+ client.script.convert(text="3lech 7abit l9anoun?", direction="ZI2AR")
20
+ for event in client.translations.create_stream(input="عندي برشا خدمة", target="French"):
21
+ print(event.type, event.delta)
22
+ ```
23
+
24
+ Async: `AsyncTapra` has the same methods. Errors raise typed exceptions
25
+ (`PaymentRequiredError` for HTTP 402, `UnauthorizedError`, …) whose `.body.error` holds
26
+ `type` and `message`. Pass `idempotency_key=` to retry metered requests safely, and use
27
+ `client.<resource>.with_raw_response.<method>()` to read `x-tapra-cost-tnd`.
28
+
29
+ ## Realtime transcription
30
+
31
+ ```python
32
+ from tapra import connect_realtime
33
+
34
+ async with connect_realtime(base_url="https://api.example.com", language="ar-AR") as session:
35
+ for chunk in pcm_chunks: # mono pcm_s16le, 16 kHz
36
+ await session.send_audio(chunk)
37
+ final = await session.stop()
38
+ print(final.text, final.usage)
39
+ ```
40
+
41
+ ## Development
42
+
43
+ `src/tapra/` is generated by Fern from `openapi/tapra-api.json`; do not edit it by hand.
44
+ `src/tapra/realtime.py` is hand-written (kept by `.fernignore`). Tests: `sdks/tests/python`.
@@ -0,0 +1,30 @@
1
+ # Package wrapper for the Fern-generated client in src/tapra (never edit generated files;
2
+ # src/tapra/realtime.py is hand-written and kept by src/tapra/.fernignore).
3
+ [build-system]
4
+ requires = ["hatchling>=1.25"]
5
+ build-backend = "hatchling.build"
6
+
7
+ [project]
8
+ name = "tapra"
9
+ version = "0.1.1"
10
+ description = "Official Python SDK for the Tapra API: Tunisian code-switching transcription, speech, translation, and script conversion."
11
+ readme = "README.md"
12
+ requires-python = ">=3.10"
13
+ license = { text = "Proprietary" }
14
+ dependencies = [
15
+ "httpx>=0.21.2",
16
+ "pydantic>=1.9.2",
17
+ "typing_extensions>=4.0.0",
18
+ ]
19
+
20
+ [project.optional-dependencies]
21
+ realtime = ["websockets>=13"]
22
+ aiohttp = ["aiohttp>=3.10.0,<4", "httpx-aiohttp>=0.1.8"]
23
+
24
+ [tool.hatch.build.targets.wheel]
25
+ packages = ["src/tapra"]
26
+ exclude = ["src/tapra/tests", "src/tapra/*.md"]
27
+
28
+ [tool.hatch.build.targets.sdist]
29
+ include = ["src/tapra", "README.md"]
30
+ exclude = ["src/tapra/tests"]
@@ -0,0 +1 @@
1
+ realtime.py
@@ -0,0 +1,125 @@
1
+ # Contributing
2
+
3
+ Thanks for your interest in contributing to this SDK! This document provides guidelines for contributing to the project.
4
+
5
+ ## Getting Started
6
+
7
+ ### Prerequisites
8
+
9
+ - Python 3.9+
10
+ - pip
11
+ - poetry
12
+
13
+ ### Installation
14
+
15
+ Install the project dependencies:
16
+
17
+ ```bash
18
+ poetry install
19
+ ```
20
+
21
+ ### Building
22
+
23
+ Build the project:
24
+
25
+ ```bash
26
+ poetry build
27
+ ```
28
+
29
+ ### Testing
30
+
31
+ Run the test suite:
32
+
33
+ ```bash
34
+ poetry run pytest
35
+ ```
36
+
37
+ ### Linting and Formatting
38
+
39
+ Check code style:
40
+
41
+ ```bash
42
+ poetry run ruff check .
43
+ poetry run ruff format .
44
+ ```
45
+
46
+ ### Type Checking
47
+
48
+ Run the type checker:
49
+
50
+ ```bash
51
+ poetry run mypy .
52
+ ```
53
+
54
+ ## About Generated Code
55
+
56
+ **Important**: Most files in this SDK are automatically generated by [Fern](https://buildwithfern.com) from the API definition. Direct modifications to generated files will be overwritten the next time the SDK is generated.
57
+
58
+ ### Generated Files
59
+
60
+ The following directories contain generated code:
61
+ - `src/` - API client classes and types
62
+ - Most Python files in the project
63
+
64
+ ### How to Customize
65
+
66
+ If you need to customize the SDK, you have two options:
67
+
68
+ #### Option 1: Use `.fernignore`
69
+
70
+ For custom code that should persist across SDK regenerations:
71
+
72
+ 1. Create a `.fernignore` file in the project root
73
+ 2. Add file patterns for files you want to preserve (similar to `.gitignore` syntax)
74
+ 3. Add your custom code to those files
75
+
76
+ Files listed in `.fernignore` will not be overwritten when the SDK is regenerated.
77
+
78
+ For more information, see the [Fern documentation on custom code](https://buildwithfern.com/learn/sdks/overview/custom-code).
79
+
80
+ #### Option 2: Contribute to the Generator
81
+
82
+ If you want to change how code is generated for all users of this SDK:
83
+
84
+ 1. The Python SDK generator lives in the [Fern repository](https://github.com/fern-api/fern)
85
+ 2. Generator code is located at `generators/python-v2/`
86
+ 3. Follow the [Fern contributing guidelines](https://github.com/fern-api/fern/blob/main/CONTRIBUTING.md)
87
+ 4. Submit a pull request with your changes to the generator
88
+
89
+ This approach is best for:
90
+ - Bug fixes in generated code
91
+ - New features that would benefit all users
92
+ - Improvements to code generation patterns
93
+
94
+ ## Making Changes
95
+
96
+ ### Workflow
97
+
98
+ 1. Create a new branch for your changes
99
+ 2. Make your modifications
100
+ 3. Run tests to ensure nothing breaks: `poetry run pytest`
101
+ 4. Run linting and formatting: `poetry run ruff check .` and `poetry run ruff format .`
102
+ 5. Run type checking: `poetry run mypy .`
103
+ 6. Build the project: `poetry build`
104
+ 7. Commit your changes with a clear commit message
105
+ 8. Push your branch and create a pull request
106
+
107
+ ### Commit Messages
108
+
109
+ Write clear, descriptive commit messages that explain what changed and why.
110
+
111
+ ### Code Style
112
+
113
+ This project uses automated code formatting and linting. Run `poetry run ruff format .` and `poetry run ruff check .` before committing to ensure your code meets the project's style guidelines.
114
+
115
+ ## Questions or Issues?
116
+
117
+ If you have questions or run into issues:
118
+
119
+ 1. Check the [Fern documentation](https://buildwithfern.com)
120
+ 2. Search existing [GitHub issues](https://github.com/fern-api/fern/issues)
121
+ 3. Open a new issue if your question hasn't been addressed
122
+
123
+ ## License
124
+
125
+ By contributing to this project, you agree that your contributions will be licensed under the same license as the project.
@@ -0,0 +1,205 @@
1
+ # Tapra Python Library
2
+
3
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=Tapra%2FPython)
4
+ [![pypi](https://img.shields.io/pypi/v/tapra)](https://pypi.python.org/pypi/tapra)
5
+
6
+ The Tapra Python library provides convenient access to the Tapra APIs from Python.
7
+
8
+ ## Table of Contents
9
+
10
+ - [Installation](#installation)
11
+ - [Reference](#reference)
12
+ - [Usage](#usage)
13
+ - [Environments](#environments)
14
+ - [Async Client](#async-client)
15
+ - [Exception Handling](#exception-handling)
16
+ - [Streaming](#streaming)
17
+ - [Advanced](#advanced)
18
+ - [Access Raw Response Data](#access-raw-response-data)
19
+ - [Retries](#retries)
20
+ - [Timeouts](#timeouts)
21
+ - [Custom Client](#custom-client)
22
+ - [Contributing](#contributing)
23
+
24
+ ## Installation
25
+
26
+ ```sh
27
+ pip install tapra
28
+ ```
29
+
30
+ ## Reference
31
+
32
+ A full reference for this library is available [here](./reference.md).
33
+
34
+ ## Usage
35
+
36
+ Instantiate and use the client with the following:
37
+
38
+ ```python
39
+ from tapra import Tapra
40
+
41
+ client = Tapra(
42
+ api_key="<token>",
43
+ )
44
+
45
+ client.transcriptions.create(
46
+ file="example_file",
47
+ )
48
+ ```
49
+
50
+ ## Environments
51
+
52
+ This SDK allows you to configure different environments for API requests.
53
+
54
+ ```python
55
+ from tapra import Tapra
56
+ from tapra.environment import TapraEnvironment
57
+
58
+ client = Tapra(
59
+ environment=TapraEnvironment.DEFAULT,
60
+ )
61
+ ```
62
+
63
+ ## Async Client
64
+
65
+ The SDK also exports an `async` client so that you can make non-blocking calls to our API. Note that if you are constructing an Async httpx client class to pass into this client, use `httpx.AsyncClient()` instead of `httpx.Client()` (e.g. for the `httpx_client` parameter of this client).
66
+
67
+ ```python
68
+ import asyncio
69
+
70
+ from tapra import AsyncTapra
71
+
72
+ client = AsyncTapra(
73
+ api_key="<token>",
74
+ )
75
+
76
+
77
+ async def main() -> None:
78
+ await client.transcriptions.create(
79
+ file="example_file",
80
+ )
81
+
82
+
83
+ asyncio.run(main())
84
+ ```
85
+
86
+ ## Exception Handling
87
+
88
+ When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
89
+ will be thrown.
90
+
91
+ ```python
92
+ from tapra.core.api_error import ApiError
93
+
94
+ try:
95
+ client.transcriptions.create(...)
96
+ except ApiError as e:
97
+ print(e.status_code)
98
+ print(e.body)
99
+ ```
100
+
101
+ ## Streaming
102
+
103
+ The SDK supports streaming responses, as well, the response will be a generator that you can loop over.
104
+
105
+ ```python
106
+ from tapra import Tapra
107
+
108
+ client = Tapra(
109
+ api_key="<token>",
110
+ )
111
+
112
+ client.translations.create_stream(
113
+ input="input",
114
+ )
115
+ ```
116
+
117
+ ## Advanced
118
+
119
+ ### Access Raw Response Data
120
+
121
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
122
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
123
+
124
+ ```python
125
+ from tapra import Tapra
126
+
127
+ client = Tapra(...)
128
+ response = client.transcriptions.with_raw_response.create(...)
129
+ print(response.headers) # access the response headers
130
+ print(response.status_code) # access the response status code
131
+ print(response.data) # access the underlying object
132
+ ```
133
+
134
+ ### Retries
135
+
136
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
137
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
138
+ retry limit (default: 2).
139
+
140
+ Which status codes are retried depends on the `retryStatusCodes` generator configuration:
141
+
142
+ **`legacy`** (current default): retries on
143
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
144
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
145
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
146
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
147
+
148
+ **`recommended`**: retries on
149
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
150
+ - [409](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/409) (Conflict)
151
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
152
+ - [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
153
+ - [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
154
+ - [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
155
+
156
+ Use the `max_retries` request option to configure this behavior.
157
+
158
+ ```python
159
+ client.transcriptions.create(..., request_options={
160
+ "max_retries": 1
161
+ })
162
+ ```
163
+
164
+ ### Timeouts
165
+
166
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
167
+
168
+ ```python
169
+ from tapra import Tapra
170
+
171
+ client = Tapra(..., timeout=20.0)
172
+
173
+ # Override timeout for a specific method
174
+ client.transcriptions.create(..., request_options={
175
+ "timeout": 1
176
+ })
177
+ ```
178
+
179
+ ### Custom Client
180
+
181
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
182
+ and transports.
183
+
184
+ ```python
185
+ import httpx
186
+ from tapra import Tapra
187
+
188
+ client = Tapra(
189
+ ...,
190
+ httpx_client=httpx.Client(
191
+ proxy="http://my.test.proxy.example.com",
192
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
193
+ ),
194
+ )
195
+ ```
196
+
197
+ ## Contributing
198
+
199
+ While we value open-source contributions to this SDK, this library is generated programmatically.
200
+ Additions made directly to this library would have to be moved over to our generation code,
201
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
202
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
203
+ an issue first to discuss with us!
204
+
205
+ On the other hand, contributions to the README are always very welcome!