diff --git a/.fern/metadata.json b/.fern/metadata.json index 3d3e1c3..ac9856a 100644 --- a/.fern/metadata.json +++ b/.fern/metadata.json @@ -1,10 +1,10 @@ { "cliVersion": "4.53.1", "generatorName": "fernapi/fern-python-sdk", - "generatorVersion": "4.61.0", + "generatorVersion": "4.64.1", "generatorConfig": { "client_class_name": "RespanClient" }, - "originGitCommit": "6fa5472be849e7dcfbcbdc84a3dec04204755705", - "sdkVersion": "0.0.0-20260401-6fa5472" + "originGitCommit": "99ac007ff3f9ad6ffe0bdbddceb55d90301c1d12", + "sdkVersion": "0.0.0-20260401-99ac007" } \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 11678d9..076e936 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,10 @@ name: ci on: [push] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: false + jobs: compile: runs-on: ubuntu-latest @@ -9,7 +14,7 @@ jobs: - name: Set up python uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: "3.9" - name: Bootstrap poetry run: | curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 @@ -25,7 +30,7 @@ jobs: - name: Set up python uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: "3.9" - name: Bootstrap poetry run: | curl -sSL https://install.python-poetry.org | python - -y --version 1.5.1 diff --git a/README.md b/README.md index e69de29..8e4c008 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,191 @@ +# Respan Python Library + +[![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=https%3A%2F%2Fgithub.com%2Frespanai%2Frespan-python-api) +[![pypi](https://img.shields.io/pypi/v/respan)](https://pypi.python.org/pypi/respan) + +The Respan Python library provides convenient access to the Respan APIs from Python. + +## Table of Contents + +- [Installation](#installation) +- [Reference](#reference) +- [Usage](#usage) +- [Async Client](#async-client) +- [Exception Handling](#exception-handling) +- [Pagination](#pagination) +- [Advanced](#advanced) + - [Access Raw Response Data](#access-raw-response-data) + - [Retries](#retries) + - [Timeouts](#timeouts) + - [Custom Client](#custom-client) +- [Contributing](#contributing) + +## Installation + +```sh +pip install respan +``` + +## Reference + +A full reference for this library is available [here](https://github.com/respanai/respan-python-api/blob/HEAD/./reference.md). + +## Usage + +Instantiate and use the client with the following: + +```python +from respan import RespanClient + +client = RespanClient() + +client.spans.create_span( + authorization="Bearer sk_live_xxxxx", +) +``` + +## Async Client + +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). + +```python +import asyncio + +from respan import AsyncRespanClient + +client = AsyncRespanClient() + + +async def main() -> None: + await client.spans.create_span( + authorization="Bearer sk_live_xxxxx", + ) + + +asyncio.run(main()) +``` + +## Exception Handling + +When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error +will be thrown. + +```python +from respan.core.api_error import ApiError + +try: + client.spans.create_span(...) +except ApiError as e: + print(e.status_code) + print(e.body) +``` + +## Pagination + +Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object. + +```python +from respan import RespanClient +import datetime + +client = RespanClient() + +client.spans.list_spans( + sort_by="-cost", + start_time=datetime.datetime.fromisoformat("2025-01-01T00:00:00+00:00"), + end_time=datetime.datetime.fromisoformat("2025-01-31T23:59:59+00:00"), + environment="production", + include_fields="customer_identifier,model,cost,latency", + authorization="Bearer sk_live_xxxxx", + operator="AND", +) +``` + +```python +# You can also iterate through pages and access the typed response per page +pager = client.spans.list_spans(...) +for page in pager.iter_pages(): + print(page.response) # access the typed response for each page + for item in page: + print(item) +``` + +## Advanced + +### Access Raw Response Data + +The SDK provides access to raw response data, including headers, through the `.with_raw_response` property. +The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes. + +```python +from respan import RespanClient + +client = RespanClient(...) +response = client.spans.with_raw_response.create_span(...) +print(response.headers) # access the response headers +print(response.status_code) # access the response status code +print(response.data) # access the underlying object +``` + +### Retries + +The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long +as the request is deemed retryable and the number of retry attempts has not grown larger than the configured +retry limit (default: 2). + +A request is deemed retryable when any of the following HTTP status codes is returned: + +- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout) +- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests) +- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors) + +Use the `max_retries` request option to configure this behavior. + +```python +client.spans.create_span(..., request_options={ + "max_retries": 1 +}) +``` + +### Timeouts + +The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level. + +```python +from respan import RespanClient + +client = RespanClient(..., timeout=20.0) + +# Override timeout for a specific method +client.spans.create_span(..., request_options={ + "timeout_in_seconds": 1 +}) +``` + +### Custom Client + +You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies +and transports. + +```python +import httpx +from respan import RespanClient + +client = RespanClient( + ..., + httpx_client=httpx.Client( + proxy="http://my.test.proxy.example.com", + transport=httpx.HTTPTransport(local_address="0.0.0.0"), + ), +) +``` + +## Contributing + +While we value open-source contributions to this SDK, this library is generated programmatically. +Additions made directly to this library would have to be moved over to our generation code, +otherwise they would be overwritten upon the next generated release. Feel free to open a PR as +a proof of concept, but know that we will not be able to merge it as-is. We suggest opening +an issue first to discuss with us! + +On the other hand, contributions to the README are always very welcome! diff --git a/reference.md b/reference.md new file mode 100644 index 0000000..1e417ed --- /dev/null +++ b/reference.md @@ -0,0 +1,12881 @@ +# Reference +## Spans +
client.spans.create_span(...) -> CreateSpanResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a span representing a single LLM interaction. Spans are the core data unit in Respan — every LLM call, agent step, or tool invocation is stored as a span. + +Span size limit: 20MB per payload. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.spans.create_span( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**prompt_messages:** `typing.Optional[typing.List[str]]` — Deprecated. Use `input` instead. + +
+
+ +
+
+ +**completion_message:** `typing.Optional[typing.Dict[str, typing.Any]]` — Deprecated. Use `output` instead. + +
+
+ +
+
+ +**input:** `typing.Optional[CreateSpanRequestInput]` — The input to the model. Format depends on `log_type`. + +
+
+ +
+
+ +**output:** `typing.Optional[CreateSpanRequestOutput]` — The output from the model. Format depends on `log_type`. + +
+
+ +
+
+ +**log_type:** `typing.Optional[CreateSpanRequestLogType]` — Type of span. Determines how `input` and `output` are parsed. + +
+
+ +
+
+ +**model:** `typing.Optional[str]` — Model used for the request. + +
+
+ +
+
+ +**usage:** `typing.Optional[typing.Dict[str, typing.Any]]` — Token usage for the request. + +
+
+ +
+
+ +**cost:** `typing.Optional[float]` — Cost in USD. Auto-calculated from model pricing if omitted. + +
+
+ +
+
+ +**latency:** `typing.Optional[float]` — Total request latency in seconds. + +
+
+ +
+
+ +**time_to_first_token:** `typing.Optional[float]` — Time to first token in seconds. + +
+
+ +
+
+ +**tokens_per_second:** `typing.Optional[float]` — Generation speed in tokens per second. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Arbitrary key-value pairs for your reference. + +
+
+ +
+
+ +**customer_identifier:** `typing.Optional[str]` — Identifier for the end user who made this request. + +
+
+ +
+
+ +**customer_params:** `typing.Optional[typing.Dict[str, typing.Any]]` — Extended customer information. + +
+
+ +
+
+ +**thread_identifier:** `typing.Optional[str]` — Conversation thread ID for multi-turn conversations. + +
+
+ +
+
+ +**custom_identifier:** `typing.Optional[str]` — Indexed custom identifier for fast querying. + +
+
+ +
+
+ +**group_identifier:** `typing.Optional[str]` — Groups related spans together. + +
+
+ +
+
+ +**trace_unique_id:** `typing.Optional[str]` — Trace ID to link spans into a trace tree. + +
+
+ +
+
+ +**span_workflow_name:** `typing.Optional[str]` — Name of the parent workflow. + +
+
+ +
+
+ +**span_name:** `typing.Optional[str]` — Name of this span within the workflow. + +
+
+ +
+
+ +**span_parent_id:** `typing.Optional[str]` — Parent span ID. Builds the trace hierarchy. + +
+
+ +
+
+ +**tools:** `typing.Optional[typing.List[str]]` — Tools available to the model (OpenAI function calling format). + +
+
+ +
+
+ +**tool_choice:** `typing.Optional[CreateSpanRequestToolChoice]` — Controls tool selection. `"none"`, `"auto"`, or a specific tool object. + +
+
+ +
+
+ +**response_format:** `typing.Optional[typing.Dict[str, typing.Any]]` — Response format configuration (e.g. JSON mode or structured output). + +
+
+ +
+
+ +**temperature:** `typing.Optional[float]` — Sampling temperature (0-2). Higher = more random. + +
+
+ +
+
+ +**top_p:** `typing.Optional[float]` — Nucleus sampling parameter. + +
+
+ +
+
+ +**frequency_penalty:** `typing.Optional[float]` — Penalizes repeated tokens (-2 to 2). + +
+
+ +
+
+ +**presence_penalty:** `typing.Optional[float]` — Penalizes tokens already present (-2 to 2). + +
+
+ +
+
+ +**max_tokens:** `typing.Optional[int]` — Maximum tokens to generate. + +
+
+ +
+
+ +**stop:** `typing.Optional[typing.List[str]]` — Stop sequences where generation halts. + +
+
+ +
+
+ +**status_code:** `typing.Optional[int]` — HTTP status code of the request. + +
+
+ +
+
+ +**error_message:** `typing.Optional[str]` — Error message if the request failed. + +
+
+ +
+
+ +**warnings:** `typing.Optional[CreateSpanRequestWarnings]` — Warnings from the request. + +
+
+ +
+
+ +**status:** `typing.Optional[CreateSpanRequestStatus]` — Request status. + +
+
+ +
+
+ +**stream:** `typing.Optional[bool]` — Whether the response was streamed. + +
+
+ +
+
+ +**prompt_id:** `typing.Optional[str]` — ID of the Respan prompt template used. + +
+
+ +
+
+ +**prompt_name:** `typing.Optional[str]` — Name of the prompt template. + +
+
+ +
+
+ +**is_custom_prompt:** `typing.Optional[bool]` — Set `true` when using a custom `prompt_id`. + +
+
+ +
+
+ +**timestamp:** `typing.Optional[str]` — ISO 8601 timestamp when the request completed. + +
+
+ +
+
+ +**start_time:** `typing.Optional[str]` — ISO 8601 timestamp when the request started. + +
+
+ +
+
+ +**full_request:** `typing.Optional[typing.Dict[str, typing.Any]]` — Full raw request object for reference. + +
+
+ +
+
+ +**full_response:** `typing.Optional[typing.Dict[str, typing.Any]]` — Full raw response object from the provider. + +
+
+ +
+
+ +**prompt_unit_price:** `typing.Optional[float]` — Custom price per 1M prompt tokens (for self-hosted/fine-tuned models). + +
+
+ +
+
+ +**completion_unit_price:** `typing.Optional[float]` — Custom price per 1M completion tokens (for self-hosted/fine-tuned models). + +
+
+ +
+
+ +**respan_api_controls:** `typing.Optional[typing.Dict[str, typing.Any]]` — Controls for the Respan logging API behavior. + +
+
+ +
+
+ +**positive_feedback:** `typing.Optional[bool]` — User feedback. `true` = positive, `false` = negative. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.spans.list_spans(...) -> ListSpansResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve spans matching the specified filters with pagination. Supports filtering by any span field, URL-based quick filters, and sorting by evaluator scores. See [Filters API Reference](/docs/api-reference/reference/filters-api-reference) for full filter syntax. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +import datetime + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.spans.list_spans( + sort_by="-cost", + start_time=datetime.datetime.fromisoformat("2025-01-01T00:00:00+00:00"), + end_time=datetime.datetime.fromisoformat("2025-01-31T23:59:59+00:00"), + environment="production", + include_fields="customer_identifier,model,cost,latency", + authorization="Bearer sk_live_xxxxx", + operator="AND", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**operator:** `ListSpansRequestOperator` — Logical operator to combine filters. + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — Page number. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — Results per page (max 1000). + +
+
+ +
+
+ +**sort_by:** `typing.Optional[str]` — Field to sort by. Prefix `-` for descending. + +
+
+ +
+
+ +**start_time:** `typing.Optional[datetime.datetime]` — Start of time range (ISO 8601). + +
+
+ +
+
+ +**end_time:** `typing.Optional[datetime.datetime]` — End of time range (ISO 8601). + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Filter by environment. + +
+
+ +
+
+ +**is_test:** `typing.Optional[ListSpansRequestIsTest]` — Filter by test/production spans. + +
+
+ +
+
+ +**all_envs:** `typing.Optional[ListSpansRequestAllEnvs]` — Include spans from all environments. + +
+
+ +
+
+ +**fetch_filters:** `typing.Optional[ListSpansRequestFetchFilters]` — Return available filter options in the response. May slow response. + +
+
+ +
+
+ +**include_fields:** `typing.Optional[str]` — Comma-separated list of fields to include in each span. Reduces response size. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.spans.retrieve_span(...) -> RetrieveSpanResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a span by its unique ID. Returns the full span including input, output, metrics, metadata, trace context, evaluation scores, and credit/budget info (`limit_info`). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.spans.retrieve_span( + unique_id="unique_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**unique_id:** `str` — The unique ID of the log to get. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.spans.patch_log_span(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update mutable fields of a span. Supports pinning for infinite retention, user feedback, text annotations, and metadata (merged with existing metadata). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.spans.patch_log_span( + unique_id="unique_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**unique_id:** `str` — The unique identifier of the span + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**is_pinned:** `typing.Optional[bool]` — Pin the span for infinite retention. + +
+
+ +
+
+ +**positive_feedback:** `typing.Optional[bool]` — User feedback. `true` = positive, `false` = negative, `null` = clear. + +
+
+ +
+
+ +**note:** `typing.Optional[str]` — Free-text annotation on the span. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Metadata to merge into existing span metadata. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.spans.get_spans_summary(...) -> GetSpansSummaryResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get aggregated statistics for spans matching the given filters. Uses the same filters and query parameters as [List spans](/docs/api-reference/observe/logs/list-spans). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +import datetime + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.spans.get_spans_summary( + start_time=datetime.datetime.fromisoformat("2025-01-01T00:00:00+00:00"), + end_time=datetime.datetime.fromisoformat("2025-01-31T23:59:59+00:00"), + environment="production", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**start_time:** `typing.Optional[datetime.datetime]` — Start of time range (ISO 8601). + +
+
+ +
+
+ +**end_time:** `typing.Optional[datetime.datetime]` — End of time range (ISO 8601). + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Filter by environment. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.spans.ingest_spans_from_traces(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Ingest an array of spans as a trace. Each span uses the same fields as [Create span](/docs/api-reference/observe/logs/create-span), plus `span_unique_id` to identify each span within the trace. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +from respan.spans import IngestSpansFromTracesRequestBodyItem + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.spans.ingest_spans_from_traces( + authorization="Bearer sk_live_xxxxx", + request=[ + IngestSpansFromTracesRequestBodyItem( + trace_unique_id="trace_abc123", + span_unique_id="span_xyz789", + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request:** `typing.List[IngestSpansFromTracesRequestBodyItem]` — Array of span objects to ingest as a trace. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Traces +
client.traces.ingest_traces_via_otlp(...) -> IngestTracesViaOtlpResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Send traces using the standard [OTLP/HTTP](https://opentelemetry.io/docs/specs/otlp/) protocol. Any OpenTelemetry-compatible SDK can export directly to this endpoint. Accepts both `application/json` and `application/x-protobuf` content types. + +For the easiest setup, use the [Respan tracing SDK](/docs/sdks/python-sdk/overview) or the [OpenTelemetry integration](/docs/integrations/opentelemetry) which auto-configures the exporter. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +from respan.traces import IngestTracesViaOtlpRequestResourceSpansItem + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.traces.ingest_traces_via_otlp( + authorization="Bearer sk_live_xxxxx", + resource_spans=[ + IngestTracesViaOtlpRequestResourceSpansItem() + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**resource_spans:** `typing.List[IngestTracesViaOtlpRequestResourceSpansItem]` — Array of resource spans. Each element represents spans from a single resource (service). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.traces.list(...) -> TracesListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a paginated list of traces matching your filters. See [Filters API Reference](/docs/api-reference/reference/filters-api-reference) for filter syntax. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +import datetime + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.traces.list( + sort_by="-total_cost", + start_time=datetime.datetime.fromisoformat("2025-01-01T00:00:00+00:00"), + end_time=datetime.datetime.fromisoformat("2025-01-31T23:59:59+00:00"), + environment="production", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — Page number. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — Results per page (max 1000). + +
+
+ +
+
+ +**sort_by:** `typing.Optional[str]` — Field to sort by. Prefix `-` for descending. + +
+
+ +
+
+ +**start_time:** `typing.Optional[datetime.datetime]` — Start of time range (ISO 8601). + +
+
+ +
+
+ +**end_time:** `typing.Optional[datetime.datetime]` — End of time range (ISO 8601). + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Filter by environment. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**operator:** `typing.Optional[TracesListRequestOperator]` — Logical operator to combine filters. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.traces.retrieve_trace(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a trace by its ID, including the complete span tree with full input/output for all spans. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.traces.retrieve_trace( + trace_unique_id="trace_unique_id", + environment="production", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**trace_unique_id:** `str` — Trace Unique Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Filter by environment. + +
+
+ +
+
+ +**start_time:** `typing.Optional[datetime.datetime]` — Start of time range (ISO 8601). + +
+
+ +
+
+ +**end_time:** `typing.Optional[datetime.datetime]` — End of time range (ISO 8601). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.traces.delete_trace(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a trace and all its spans by `trace_unique_id`. Removes data from both raw span storage and the aggregated trace table. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.traces.delete_trace( + trace_unique_id="trace_unique_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**trace_unique_id:** `str` — Unique identifier of the trace to delete. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**start_time:** `typing.Optional[str]` — ISO 8601 start of time range for efficient lookup. Defaults to end_time minus 1 hour. + +
+
+ +
+
+ +**end_time:** `typing.Optional[str]` — ISO 8601 end of time range for efficient lookup. Defaults to current time. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.traces.retrieve_traces_summary(...) -> RetrieveTracesSummaryResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get aggregated statistics for traces matching your filters. Uses the same filters and query parameters as [List traces](/docs/api-reference/observe/traces/list-traces). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +import datetime + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.traces.retrieve_traces_summary( + start_time=datetime.datetime.fromisoformat("2025-01-01T00:00:00+00:00"), + end_time=datetime.datetime.fromisoformat("2025-01-31T23:59:59+00:00"), + environment="production", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**start_time:** `typing.Optional[datetime.datetime]` — Start of time range (ISO 8601). + +
+
+ +
+
+ +**end_time:** `typing.Optional[datetime.datetime]` — End of time range (ISO 8601). + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Filter by environment. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.traces.bulk_delete_traces(...) -> BulkDeleteTracesResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete multiple traces matching the given filters. Uses the same filter format as [List traces](/docs/api-reference/observe/traces/list-traces). Returns the count of deleted traces. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient, Filters, FilterValue +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.traces.bulk_delete_traces( + authorization="Bearer sk_live_xxxxx", + filters=Filters( + customer_identifier=FilterValue( + operator="", + value=[ + "user_123" + ], + ), + model=FilterValue( + operator="", + value=[ + "gpt-4o" + ], + ), + cost=FilterValue( + operator="gte", + value=[ + 0.01 + ], + ), + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**filters:** `Filters` + +
+
+ +
+
+ +**start_time:** `typing.Optional[str]` — ISO 8601 start of time range. Defaults to end_time minus 1 hour. + +
+
+ +
+
+ +**end_time:** `typing.Optional[str]` — ISO 8601 end of time range. Defaults to current time. + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Filter by environment (e.g., production, staging). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.traces.ingest_traces_from_logs(...) -> IngestTracesFromLogsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Ingest a batch of spans to construct traces. Spans with the same `trace_unique_id` are grouped into a single trace. Parent-child relationships are inferred via `span_parent_id`. For new integrations, prefer [Create a trace (OTLP)](/docs/api-reference/observe/traces/create-a-trace-otlp). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +from respan.traces import IngestTracesFromLogsRequestBodyItem + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.traces.ingest_traces_from_logs( + authorization="Bearer sk_live_xxxxx", + request=[ + IngestTracesFromLogsRequestBodyItem( + trace_unique_id="trace_abc123", + span_unique_id="span_001", + ) + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request:** `typing.List[IngestTracesFromLogsRequestBodyItem]` — Array of span objects. Each span uses the same fields as [Create a span](/docs/api-reference/observe/spans/create-a-span). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Health +
client.health.check(...) -> HealthCheckResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Check API availability. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.health.check( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Threads +
client.threads.list(...) -> ThreadsListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve threads matching the specified filters with pagination. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.threads.list( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — The page number to retrieve. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — The number of items per page. Maximum is 1000. + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — This is controlled by the API key. A prod API key creates prod threads, test key creates test threads. + +
+
+ +
+
+ +**filters:** `typing.Optional[ThreadsListRequestFilters]` — Filter criteria. See [Filters API Reference](/docs/api-reference/reference/filters-api-reference). + +
+
+ +
+
+ +**operator:** `typing.Optional[ThreadsListRequestOperator]` — Logical operator to combine filters. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Users +
client.users.search(...) -> UsersSearchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve customers matching the specified filters with pagination. See [Filters API Reference](/docs/api-reference/reference/filters-api-reference) for filter syntax. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.users.search( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**page:** `typing.Optional[float]` — Page number. + +
+
+ +
+
+ +**page_size:** `typing.Optional[float]` — The number of customers to return per page. Maximum is 1000. + +
+
+ +
+
+ +**sort_by:** `typing.Optional[str]` — Sort field. Prefix with - for descending. + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Filter by environment. Options: prod, test. + +
+
+ +
+
+ +**filters:** `typing.Optional[UsersSearchRequestFilters]` — Filter criteria. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.users.retrieve_user(...) -> RetrieveUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a customer by their identifier. Returns usage stats, budgets, and metadata. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.users.retrieve_user( + customer_identifier="customer_identifier", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customer_identifier:** `str` — Your unique identifier for this customer. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Specify environment if you are not using the default. Options: prod, test. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.users.delete_user(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a customer by their identifier. This action is irreversible. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.users.delete_user( + customer_identifier="customer_identifier", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customer_identifier:** `str` — Your unique identifier for this customer. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.users.update_user(...) -> UpdateUserResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a customer profile. Supports name, email, metadata, and budget settings. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.users.update_user( + customer_identifier="customer_identifier", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**customer_identifier:** `str` — Your unique identifier for this customer. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**email:** `typing.Optional[str]` — Customer email address. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Customer display name. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value metadata. + +
+
+ +
+
+ +**period_budget:** `typing.Optional[float]` — Spending budget per period in USD. + +
+
+ +
+
+ +**budget_duration:** `typing.Optional[UpdateUserRequestBudgetDuration]` — Budget reset period. + +
+
+ +
+
+ +**total_budget:** `typing.Optional[float]` — Total lifetime spending budget in USD. + +
+
+ +
+
+ +**markup_percentage:** `typing.Optional[float]` — Markup percentage applied to costs for this customer. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Gateway +
client.gateway.create_chat_completion(...) -> CreateChatCompletionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Send a chat completion request through the Respan gateway. Supports 250+ models across OpenAI, Anthropic, Google, Azure, and more with automatic logging, fallbacks, and caching. + +Accepts all [OpenAI chat completion parameters](https://platform.openai.com/docs/api-reference/chat). Respan-specific parameters can be passed three ways: +1. **Top-level body fields** - add directly to the request body +2. **Nested under `respan_params`** - explicit namespacing to avoid conflicts +3. **Header `X-Respan-Params`** - base64-encoded JSON header + +Merge order: header > `respan_params` > top-level fields. + +When using the OpenAI SDK, pass Respan parameters via `extra_body`. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.gateway.create_chat_completion( + authorization="Bearer sk_live_xxxxx", + messages=[ + "messages" + ], + model="gpt-4o", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**messages:** `typing.List[str]` — Array of messages in the conversation. Each message has `role` (`system`, `user`, `assistant`, `tool`) and `content`. + +
+
+ +
+
+ +**model:** `str` — Model to use. See [Models](https://platform.respan.ai/platform/models) for available options. + +
+
+ +
+
+ +**respan_beta:** `typing.Optional[str]` — Comma-separated beta feature flags. Available: token-breakdown-2026-03-26, env-scoped-integrations-2026-03-28 + +
+
+ +
+
+ +**stream:** `typing.Optional[bool]` — Stream back partial progress token by token as server-sent events. + +
+
+ +
+
+ +**tools:** `typing.Optional[typing.List[typing.Dict[str, typing.Any]]]` — Tools the model may call. Currently only functions are supported. + +
+
+ +
+
+ +**tool_choice:** `typing.Optional[typing.Dict[str, typing.Any]]` — Controls tool selection. `"none"` = no tools, `"auto"` = model decides, or specify a tool object. + +
+
+ +
+
+ +**frequency_penalty:** `typing.Optional[float]` — Penalizes tokens based on frequency in text so far (-2 to 2). + +
+
+ +
+
+ +**max_tokens:** `typing.Optional[float]` — Maximum tokens to generate. + +
+
+ +
+
+ +**temperature:** `typing.Optional[float]` — Sampling temperature (0-2). Higher = more random. + +
+
+ +
+
+ +**n:** `typing.Optional[float]` — Number of completions to generate. Note: costs multiply with `n`. + +
+
+ +
+
+ +**logprobs:** `typing.Optional[bool]` — Return log probabilities of output tokens. + +
+
+ +
+
+ +**echo:** `typing.Optional[bool]` — Echo back the prompt in addition to the completion + +
+
+ +
+
+ +**stop:** `typing.Optional[typing.List[str]]` — Stop sequences where generation halts. + +
+
+ +
+
+ +**presence_penalty:** `typing.Optional[float]` — Penalizes tokens already present in text (-2 to 2). + +
+
+ +
+
+ +**logit_bias:** `typing.Optional[typing.Dict[str, typing.Any]]` — Used to modify the probability of tokens appearing in the response + +
+
+ +
+
+ +**response_format:** `typing.Optional[typing.Dict[str, typing.Any]]` — Output format. Set `{"type": "json_schema", "json_schema": {...}}` for structured output, or `{"type": "json_object"}` for JSON mode. + +
+
+ +
+
+ +**parallel_tool_calls:** `typing.Optional[bool]` — Enable parallel function calling during tool use. + +
+
+ +
+
+ +**load_balance_group:** `typing.Optional[typing.Dict[str, typing.Any]]` — Load balance config. Specify `models` array with `model`, `weight`, and optional `credentials` per model. See [Advanced configuration](/docs/documentation/features/gateway/advanced). + +
+
+ +
+
+ +**fallback_models:** `typing.Optional[typing.List[str]]` — Backup models (ranked by priority) if the primary model fails. + +
+
+ +
+
+ +**customer_credentials:** `typing.Optional[typing.Dict[str, typing.Any]]` — Per-customer LLM provider credentials. Keys are provider names, values are API keys. + +
+
+ +
+
+ +**credential_override:** `typing.Optional[typing.Dict[str, typing.Any]]` — One-off credential overrides per provider. Overrides uploaded provider keys for this request only. + +
+
+ +
+
+ +**cache_enabled:** `typing.Optional[bool]` — Enable response caching. See [Caching](/docs/documentation/features/gateway/advanced). + +
+
+ +
+
+ +**cache_ttl:** `typing.Optional[float]` — Cache time-to-live in seconds. + +
+
+ +
+
+ +**cache_options:** `typing.Optional[bool]` — Cache options. Set `cache_by_customer: true` to cache per customer. + +
+
+ +
+
+ +**prompt:** `typing.Optional[typing.Dict[str, typing.Any]]` — Prompt template config. Properties: `prompt_id` (required), `variables` (template variables), `version` (number, or `"latest"` for draft), `echo` (return rendered prompt), `override` (use override_params), `override_params` (OpenAI params to override), `schema_version` (`1` = legacy, `2` = prompt config wins). See [Prompt management](/docs/documentation/features/prompt-management/advanced). + +
+
+ +
+
+ +**retry_params:** `typing.Optional[typing.Dict[str, typing.Any]]` — Retry config. Properties: `retry_enabled` (boolean, required), `num_retries` (number), `retry_after` (seconds to wait). + +
+
+ +
+
+ +**disable_log:** `typing.Optional[bool]` — When `true`, omits input/output from the log. Metrics (tokens, cost, latency) are still recorded. + +
+
+ +
+
+ +**model_name_map:** `typing.Optional[typing.Dict[str, typing.Any]]` — Azure deployment name mapping. Maps your custom Azure deployment names to standard model names. + +
+
+ +
+
+ +**models:** `typing.Optional[typing.List[str]]` — Load balancing model list. Each item: `model` (name), `weight` (routing weight), optional `credentials`. + +
+
+ +
+
+ +**exclude_providers:** `typing.Optional[typing.List[str]]` — Providers to exclude from routing. All models under excluded providers are skipped. + +
+
+ +
+
+ +**exclude_models:** `typing.Optional[typing.List[str]]` — Specific models to exclude from routing. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value metadata attached to the span. + +
+
+ +
+
+ +**custom_identifier:** `typing.Optional[str]` — Indexed custom tag for fast querying. + +
+
+ +
+
+ +**customer_identifier:** `typing.Optional[str]` — End user identifier for analytics and budgets. + +
+
+ +
+
+ +**customer_params:** `typing.Optional[typing.Dict[str, typing.Any]]` — Extended customer info. Properties: `customer_identifier` (required), `group_identifier`, `name`, `email`, `period_budget`, `budget_duration` (`daily`/`weekly`/`monthly`/`yearly`), `total_budget`, `markup_percentage`. + +
+
+ +
+
+ +**request_breakdown:** `typing.Optional[bool]` — Return response metrics summary in the response body. For streaming, metrics appear in the final chunk. + +
+
+ +
+
+ +**positive_feedback:** `typing.Optional[bool]` — User feedback. `true` = liked, `false` = disliked. + +
+
+ +
+
+ +**customer_api_keys:** `typing.Optional[typing.Dict[str, typing.Any]]` — You can pass in a dictionary of your customer's API keys for specific models. If the router selects a model that is in the dictionary, it will attempt to use the customer's API key for calling the model before using your integration API key or Respan's default API key. + +
+
+ +
+
+ +**loadbalance_models:** `typing.Optional[typing.List[str]]` — Balance the load of your requests between different models. See the details of load balancing here. + +
+
+ +
+
+ +**thread_identifier:** `typing.Optional[str]` — Conversation thread ID. Spans with the same `thread_identifier` are grouped together. + +
+
+ +
+
+ +**properties:** `typing.Optional[typing.Dict[str, typing.Any]]` — Typed metadata preserving native types (numbers, booleans, nested objects). Unlike `metadata` which coerces to strings. + +
+
+ +
+
+ +**retries:** `typing.Optional[int]` — Number of retries on failure. + +
+
+ +
+
+ +**weight:** `typing.Optional[float]` — Load balancing weight. + +
+
+ +
+
+ +**prompt_id:** `typing.Optional[str]` — Respan prompt template ID. + +
+
+ +
+
+ +**prompt_variables:** `typing.Optional[typing.Dict[str, typing.Any]]` — Variables to inject into the prompt template. + +
+
+ +
+
+ +**span_name:** `typing.Optional[str]` — Custom span name for tracing. + +
+
+ +
+
+ +**respan_params:** `typing.Optional[typing.Dict[str, typing.Any]]` — Namespaced container for all Respan parameters. Alternative to passing them at top level. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.gateway.create_response(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Send a response request through the Respan gateway using the OpenAI Responses API format. Supports streaming, tool use, and prompt management. + +Respan parameters can be passed the same way as [Create chat completion](/docs/api-reference/develop/gateway/create-chat-completion): top-level fields, nested under `respan_params`, or via `X-Respan-Params` header. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.gateway.create_response( + authorization="Bearer sk_live_xxxxx", + model="gpt-4o", + input="input", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**model:** `str` — Model to use. + +
+
+ +
+
+ +**input:** `CreateResponseRequestInput` — Input text or array of conversation messages. + +
+
+ +
+
+ +**respan_beta:** `typing.Optional[str]` — Comma-separated beta feature flags. Available: token-breakdown-2026-03-26, env-scoped-integrations-2026-03-28 + +
+
+ +
+
+ +**instructions:** `typing.Optional[str]` — System instructions for the model. + +
+
+ +
+
+ +**stream:** `typing.Optional[bool]` — Stream the response as server-sent events. + +
+
+ +
+
+ +**temperature:** `typing.Optional[float]` — Sampling temperature (0-2). + +
+
+ +
+
+ +**max_output_tokens:** `typing.Optional[int]` — Maximum tokens to generate. + +
+
+ +
+
+ +**top_p:** `typing.Optional[float]` — Nucleus sampling parameter. + +
+
+ +
+
+ +**tools:** `typing.Optional[typing.List[typing.Dict[str, typing.Any]]]` — Tools the model may call. + +
+
+ +
+
+ +**previous_response_id:** `typing.Optional[str]` — ID of a previous response for multi-turn conversations. + +
+
+ +
+
+ +**fallback_models:** `typing.Optional[typing.List[str]]` — Backup models if the primary model fails. + +
+
+ +
+
+ +**customer_credentials:** `typing.Optional[typing.Dict[str, typing.Any]]` — Per-customer LLM provider credentials. + +
+
+ +
+
+ +**credential_override:** `typing.Optional[typing.Dict[str, typing.Any]]` — One-off credential overrides per provider. + +
+
+ +
+
+ +**cache_enabled:** `typing.Optional[bool]` — Enable response caching. + +
+
+ +
+
+ +**cache_ttl:** `typing.Optional[int]` — Cache TTL in seconds. + +
+
+ +
+
+ +**prompt:** `typing.Optional[typing.Dict[str, typing.Any]]` — Prompt template config. Properties: `prompt_id` (required), `variables`, `version`, `echo`. See [Prompt management](/docs/documentation/features/prompt-management/advanced). + +
+
+ +
+
+ +**retry_params:** `typing.Optional[typing.Dict[str, typing.Any]]` — Retry config. Properties: `retry_enabled` (boolean), `num_retries`, `retry_after` (seconds). + +
+
+ +
+
+ +**disable_log:** `typing.Optional[bool]` — When `true`, omits input/output from the log. Metrics still recorded. + +
+
+ +
+
+ +**models:** `typing.Optional[typing.List[typing.Dict[str, typing.Any]]]` — Load balancing model list. + +
+
+ +
+
+ +**exclude_providers:** `typing.Optional[typing.List[str]]` — Providers to exclude from routing. + +
+
+ +
+
+ +**exclude_models:** `typing.Optional[typing.List[str]]` — Models to exclude from routing. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value metadata attached to the span. + +
+
+ +
+
+ +**custom_identifier:** `typing.Optional[str]` — Indexed custom tag for fast querying. + +
+
+ +
+
+ +**customer_identifier:** `typing.Optional[str]` — End user identifier for analytics and budgets. + +
+
+ +
+
+ +**customer_params:** `typing.Optional[typing.Dict[str, typing.Any]]` — Extended customer info. + +
+
+ +
+
+ +**thread_identifier:** `typing.Optional[str]` — Conversation thread ID. + +
+
+ +
+
+ +**positive_feedback:** `typing.Optional[bool]` — User feedback. `true` = liked, `false` = disliked. + +
+
+ +
+
+ +**properties:** `typing.Optional[typing.Dict[str, typing.Any]]` — Typed metadata preserving native types. + +
+
+ +
+
+ +**respan_params:** `typing.Optional[typing.Dict[str, typing.Any]]` — Namespaced container for all Respan parameters. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## OpenAI Batch +
client.open_ai_batch.list_files(...) -> ListFilesResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all uploaded files. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.list_files( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.upload_file(...) -> UploadFileResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Upload a JSONL file for batch processing. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.upload_file( + authorization="Bearer sk_live_xxxxx", + file="example_file", + purpose="batch", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**file:** `core.File` — The JSONL file to upload. + +
+
+ +
+
+ +**purpose:** `UploadFileRequestPurpose` — Intended purpose of the file. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.retrieve_file(...) -> RetrieveFileResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve metadata for a specific file. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.retrieve_file( + file_id="file_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file_id:** `str` — The unique identifier of the file to retrieve. Format: file-xxxxx + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.delete_file(...) -> DeleteFileResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an uploaded file. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.delete_file( + file_id="file_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file_id:** `str` — The unique identifier of the file to delete. Format: file-xxxxx + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.retrieve_file_content(...) -> typing.Iterator[bytes] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Download the content of a file. For batch output files, returns JSONL with results for each request. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.retrieve_file_content( + file_id="file_id", + authorization="authorization", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**file_id:** `str` — The unique identifier of the file whose content you want to download. Format: file-xxxxx + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.list_batches(...) -> ListBatchesResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List batch processing jobs with pagination. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.list_batches( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**limit:** `typing.Optional[int]` — Maximum number of batches to return. + +
+
+ +
+
+ +**after:** `typing.Optional[str]` — Cursor for pagination. Use the last_id from a previous response to get the next page. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.create_batch(...) -> CreateBatchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new batch processing job from an uploaded JSONL file. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.create_batch( + authorization="Bearer sk_live_xxxxx", + input_file_id="file-abc123", + endpoint="/v1/chat/completions", + completion_window="24h", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**input_file_id:** `str` — ID of the uploaded JSONL file. Get from Upload file endpoint. + +
+
+ +
+
+ +**endpoint:** `CreateBatchRequestEndpoint` — API endpoint for batch requests. + +
+
+ +
+
+ +**completion_window:** `CreateBatchRequestCompletionWindow` — Processing time frame. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value pairs for tracking. + +
+
+ +
+
+ +**customer_identifier:** `typing.Optional[str]` — End user identifier. + +
+
+ +
+
+ +**custom_identifier:** `typing.Optional[str]` — Custom identifier for fast querying. + +
+
+ +
+
+ +**thread_identifier:** `typing.Optional[str]` — Conversation thread ID. + +
+
+ +
+
+ +**environment:** `typing.Optional[str]` — Environment tag. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.retrieve_batch(...) -> RetrieveBatchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve details of a batch processing job. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.retrieve_batch( + batch_id="batch_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**batch_id:** `str` — The unique identifier of the batch to retrieve. Format: batch_xxxxx + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.open_ai_batch.cancel_batch(...) -> CancelBatchResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Cancel an in-progress batch. Already completed requests in the batch are not affected. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.open_ai_batch.cancel_batch( + batch_id="batch_id", + authorization="Bearer sk_live_xxxxx", + request={ + "key": "value" + }, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**batch_id:** `str` — The unique identifier of the batch to cancel. Format: batch_xxxxx + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request:** `typing.Dict[str, typing.Any]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Multimodal +
client.multimodal.embeddings(...) -> EmbeddingsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create embeddings through the Respan gateway with automatic logging. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.multimodal.embeddings( + authorization="Bearer sk_live_xxxxx", + model="text-embedding-3-small", + input="Hello world", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**model:** `EmbeddingsRequestModel` — Embedding model ID. + +
+
+ +
+
+ +**input:** `typing.Any` + +
+
+ +
+
+ +**encoding_format:** `typing.Optional[EmbeddingsRequestEncodingFormat]` — Output format. + +
+
+ +
+
+ +**dimensions:** `typing.Optional[int]` — Output embedding dimensions. Only supported by `text-embedding-3-*` models. + +
+
+ +
+
+ +**customer_credentials:** `typing.Optional[typing.Dict[str, typing.Any]]` — Per-customer LLM provider credentials. + +
+
+ +
+
+ +**disable_log:** `typing.Optional[bool]` — When `true`, omits input/output from the log. Metrics still recorded. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value metadata. + +
+
+ +
+
+ +**customer_identifier:** `typing.Optional[str]` — End user identifier. + +
+
+ +
+
+ +**customer_email:** `typing.Optional[str]` — Customer email address. + +
+
+ +
+
+ +**thread_identifier:** `typing.Optional[str]` — Conversation thread ID. + +
+
+ +
+
+ +**request_breakdown:** `typing.Optional[bool]` — Return response metrics summary in the response body. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.multimodal.speech_to_text(...) -> SpeechToTextResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Transcribe audio to text through the Respan gateway with automatic logging. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.multimodal.speech_to_text( + authorization="Bearer sk_live_xxxxx", + file="example_file", + model="whisper-1", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**file:** `core.File` — Audio file. Supported: flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm. + +
+
+ +
+
+ +**model:** `SpeechToTextRequestModel` — Model ID. + +
+
+ +
+
+ +**language:** `typing.Optional[str]` — Input audio language (ISO-639-1). + +
+
+ +
+
+ +**prompt:** `typing.Optional[str]` — Optional text to guide the model's style. + +
+
+ +
+
+ +**response_format:** `typing.Optional[SpeechToTextRequestResponseFormat]` — Output format. + +
+
+ +
+
+ +**temperature:** `typing.Optional[float]` — Sampling temperature (0-1). + +
+
+ +
+
+ +**timestamp_granularities:** `typing.Optional[typing.List[str]]` — Timestamp granularities. Requires `verbose_json` response format. + +
+
+ +
+
+ +**customer_credentials:** `typing.Optional[typing.Dict[str, typing.Any]]` — Per-customer LLM provider credentials. + +
+
+ +
+
+ +**disable_log:** `typing.Optional[bool]` — When `true`, omits input/output from the log. Metrics still recorded. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value metadata. + +
+
+ +
+
+ +**customer_identifier:** `typing.Optional[str]` — End user identifier. + +
+
+ +
+
+ +**customer_email:** `typing.Optional[str]` — Customer email address. + +
+
+ +
+
+ +**thread_identifier:** `typing.Optional[str]` — Conversation thread ID. + +
+
+ +
+
+ +**request_breakdown:** `typing.Optional[bool]` — Return response metrics summary in the response body. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.multimodal.text_to_speech(...) -> typing.Iterator[bytes] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Convert text to speech through the Respan gateway with automatic logging. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.multimodal.text_to_speech( + authorization="authorization", + model="tts-1", + input="input", + voice="alloy", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**model:** `TextToSpeechRequestModel` — TTS model. + +
+
+ +
+
+ +**input:** `str` — Text to generate audio for. Max 4096 characters. + +
+
+ +
+
+ +**voice:** `TextToSpeechRequestVoice` — Voice to use. + +
+
+ +
+
+ +**response_format:** `typing.Optional[TextToSpeechRequestResponseFormat]` — Audio output format. + +
+
+ +
+
+ +**speed:** `typing.Optional[float]` — Audio speed (0.25 to 4.0). + +
+
+ +
+
+ +**customer_credentials:** `typing.Optional[typing.Dict[str, typing.Any]]` — Per-customer LLM provider credentials. + +
+
+ +
+
+ +**disable_log:** `typing.Optional[bool]` — When `true`, omits input/output from the log. Metrics still recorded. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value metadata. + +
+
+ +
+
+ +**customer_identifier:** `typing.Optional[str]` — End user identifier. + +
+
+ +
+
+ +**customer_email:** `typing.Optional[str]` — Customer email address. + +
+
+ +
+
+ +**thread_identifier:** `typing.Optional[str]` — Conversation thread ID. + +
+
+ +
+
+ +**request_breakdown:** `typing.Optional[bool]` — Return response metrics summary in the response body. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.multimodal.assemblyai_integration(...) -> AssemblyaiIntegrationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an AssemblyAI transcript by ID. Proxied through Respan for logging. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.multimodal.assemblyai_integration( + transcript_id="transcript_id", + authorization="Bearer sk_live_xxxxx", + assemblyai_api_key="X-Assemblyai-Api-Key", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**transcript_id:** `str` — The AssemblyAI transcript ID to retrieve. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**assemblyai_api_key:** `str` — Your AssemblyAI API key for authentication with AssemblyAI services. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Prompts +
client.prompts.list_prompts(...) -> ListPromptsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List prompts with pagination and sorting. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.list_prompts( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — Page number + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — Number of items per page (max: 100) + +
+
+ +
+
+ +**sort_by:** `typing.Optional[ListPromptsRequestSortBy]` — Sort field (e.g., -current_version__updated_at, -id) + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.create_prompt(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new prompt template. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.create_prompt( + authorization="Bearer sk_live_xxxxx", + name="customer_support", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `str` — Prompt name. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Prompt description. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.retrieve_prompt(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single prompt by ID, including its current deployed version. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.retrieve_prompt( + prompt_id="prompt_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — The unique prompt identifier + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.delete_prompt(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a prompt and all its versions. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.delete_prompt( + prompt_id="prompt_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — Prompt Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.update_prompt(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a prompt's name or description. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.update_prompt( + prompt_id="prompt_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — Prompt Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Prompt name. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Prompt description. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.retrieve_versions(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all versions of a prompt. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.retrieve_versions( + prompt_id="prompt_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — Prompt Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.create_version(...) -> CreateVersionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new version of a prompt. Use `{{variable_name}}` syntax in messages to define template variables. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.create_version( + prompt_id="prompt_id", + authorization="Bearer sk_live_xxxxx", + messages=[ + "messages" + ], + model="gpt-4o", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — Prompt Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**messages:** `typing.List[str]` — Messages for this version. Use `{{variable_name}}` for template variables. + +
+
+ +
+
+ +**model:** `str` — Model for this version. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Version description. + +
+
+ +
+
+ +**stream:** `typing.Optional[bool]` — Whether to stream responses. + +
+
+ +
+
+ +**temperature:** `typing.Optional[float]` — Sampling temperature (0-2). + +
+
+ +
+
+ +**max_tokens:** `typing.Optional[int]` — Maximum tokens to generate. + +
+
+ +
+
+ +**top_p:** `typing.Optional[float]` — Nucleus sampling parameter. + +
+
+ +
+
+ +**frequency_penalty:** `typing.Optional[float]` — Frequency penalty (-2 to 2). + +
+
+ +
+
+ +**presence_penalty:** `typing.Optional[float]` — Presence penalty (-2 to 2). + +
+
+ +
+
+ +**variables:** `typing.Optional[typing.Dict[str, typing.Any]]` — Template variables and their default values. + +
+
+ +
+
+ +**fallback_models:** `typing.Optional[typing.List[str]]` — Fallback models if the primary model fails. + +
+
+ +
+
+ +**tools:** `typing.Optional[typing.List[str]]` — Tools available to the model (function calling). + +
+
+ +
+
+ +**deploy:** `typing.Optional[bool]` — Deploy this version as the live version. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.retrieve_prompt_version(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a specific version of a prompt. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.retrieve_prompt_version( + prompt_id="prompt_id", + version="version", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — The unique prompt identifier + +
+
+ +
+
+ +**version:** `str` — The version number + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.delete_version(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a specific prompt version. Cannot delete the currently deployed version. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.delete_version( + prompt_id="prompt_id", + version="version", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — Prompt Id + +
+
+ +
+
+ +**version:** `str` — Version + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.update_prompt_version(...) -> UpdatePromptVersionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a prompt version's messages, model, parameters, or deploy it as the live version. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.update_prompt_version( + prompt_id="prompt_id", + version="version", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — Prompt Id + +
+
+ +
+
+ +**version:** `str` — Version + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**messages:** `typing.Optional[typing.List[typing.Any]]` — Messages for this version. Use `{{variable_name}}` for template variables. + +
+
+ +
+
+ +**model:** `typing.Optional[str]` — Model for this version. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Version description. + +
+
+ +
+
+ +**stream:** `typing.Optional[bool]` — Whether to stream responses. + +
+
+ +
+
+ +**temperature:** `typing.Optional[float]` — Sampling temperature (0-2). + +
+
+ +
+
+ +**max_tokens:** `typing.Optional[int]` — Maximum tokens to generate. + +
+
+ +
+
+ +**top_p:** `typing.Optional[float]` — Nucleus sampling parameter. + +
+
+ +
+
+ +**frequency_penalty:** `typing.Optional[float]` — Frequency penalty (-2 to 2). + +
+
+ +
+
+ +**presence_penalty:** `typing.Optional[float]` — Presence penalty (-2 to 2). + +
+
+ +
+
+ +**variables:** `typing.Optional[typing.Dict[str, typing.Any]]` — Template variables and default values. + +
+
+ +
+
+ +**fallback_models:** `typing.Optional[typing.List[str]]` — Fallback models. + +
+
+ +
+
+ +**tools:** `typing.Optional[typing.List[typing.Any]]` — Tools for function calling. + +
+
+ +
+
+ +**deploy:** `typing.Optional[bool]` — Deploy this version as the live version. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.commit_draft_version(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Commit the current prompt version with a description message. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.commit_draft_version( + prompt_id="prompt_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — The unique prompt identifier + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Commit message describing the changes. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.deploy_committed_version(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Deploy a specific version as the live version. All API calls referencing this prompt will use the deployed version. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.deploy_committed_version( + prompt_id="prompt_id", + authorization="Bearer sk_live_xxxxx", + version=3, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**prompt_id:** `str` — The unique prompt identifier + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**version:** `int` — Version number to deploy as live. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.get_prompts_summary(...) -> GetPromptsSummaryResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get aggregated summary statistics for all prompts. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.get_prompts_summary( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.prompts.get_prompts_summary_with_filters(...) -> GetPromptsSummaryWithFiltersResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get aggregated summary statistics for prompts matching the given filters. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.prompts.get_prompts_summary_with_filters( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Testsets +
client.testsets.create_testset(...) -> CreateTestsetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new testset for evaluation. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.create_testset( + authorization="Bearer sk_live_xxxxx", + name="QA Test Set", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `str` — Testset name. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Testset description. + +
+
+ +
+
+ +**column_definitions:** `typing.Optional[typing.List[CreateTestsetRequestColumnDefinitionsItem]]` — Column definitions for the testset. + +
+
+ +
+
+ +**starred:** `typing.Optional[bool]` — Star the testset. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.list_testsets(...) -> ListTestsetsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List testsets with optional filtering. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.list_testsets( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**filters:** `typing.Optional[typing.Dict[str, typing.Any]]` — Filter criteria. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.retrieve_testset(...) -> RetrieveTestsetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a testset by ID, including column definitions. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.retrieve_testset( + testset_id="testset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**testset_id:** `str` — The ID of the testset to retrieve. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.delete_testset(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a testset and all its rows. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.delete_testset( + testset_id="testset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**testset_id:** `str` — The ID of the testset to delete. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.update_testset(...) -> UpdateTestsetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a testset's name, description, or starred status. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.update_testset( + testset_id="testset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**testset_id:** `str` — The ID of the testset to update. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Testset name. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Testset description. + +
+
+ +
+
+ +**starred:** `typing.Optional[bool]` — Star the testset. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.list_testset_rows(...) -> ListTestsetRowsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all rows in a testset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.list_testset_rows( + testset_id="testset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**testset_id:** `str` — The ID of the testset to list rows from. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.create_testset_rows(...) -> CreateTestsetRowsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add rows to a testset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +from respan.testsets import CreateTestsetRowsRequestBodyItem + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.create_testset_rows( + testset_id="testset_id", + authorization="Bearer sk_live_xxxxx", + request=[ + CreateTestsetRowsRequestBodyItem() + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**testset_id:** `str` — The ID of the testset to add rows to. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request:** `typing.List[CreateTestsetRowsRequestBodyItem]` — Array of row objects. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.delete_testset_row(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a specific row from a testset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.delete_testset_row( + testset_id="testset_id", + row_index=1, + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**testset_id:** `str` — The ID of the testset. + +
+
+ +
+
+ +**row_index:** `int` — The index of the row to delete. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.testsets.update_testset_row(...) -> UpdateTestsetRowResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a specific row in a testset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.testsets.update_testset_row( + testset_id="testset_id", + row_index=1, + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**testset_id:** `str` — The ID of the testset. + +
+
+ +
+
+ +**row_index:** `int` — The index of the row to update. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**row_data:** `typing.Optional[typing.Dict[str, typing.Any]]` — Updated row data keyed by column name. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Experiments +
client.experiments.create_experiment(...) -> CreateExperimentResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new experiment with workflows. Supports custom (submit results via API), completion (auto-run LLM calls), and prompt (test prompt versions) workflow types. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.create_experiment( + authorization="Bearer sk_live_xxxxx", + name="model-comparison", + dataset_id="ds_abc123", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `str` — Experiment name. + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset ID to run against. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Experiment description. + +
+
+ +
+
+ +**workflows:** `typing.Optional[typing.List[CreateExperimentRequestWorkflowsItem]]` — Array of workflow configs. Each has `type`, `config`, and optional settings. + +
+
+ +
+
+ +**evaluator_slugs:** `typing.Optional[typing.List[str]]` — Evaluator slugs to auto-run on results. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.search_experiment(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Search experiments with filters. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.search_experiment( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.retrieve_experiment(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an experiment by ID, including its workflows and configuration. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.retrieve_experiment( + experiment_id="experiment_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**experiment_id:** `str` — The ID of the experiment to retrieve. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.delete_experiment(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an experiment and all its results. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.delete_experiment( + experiment_id="experiment_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**experiment_id:** `str` — The ID of the experiment to delete. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.search_experiment_spans(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Search experiment spans with filters. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.search_experiment_spans( + experiment_id="experiment_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**experiment_id:** `str` — The ID of the experiment to search spans for. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.retrieve_experiment_span(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single span (result) from an experiment. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.retrieve_experiment_span( + experiment_id="experiment_id", + log_id="log_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**experiment_id:** `str` — The ID of the experiment. + +
+
+ +
+
+ +**log_id:** `str` — The ID of the log to retrieve. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.update_experiment_span(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a span in an experiment. Supports updating output, metadata, and scores. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.update_experiment_span( + experiment_id="experiment_id", + log_id="log_id", + authorization="Bearer sk_live_xxxxx", + request={ + "key": "value" + }, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**experiment_id:** `str` — The ID of the experiment. + +
+
+ +
+
+ +**log_id:** `str` — The ID of the log to update. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request:** `typing.Dict[str, typing.Any]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.get_experiment_spans_summary(...) -> typing.Dict[str, typing.Any] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Get aggregated statistics for spans in an experiment. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.get_experiment_spans_summary( + experiment_id="experiment_id", + start_time="start_time", + end_time="end_time", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**experiment_id:** `str` — The ID of the experiment to get summary statistics for. + +
+
+ +
+
+ +**start_time:** `str` — Filter start time (ISO format). + +
+
+ +
+
+ +**end_time:** `str` — Filter end time (ISO format). + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.experiments.export_experiment_spans(...) -> ExportExperimentSpansResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Export all experiment spans. Supports pagination and sorting. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.experiments.export_experiment_spans( + experiment_id="experiment_id", + export="export", + page=1, + page_size=1, + sort_by="sort_by", + start_time="start_time", + end_time="end_time", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**experiment_id:** `str` — The ID of the experiment to export spans from. + +
+
+ +
+
+ +**export:** `str` — Set to 1 or true to trigger export. + +
+
+ +
+
+ +**page:** `int` — Page number (default: 1). + +
+
+ +
+
+ +**page_size:** `int` — Number of results per page (default: 100). + +
+
+ +
+
+ +**sort_by:** `str` — Sort field (e.g., "-cost", "-start_time", "name"). + +
+
+ +
+
+ +**start_time:** `str` — Filter start time (ISO format). + +
+
+ +
+
+ +**end_time:** `str` — Filter end time (ISO format). + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Evaluators +
client.evaluators.create_evaluator(...) -> CreateEvaluatorResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new evaluator for scoring LLM outputs. Specify `type` and `score_value_type`. Optionally use `eval_class` for pre-built templates. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.evaluators.create_evaluator( + authorization="Bearer sk_live_xxxxx", + name="Response Quality", + type="llm", + score_value_type="numerical", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `str` — Evaluator display name. + +
+
+ +
+
+ +**type:** `CreateEvaluatorRequestType` — Evaluator type. + +
+
+ +
+
+ +**score_value_type:** `CreateEvaluatorRequestScoreValueType` — Score format. + +
+
+ +
+
+ +**evaluator_slug:** `typing.Optional[str]` — Unique identifier. Auto-generated if not provided. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Evaluator description. + +
+
+ +
+
+ +**eval_class:** `typing.Optional[CreateEvaluatorRequestEvalClass]` — Pre-built template. + +
+
+ +
+
+ +**categorical_choices:** `typing.Optional[typing.List[CreateEvaluatorRequestCategoricalChoicesItem]]` — Required for `single_select` or `multi_select` score types. + +
+
+ +
+
+ +**score_config:** `typing.Optional[CreateEvaluatorRequestScoreConfig]` — Score type configuration. For numerical/percentage: `min_score`, `max_score`. For single/multi select: `choices` array. + +
+
+ +
+
+ +**passing_conditions:** `typing.Optional[typing.Dict[str, typing.Any]]` — Conditions for passing. Uses filter format (e.g. `{"primary_score": {"operator": "gte", "value": 3}}`). + +
+
+ +
+
+ +**llm_config:** `typing.Optional[CreateEvaluatorRequestLlmConfig]` — LLM automation config. Required fields: `model`, `evaluator_definition`. + +
+
+ +
+
+ +**code_config:** `typing.Optional[CreateEvaluatorRequestCodeConfig]` — Code automation config. + +
+
+ +
+
+ +**configurations:** `typing.Optional[CreateEvaluatorRequestConfigurations]` — Legacy configuration format. Use `llm_config`/`code_config` instead for new evaluators. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.evaluators.retrieve_evaluator(...) -> RetrieveEvaluatorResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an evaluator by ID, including its full configuration. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.evaluators.retrieve_evaluator( + evaluator_id="evaluator_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**evaluator_id:** `str` — Evaluator Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.evaluators.delete_evaluator(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an evaluator. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.evaluators.delete_evaluator( + evaluator_id="evaluator_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**evaluator_id:** `str` — Evaluator Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.evaluators.update_evaluator(...) -> UpdateEvaluatorResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an evaluator's configuration, scoring, or automation settings. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.evaluators.update_evaluator( + evaluator_id="evaluator_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**evaluator_id:** `str` — Evaluator Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Evaluator name. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` + +
+
+ +
+
+ +**score_value_type:** `typing.Optional[UpdateEvaluatorRequestScoreValueType]` + +
+
+ +
+
+ +**categorical_choices:** `typing.Optional[typing.List[typing.Dict[str, typing.Any]]]` + +
+
+ +
+
+ +**score_config:** `typing.Optional[typing.Dict[str, typing.Any]]` — Score configuration. + +
+
+ +
+
+ +**passing_conditions:** `typing.Optional[typing.Dict[str, typing.Any]]` — Passing conditions. + +
+
+ +
+
+ +**llm_config:** `typing.Optional[typing.Dict[str, typing.Any]]` — LLM automation config. + +
+
+ +
+
+ +**code_config:** `typing.Optional[typing.Dict[str, typing.Any]]` — Code automation config. + +
+
+ +
+
+ +**configurations:** `typing.Optional[typing.Dict[str, typing.Any]]` — Legacy config format. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.evaluators.run_evaluator(...) -> RunEvaluatorResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Run an evaluator against spans or a dataset to generate scores. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.evaluators.run_evaluator( + evaluator_id="evaluator_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**evaluator_id:** `str` — Evaluator Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**log_ids:** `typing.Optional[typing.List[str]]` — Span IDs to evaluate. + +
+
+ +
+
+ +**dataset_id:** `typing.Optional[str]` — Dataset ID to evaluate all spans in. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.evaluators.list_evaluators(...) -> typing.List[ListEvaluatorsResponseItem] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List evaluators with optional filters. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.evaluators.list_evaluators( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Datasets +
client.datasets.retrieve_dataset(...) -> RetrieveDatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a dataset by ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.retrieve_dataset( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.delete_dataset(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a dataset and all its spans. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.delete_dataset( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.update_dataset(...) -> UpdateDatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a dataset's name or description. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.update_dataset( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Dataset name. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Dataset description. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.create_dataset(...) -> CreateDatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new dataset, either empty or populated from existing spans using filters and sampling. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.create_dataset( + authorization="Bearer sk_live_xxxxx", + name="qa-test-set", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `str` — Dataset name. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Dataset description. + +
+
+ +
+
+ +**sampling:** `typing.Optional[int]` — Sampling rate (0-1). Fraction of matching spans to include. + +
+
+ +
+
+ +**start_time:** `typing.Optional[str]` — Start of time range for selecting spans (ISO 8601). + +
+
+ +
+
+ +**end_time:** `typing.Optional[str]` — End of time range for selecting spans (ISO 8601). + +
+
+ +
+
+ +**is_empty:** `typing.Optional[bool]` — Create an empty dataset (no initial spans). + +
+
+ +
+
+ +**initial_log_filters:** `typing.Optional[typing.Dict[str, typing.Any]]` — Filters for selecting initial spans. Same format as [Filters API](/docs/api-reference/reference/filters-api-reference). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.list_datasets(...) -> ListDatasetsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List datasets with pagination and filters. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.list_datasets( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — Page number. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — Results per page. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.listspanswithfilters(...) -> DatasetsListSpansWithFiltersResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List spans in a dataset with filters and pagination. See [Filters API Reference](/docs/api-reference/reference/filters-api-reference). +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.listspanswithfilters( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.create_dataset_span(...) -> CreateDatasetSpanResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new span in a dataset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.create_dataset_span( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", + input="What is 2+2?", + output="4", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**input:** `str` — Span input data. + +
+
+ +
+
+ +**output:** `str` — Span output data. + +
+
+ +
+
+ +**metadata:** `typing.Optional[typing.Dict[str, typing.Any]]` — Custom key-value metadata. + +
+
+ +
+
+ +**metrics:** `typing.Optional[typing.Dict[str, typing.Any]]` — Performance metrics. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.retrievespan(...) -> DatasetsRetrieveSpanResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a single span from a dataset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.retrievespan( + dataset_id="dataset_id", + log_id="log_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.delete_span(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a single span from a dataset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.delete_span( + dataset_id="dataset_id", + log_id="log_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.update_span_partial(...) -> UpdateSpanPartialResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update fields on a span in a dataset. Only provided fields are updated. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.update_span_partial( + dataset_id="dataset_id", + log_id="log_id", + authorization="Bearer sk_live_xxxxx", + request={ + "key": "value" + }, +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request:** `typing.Dict[str, typing.Any]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.delete_spans(...) -> DeleteSpansResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete spans from a dataset by filters, or delete all spans. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.delete_spans( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**is_deleting_all_logs:** `typing.Optional[bool]` — Delete all spans in the dataset. Required if no `filters` provided. + +
+
+ +
+
+ +**filters:** `typing.Optional[Filters]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.add_spans_to_dataset(...) -> AddSpansToDatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Add existing spans to a dataset by their IDs. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.add_spans_to_dataset( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", + log_ids=[ + "log_abc", + "log_def" + ], +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — Dataset Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**log_ids:** `typing.List[str]` — Array of span IDs to add. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.run_eval_on_dataset(...) -> RunEvalOnDatasetResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Run evaluators on all spans in a dataset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.run_eval_on_dataset( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — The ID of the dataset to run evaluations on. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**evaluator_ids:** `typing.Optional[typing.List[str]]` — Evaluator IDs to run. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.datasets.list_eval_runs(...) -> ListEvalRunsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List evaluation runs for a dataset. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.datasets.list_eval_runs( + dataset_id="dataset_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**dataset_id:** `str` — The ID of the dataset to list evaluation reports for. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Scores +
client.scores.list_scores(...) -> ListScoresResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all evaluation scores with pagination. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.list_scores( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.create_score(...) -> CreateScoreResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new evaluation score. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.create_score( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**evaluator_id:** `typing.Optional[str]` — UUID of evaluator created in Respan. Either this or `evaluator_slug` must be provided. + +
+
+ +
+
+ +**evaluator_slug:** `typing.Optional[str]` — Custom string identifier for your evaluator. Either this or `evaluator_id` must be provided. + +
+
+ +
+
+ +**numerical_value:** `typing.Optional[float]` — Numerical score value. Use when evaluator's `score_value_type` is `numerical`. + +
+
+ +
+
+ +**string_value:** `typing.Optional[str]` — String/text score value. Use when `score_value_type` is `text` or `comment`. + +
+
+ +
+
+ +**boolean_value:** `typing.Optional[bool]` — Boolean score value. Use when `score_value_type` is `boolean`. + +
+
+ +
+
+ +**categorical_value:** `typing.Optional[typing.List[str]]` — Categorical score value. Use when `score_value_type` is `single_select`, `multi_select`, or `categorical`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.retrieve_score(...) -> RetrieveScoreResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a specific score by ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.retrieve_score( + id="id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.delete_score(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an evaluation score. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.delete_score( + id="id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.update_score(...) -> UpdateScoreResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an existing score. Only provided fields are updated. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.update_score( + id="id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**numerical_value:** `typing.Optional[float]` — Numerical score value. Use when evaluator's `score_value_type` is `numerical`. + +
+
+ +
+
+ +**string_value:** `typing.Optional[str]` — String/text score value. Use when `score_value_type` is `text` or `comment`. + +
+
+ +
+
+ +**boolean_value:** `typing.Optional[bool]` — Boolean score value. Use when `score_value_type` is `boolean`. + +
+
+ +
+
+ +**categorical_value:** `typing.Optional[typing.List[str]]` — Categorical score value. Use when `score_value_type` is `single_select`, `multi_select`, or `categorical`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.list_span_scores(...) -> ListSpanScoresResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all scores for a specific span. Scores are automatically enriched with evaluator names when retrieving span details. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.list_span_scores( + log_id="log_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.log_scores_create_span_score(...) -> LogScoresCreateSpanScoreResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a score for a specific span. Only one score per evaluator per span is allowed. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.log_scores_create_span_score( + log_id="log_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**evaluator_id:** `typing.Optional[str]` — UUID of evaluator created in Respan. Either this or `evaluator_slug` must be provided. + +
+
+ +
+
+ +**evaluator_slug:** `typing.Optional[str]` — Custom string identifier for your evaluator. Either this or `evaluator_id` must be provided. + +
+
+ +
+
+ +**numerical_value:** `typing.Optional[float]` — Numerical score value. Use when evaluator's `score_value_type` is `numerical`. + +
+
+ +
+
+ +**string_value:** `typing.Optional[str]` — String/text score value. Use when `score_value_type` is `text` or `comment`. + +
+
+ +
+
+ +**boolean_value:** `typing.Optional[bool]` — Boolean score value. Use when `score_value_type` is `boolean`. + +
+
+ +
+
+ +**categorical_value:** `typing.Optional[typing.List[str]]` — Categorical score value. Use when `score_value_type` is `single_select`, `multi_select`, or `categorical`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.retrieve_span_score(...) -> RetrieveSpanScoreResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a specific score for a span. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.retrieve_span_score( + log_id="log_id", + score_id="score_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**score_id:** `str` — Score Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.delete_span_score(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a score from a span. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.delete_span_score( + log_id="log_id", + score_id="score_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**score_id:** `str` — Score Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.scores.update_span_score(...) -> UpdateSpanScoreResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a score for a specific span. Only provided fields are updated. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.scores.update_span_score( + log_id="log_id", + score_id="score_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**log_id:** `str` — Log Id + +
+
+ +
+
+ +**score_id:** `str` — Score Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**numerical_value:** `typing.Optional[float]` — Numerical score value. Use when evaluator's `score_value_type` is `numerical`. + +
+
+ +
+
+ +**string_value:** `typing.Optional[str]` — String/text score value. Use when `score_value_type` is `text` or `comment`. + +
+
+ +
+
+ +**boolean_value:** `typing.Optional[bool]` — Boolean score value. Use when `score_value_type` is `boolean`. + +
+
+ +
+
+ +**categorical_value:** `typing.Optional[typing.List[str]]` — Categorical score value. Use when `score_value_type` is `single_select`, `multi_select`, or `categorical`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Models +
client.models.list_models(...) -> typing.List[ListModelsResponseItem] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all available models including pricing, context window, and provider info. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.list_models( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.list_custom_models(...) -> typing.List[ListCustomModelsResponseItem] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all models accessible to your organization, including global models and custom models. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.list_custom_models( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**sort_by:** `typing.Optional[str]` — Field to sort by. + +
+
+ +
+
+ +**all:** `typing.Optional[bool]` — If true, returns all models without pagination. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.create_custom_model(...) -> CreateCustomModelResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new custom model or update an existing one (upsert by `model_name`). Custom models allow organization-specific configurations with custom pricing, capabilities, and provider associations. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.create_custom_model( + authorization="Bearer sk_live_xxxxx", + model_name="my-custom-gpt-4", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**model_name:** `str` — Unique model name. Used to reference the model in API calls. + +
+
+ +
+
+ +**base_model_name:** `typing.Optional[str]` — Base model to inherit properties from. + +
+
+ +
+
+ +**display_name:** `typing.Optional[str]` — Human-readable display name. + +
+
+ +
+
+ +**custom_provider_id:** `typing.Optional[str]` — ID of the custom provider to associate. + +
+
+ +
+
+ +**provider_id:** `typing.Optional[str]` — Alternative to `custom_provider_id`. + +
+
+ +
+
+ +**input_cost:** `typing.Optional[float]` — Cost per 1M input tokens (USD). + +
+
+ +
+
+ +**output_cost:** `typing.Optional[float]` — Cost per 1M output tokens (USD). + +
+
+ +
+
+ +**cache_hit_input_cost:** `typing.Optional[float]` — Cost per 1M cached input tokens (USD). + +
+
+ +
+
+ +**cache_creation_input_cost:** `typing.Optional[float]` — Cost per 1M cache creation tokens (USD). + +
+
+ +
+
+ +**max_context_window:** `typing.Optional[int]` — Maximum context window size. + +
+
+ +
+
+ +**streaming_support:** `typing.Optional[int]` — Streaming support. `0` = no, `1` = yes. + +
+
+ +
+
+ +**function_call:** `typing.Optional[int]` — Function calling support. `0` = no, `1` = yes. + +
+
+ +
+
+ +**image_support:** `typing.Optional[int]` — Image/vision support. `0` = no, `1` = yes. + +
+
+ +
+
+ +**supported_params_override:** `typing.Optional[typing.Dict[str, typing.Any]]` — Override UI parameter support for Playground. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.retrieve_custom_model(...) -> RetrieveCustomModelResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a model by name. Global models are accessible by anyone. Custom models are only accessible by the owning organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.retrieve_custom_model( + model_name="model_name", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**model_name:** `str` — The model's unique name. Can include slashes (e.g., openai/gpt-4). + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.delete_custom_model(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a custom model. Only custom models (`source: "db"`) can be deleted. This action is permanent. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.delete_custom_model( + model_name="model_name", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**model_name:** `str` — The model's unique name to delete. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.update_custom_model(...) -> UpdateCustomModelResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a custom model. Only provided fields are updated. The `model_name` field is read-only. Only the owning organization can update their custom models. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.update_custom_model( + model_name="model_name", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**model_name:** `str` — The model's unique name to update. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**display_name:** `typing.Optional[str]` — Display name. + +
+
+ +
+
+ +**base_model_name:** `typing.Optional[str]` — Base model. + +
+
+ +
+
+ +**custom_provider_id:** `typing.Optional[str]` — Custom provider ID. + +
+
+ +
+
+ +**input_cost:** `typing.Optional[float]` — Cost per 1M input tokens (USD). + +
+
+ +
+
+ +**output_cost:** `typing.Optional[float]` — Cost per 1M output tokens (USD). + +
+
+ +
+
+ +**cache_hit_input_cost:** `typing.Optional[float]` + +
+
+ +
+
+ +**cache_creation_input_cost:** `typing.Optional[float]` + +
+
+ +
+
+ +**max_context_window:** `typing.Optional[int]` + +
+
+ +
+
+ +**streaming_support:** `typing.Optional[int]` + +
+
+ +
+
+ +**function_call:** `typing.Optional[int]` + +
+
+ +
+
+ +**image_support:** `typing.Optional[int]` + +
+
+ +
+
+ +**supported_params_override:** `typing.Optional[typing.Dict[str, typing.Any]]` + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.list_custom_providers(...) -> typing.List[ListCustomProvidersResponseItem] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all custom providers. The `api_key` and `extra_kwargs` fields are write-only and never returned for security. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.list_custom_providers( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.create_custom_provider(...) -> CreateCustomProviderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new custom provider or update an existing one (upsert by `provider_id`). The `api_key` and `extra_kwargs` fields are write-only and never returned for security. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.create_custom_provider( + authorization="Bearer sk_live_xxxxx", + provider_id="my-azure-provider", + provider_name="My Azure Provider", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**provider_id:** `str` — Unique provider identifier. + +
+
+ +
+
+ +**provider_name:** `str` — Human-readable provider name. + +
+
+ +
+
+ +**api_key:** `typing.Optional[str]` — API key for the provider (write-only, never returned). + +
+
+ +
+
+ +**extra_kwargs:** `typing.Optional[typing.Dict[str, typing.Any]]` — Additional provider config (write-only). Common fields: `base_url`, `timeout`, `temperature`, `max_tokens`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.retrieve_custom_provider(...) -> RetrieveCustomProviderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve a custom provider by ID. Sensitive fields (`api_key`, `extra_kwargs`) are never returned. The `api_key` and `extra_kwargs` fields are write-only and never returned. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.retrieve_custom_provider( + provider_id=1, + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**provider_id:** `int` — The provider's primary key ID (numeric database ID). + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.delete_custom_provider(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete a custom provider. Managed providers cannot be deleted. Deleting a provider may affect models that reference it. This action is permanent. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.delete_custom_provider( + provider_id=1, + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**provider_id:** `int` — The provider's primary key ID to delete. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.models.update_custom_provider(...) -> UpdateCustomProviderResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update a custom provider. Only provided fields are updated. The `provider_id` is read-only. Managed providers cannot have critical fields modified. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.models.update_custom_provider( + provider_id=1, + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**provider_id:** `int` — The provider's primary key ID to update. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**provider_name:** `typing.Optional[str]` — Provider name. + +
+
+ +
+
+ +**api_key:** `typing.Optional[str]` — API key (write-only). + +
+
+ +
+
+ +**extra_kwargs:** `typing.Optional[typing.Dict[str, typing.Any]]` — Additional config (write-only). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Temporary API Keys +
client.temporary_api_keys.list_api_keys(...) -> typing.List[ListApiKeysResponseItem] +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List all API keys for your organization. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.temporary_api_keys.list_api_keys( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.temporary_api_keys.create_api_key(...) -> CreateApiKeyResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create a new API key. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.temporary_api_keys.create_api_key( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Key name. + +
+
+ +
+
+ +**expiry_date:** `typing.Optional[datetime.datetime]` — Expiry date (ISO 8601). + +
+
+ +
+
+ +**max_usage:** `typing.Optional[int]` — Max usage count. -1 = unlimited. + +
+
+ +
+
+ +**rate_limit:** `typing.Optional[int]` — Calls per minute. Overridden by plan limit. + +
+
+ +
+
+ +**spending_limit:** `typing.Optional[float]` — Spending limit in USD for gateway usage. + +
+
+ +
+
+ +**is_test:** `typing.Optional[bool]` — Test key (`true`) or production key (`false`). + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.temporary_api_keys.retrieve_api_key(...) -> RetrieveApiKeyResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve an API key by ID. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.temporary_api_keys.retrieve_api_key( + id="id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — The ID of the temporary API key to retrieve. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.temporary_api_keys.delete_api_key(...) +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Delete an API key. This action is irreversible. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.temporary_api_keys.delete_api_key( + id="id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — The ID of the temporary API key to delete. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.temporary_api_keys.update_api_key(...) -> UpdateApiKeyResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an API key's name, expiry, or test status. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.temporary_api_keys.update_api_key( + id="id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — The ID of the temporary API key to update. + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Key name. + +
+
+ +
+
+ +**expiry_date:** `typing.Optional[datetime.datetime]` — Expiry date (ISO 8601). + +
+
+ +
+
+ +**is_test:** `typing.Optional[bool]` — Test or production key. + +
+
+ +
+
+ +**prefix:** `typing.Optional[str]` — Key prefix. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Credit Transactions +
client.credit_transactions.credit_transactions_list(...) -> CreditTransactionsListResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List credit transactions with pagination. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.credit_transactions.credit_transactions_list( + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — Page number for pagination. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — Number of items per page. Maximum is 1000. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.credit_transactions.credit_transactions_retrieve(...) -> CreditTransactionsRetrieveResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Retrieve details of a specific credit transaction. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.credit_transactions.credit_transactions_retrieve( + id="id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**id:** `str` — The unique identifier of the transaction to retrieve (e.g., ct_1a2b3c4d5e6f7g8h) + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +## Automations +
client.automations.list_conditions(...) -> ListConditionsResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +List automation conditions with pagination and filtering. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.automations.list_conditions( + condition_type="single_log", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**page:** `typing.Optional[int]` — Page number. + +
+
+ +
+
+ +**page_size:** `typing.Optional[int]` — Results per page. + +
+
+ +
+
+ +**search:** `typing.Optional[str]` — Search conditions by name or slug. + +
+
+ +
+
+ +**condition_type:** `typing.Optional[str]` — Filter by condition type. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.automations.create_condition(...) -> CreateConditionResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create an automation condition that defines which spans should trigger evaluations. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +from respan.automations import CreateConditionRequestConditionPolicy, CreateConditionRequestConditionPolicyRulesItem + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.automations.create_condition( + authorization="Bearer sk_live_xxxxx", + name="Successful Requests", + condition_slug="success_logs", + condition_type="single_log", + condition_policy=CreateConditionRequestConditionPolicy( + rules=[ + CreateConditionRequestConditionPolicyRulesItem( + field="status_code", + operator="equals", + value=200, + ) + ], + connector="AND", + ), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**name:** `str` — Display name. + +
+
+ +
+
+ +**condition_slug:** `str` — Unique identifier. + +
+
+ +
+
+ +**condition_type:** `CreateConditionRequestConditionType` — Condition type. + +
+
+ +
+
+ +**condition_policy:** `CreateConditionRequestConditionPolicy` — Policy defining evaluation rules. + +
+
+ +
+
+ +**description:** `typing.Optional[str]` — Condition description. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.automations.create_automation(...) -> CreateAutomationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Create an online evaluation automation that automatically runs evaluators on spans matching specified conditions. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment +from respan.automations import CreateAutomationRequestConfiguration + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.automations.create_automation( + authorization="Bearer sk_live_xxxxx", + automation_slug="prod_quality_monitor", + name="Production Quality Monitor", + automation_type="online_eval", + condition="cond-12345", + evaluator_ids=[ + "eval-quality-uuid", + "eval-safety-uuid" + ], + configuration=CreateAutomationRequestConfiguration(), +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**automation_slug:** `str` — Unique identifier. + +
+
+ +
+
+ +**name:** `str` — Human-readable name. + +
+
+ +
+
+ +**automation_type:** `CreateAutomationRequestAutomationType` — Automation type. + +
+
+ +
+
+ +**condition:** `str` — Condition ID (from Create Condition endpoint). + +
+
+ +
+
+ +**evaluator_ids:** `typing.List[str]` — Evaluator UUIDs to run (from List Evaluators). + +
+
+ +
+
+ +**configuration:** `CreateAutomationRequestConfiguration` — Automation configuration. + +
+
+ +
+
+ +**is_enabled:** `typing.Optional[bool]` — Whether automation is active. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ +
client.automations.update_automation(...) -> UpdateAutomationResponse +
+
+ +#### 📝 Description + +
+
+ +
+
+ +Update an automation. Use to enable/disable, change sampling rate, or update evaluator list. Only provided fields are updated. +
+
+
+
+ +#### 🔌 Usage + +
+
+ +
+
+ +```python +from respan import RespanClient +from respan.environment import RespanClientEnvironment + +client = RespanClient( + environment=RespanClientEnvironment.DEFAULT, +) + +client.automations.update_automation( + automation_id="automation_id", + authorization="Bearer sk_live_xxxxx", +) + +``` +
+
+
+
+ +#### ⚙️ Parameters + +
+
+ +
+
+ +**automation_id:** `str` — Automation Id + +
+
+ +
+
+ +**authorization:** `str` — Bearer token. Use `Bearer YOUR_API_KEY`. + +
+
+ +
+
+ +**is_enabled:** `typing.Optional[bool]` — Enable or disable the automation. + +
+
+ +
+
+ +**configuration:** `typing.Optional[UpdateAutomationRequestConfiguration]` + +
+
+ +
+
+ +**evaluator_ids:** `typing.Optional[typing.List[str]]` — Updated evaluator UUIDs. + +
+
+ +
+
+ +**name:** `typing.Optional[str]` — Automation name. + +
+
+ +
+
+ +**request_options:** `typing.Optional[RequestOptions]` — Request-specific configuration. + +
+
+
+
+ + +
+
+
+ diff --git a/src/respan/automations/raw_client.py b/src/respan/automations/raw_client.py index c0740ff..ba08b23 100644 --- a/src/respan/automations/raw_client.py +++ b/src/respan/automations/raw_client.py @@ -7,6 +7,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -21,6 +22,7 @@ from .types.list_conditions_response import ListConditionsResponse from .types.update_automation_request_configuration import UpdateAutomationRequestConfiguration from .types.update_automation_response import UpdateAutomationResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -106,6 +108,10 @@ def list_conditions( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_condition( @@ -193,6 +199,10 @@ def create_condition( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_automation( @@ -290,6 +300,10 @@ def create_automation( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_automation( @@ -386,6 +400,10 @@ def update_automation( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -469,6 +487,10 @@ async def list_conditions( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_condition( @@ -556,6 +578,10 @@ async def create_condition( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_automation( @@ -653,6 +679,10 @@ async def create_automation( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_automation( @@ -749,4 +779,8 @@ async def update_automation( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/core/__init__.py b/src/respan/core/__init__.py index 587618b..2a2b56e 100644 --- a/src/respan/core/__init__.py +++ b/src/respan/core/__init__.py @@ -15,6 +15,7 @@ from .jsonable_encoder import jsonable_encoder from .logging import ConsoleLogger, ILogger, LogConfig, LogLevel, Logger, create_logger from .pagination import AsyncPager, SyncPager + from .parse_error import ParsingError from .pydantic_utilities import ( IS_PYDANTIC_V2, UniversalBaseModel, @@ -45,6 +46,7 @@ "LogConfig": ".logging", "LogLevel": ".logging", "Logger": ".logging", + "ParsingError": ".parse_error", "RequestOptions": ".request_options", "Rfc2822DateTime": ".datetime_utils", "SyncClientWrapper": ".client_wrapper", @@ -105,6 +107,7 @@ def __dir__(): "LogConfig", "LogLevel", "Logger", + "ParsingError", "RequestOptions", "Rfc2822DateTime", "SyncClientWrapper", diff --git a/src/respan/core/parse_error.py b/src/respan/core/parse_error.py new file mode 100644 index 0000000..4527c6a --- /dev/null +++ b/src/respan/core/parse_error.py @@ -0,0 +1,36 @@ +# This file was auto-generated by Fern from our API Definition. + +from typing import Any, Dict, Optional + + +class ParsingError(Exception): + """ + Raised when the SDK fails to parse/validate a response from the server. + This typically indicates that the server returned a response whose shape + does not match the expected schema. + """ + + headers: Optional[Dict[str, str]] + status_code: Optional[int] + body: Any + cause: Optional[Exception] + + def __init__( + self, + *, + headers: Optional[Dict[str, str]] = None, + status_code: Optional[int] = None, + body: Any = None, + cause: Optional[Exception] = None, + ) -> None: + self.headers = headers + self.status_code = status_code + self.body = body + self.cause = cause + super().__init__() + if cause is not None: + self.__cause__ = cause + + def __str__(self) -> str: + cause_str = f", cause: {self.cause}" if self.cause is not None else "" + return f"headers: {self.headers}, status_code: {self.status_code}, body: {self.body}{cause_str}" diff --git a/src/respan/core/pydantic_utilities.py b/src/respan/core/pydantic_utilities.py index 831aadc..fea3a08 100644 --- a/src/respan/core/pydantic_utilities.py +++ b/src/respan/core/pydantic_utilities.py @@ -26,6 +26,7 @@ import pydantic import typing_extensions +from pydantic.fields import FieldInfo as _FieldInfo _logger = logging.getLogger(__name__) @@ -35,8 +36,6 @@ IS_PYDANTIC_V2 = pydantic.VERSION.startswith("2.") if IS_PYDANTIC_V2: - import warnings - _datetime_adapter = pydantic.TypeAdapter(dt.datetime) # type: ignore[attr-defined] _date_adapter = pydantic.TypeAdapter(dt.date) # type: ignore[attr-defined] @@ -52,22 +51,80 @@ def parse_date(value: Any) -> dt.date: # type: ignore[misc] return value return _date_adapter.validate_python(value) - with warnings.catch_warnings(): - warnings.simplefilter("ignore", UserWarning) - from pydantic.v1.fields import ModelField as ModelField - from pydantic.v1.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore[attr-defined] - from pydantic.v1.typing import get_args as get_args - from pydantic.v1.typing import get_origin as get_origin - from pydantic.v1.typing import is_literal_type as is_literal_type - from pydantic.v1.typing import is_union as is_union + # Avoid importing from pydantic.v1 to maintain Python 3.14 compatibility. + from typing import get_args as get_args # type: ignore[assignment] + from typing import get_origin as get_origin # type: ignore[assignment] + + def is_literal_type(tp: Optional[Type[Any]]) -> bool: # type: ignore[misc] + return typing_extensions.get_origin(tp) is typing_extensions.Literal + + def is_union(tp: Optional[Type[Any]]) -> bool: # type: ignore[misc] + return tp is Union or typing_extensions.get_origin(tp) is Union # type: ignore[comparison-overlap] + + # Inline encoders_by_type to avoid importing from pydantic.v1.json + import re as _re + from collections import deque as _deque + from decimal import Decimal as _Decimal + from enum import Enum as _Enum + from ipaddress import ( + IPv4Address as _IPv4Address, + ) + from ipaddress import ( + IPv4Interface as _IPv4Interface, + ) + from ipaddress import ( + IPv4Network as _IPv4Network, + ) + from ipaddress import ( + IPv6Address as _IPv6Address, + ) + from ipaddress import ( + IPv6Interface as _IPv6Interface, + ) + from ipaddress import ( + IPv6Network as _IPv6Network, + ) + from pathlib import Path as _Path + from types import GeneratorType as _GeneratorType + from uuid import UUID as _UUID + + from pydantic.fields import FieldInfo as ModelField # type: ignore[no-redef, assignment] + + def _decimal_encoder(dec_value: Any) -> Any: + if dec_value.as_tuple().exponent >= 0: + return int(dec_value) + return float(dec_value) + + encoders_by_type: Dict[Type[Any], Callable[[Any], Any]] = { # type: ignore[no-redef] + bytes: lambda o: o.decode(), + dt.date: lambda o: o.isoformat(), + dt.datetime: lambda o: o.isoformat(), + dt.time: lambda o: o.isoformat(), + dt.timedelta: lambda td: td.total_seconds(), + _Decimal: _decimal_encoder, + _Enum: lambda o: o.value, + frozenset: list, + _deque: list, + _GeneratorType: list, + _IPv4Address: str, + _IPv4Interface: str, + _IPv4Network: str, + _IPv6Address: str, + _IPv6Interface: str, + _IPv6Network: str, + _Path: str, + _re.Pattern: lambda o: o.pattern, + set: list, + _UUID: str, + } else: from pydantic.datetime_parse import parse_date as parse_date # type: ignore[no-redef] from pydantic.datetime_parse import parse_datetime as parse_datetime # type: ignore[no-redef] - from pydantic.fields import ModelField as ModelField # type: ignore[attr-defined, no-redef] + from pydantic.fields import ModelField as ModelField # type: ignore[attr-defined, no-redef, assignment] from pydantic.json import ENCODERS_BY_TYPE as encoders_by_type # type: ignore[no-redef] from pydantic.typing import get_args as get_args # type: ignore[no-redef] from pydantic.typing import get_origin as get_origin # type: ignore[no-redef] - from pydantic.typing import is_literal_type as is_literal_type # type: ignore[no-redef] + from pydantic.typing import is_literal_type as is_literal_type # type: ignore[no-redef, assignment] from pydantic.typing import is_union as is_union # type: ignore[no-redef] from .datetime_utils import serialize_datetime @@ -554,7 +611,7 @@ def decorator(func: AnyCallable) -> AnyCallable: return decorator -PydanticField = Union[ModelField, pydantic.fields.FieldInfo] +PydanticField = Union[ModelField, _FieldInfo] def _get_model_fields(model: Type["Model"]) -> Mapping[str, PydanticField]: diff --git a/src/respan/credit_transactions/raw_client.py b/src/respan/credit_transactions/raw_client.py index 7f93a47..600a749 100644 --- a/src/respan/credit_transactions/raw_client.py +++ b/src/respan/credit_transactions/raw_client.py @@ -8,6 +8,7 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder from ..core.pagination import AsyncPager, SyncPager +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.not_found_error import NotFoundError @@ -15,6 +16,7 @@ from .types.credit_transactions_list_response import CreditTransactionsListResponse from .types.credit_transactions_list_response_results_item import CreditTransactionsListResponseResultsItem from .types.credit_transactions_retrieve_response import CreditTransactionsRetrieveResponse +from pydantic import ValidationError class RawCreditTransactionsClient: @@ -97,6 +99,10 @@ def credit_transactions_list( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def credit_transactions_retrieve( @@ -164,6 +170,10 @@ def credit_transactions_retrieve( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -250,6 +260,10 @@ async def _get_next(): _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def credit_transactions_retrieve( @@ -317,4 +331,8 @@ async def credit_transactions_retrieve( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/datasets/raw_client.py b/src/respan/datasets/raw_client.py index ead9271..18f7150 100644 --- a/src/respan/datasets/raw_client.py +++ b/src/respan/datasets/raw_client.py @@ -7,6 +7,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -26,6 +27,7 @@ from .types.run_eval_on_dataset_response import RunEvalOnDatasetResponse from .types.update_dataset_response import UpdateDatasetResponse from .types.update_span_partial_response import UpdateSpanPartialResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -89,6 +91,10 @@ def retrieve_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_dataset( @@ -137,6 +143,10 @@ def delete_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_dataset( @@ -211,6 +221,10 @@ def update_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_dataset( @@ -306,6 +320,10 @@ def create_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_datasets( @@ -384,6 +402,10 @@ def list_datasets( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def listspanswithfilters( @@ -454,6 +476,10 @@ def listspanswithfilters( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_dataset_span( @@ -538,6 +564,10 @@ def create_dataset_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrievespan( @@ -602,6 +632,10 @@ def retrievespan( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_span( @@ -658,6 +692,10 @@ def delete_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_span_partial( @@ -728,6 +766,10 @@ def update_span_partial( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_spans( @@ -825,6 +867,10 @@ def delete_spans( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def add_spans_to_dataset( @@ -894,6 +940,10 @@ def add_spans_to_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def run_eval_on_dataset( @@ -963,6 +1013,10 @@ def run_eval_on_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_eval_runs( @@ -1019,6 +1073,10 @@ def list_eval_runs( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -1080,6 +1138,10 @@ async def retrieve_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_dataset( @@ -1128,6 +1190,10 @@ async def delete_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_dataset( @@ -1202,6 +1268,10 @@ async def update_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_dataset( @@ -1297,6 +1367,10 @@ async def create_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_datasets( @@ -1375,6 +1449,10 @@ async def list_datasets( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def listspanswithfilters( @@ -1445,6 +1523,10 @@ async def listspanswithfilters( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_dataset_span( @@ -1529,6 +1611,10 @@ async def create_dataset_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrievespan( @@ -1593,6 +1679,10 @@ async def retrievespan( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_span( @@ -1649,6 +1739,10 @@ async def delete_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_span_partial( @@ -1719,6 +1813,10 @@ async def update_span_partial( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_spans( @@ -1816,6 +1914,10 @@ async def delete_spans( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def add_spans_to_dataset( @@ -1885,6 +1987,10 @@ async def add_spans_to_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def run_eval_on_dataset( @@ -1954,6 +2060,10 @@ async def run_eval_on_dataset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_eval_runs( @@ -2010,4 +2120,8 @@ async def list_eval_runs( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/evaluators/raw_client.py b/src/respan/evaluators/raw_client.py index efe7d8f..ab32647 100644 --- a/src/respan/evaluators/raw_client.py +++ b/src/respan/evaluators/raw_client.py @@ -7,6 +7,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -27,6 +28,7 @@ from .types.run_evaluator_response import RunEvaluatorResponse from .types.update_evaluator_request_score_value_type import UpdateEvaluatorRequestScoreValueType from .types.update_evaluator_response import UpdateEvaluatorResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -166,6 +168,10 @@ def create_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_evaluator( @@ -222,6 +228,10 @@ def retrieve_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_evaluator( @@ -281,6 +291,10 @@ def delete_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_evaluator( @@ -387,6 +401,10 @@ def update_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def run_evaluator( @@ -461,6 +479,10 @@ def run_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_evaluators( @@ -527,6 +549,10 @@ def list_evaluators( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -664,6 +690,10 @@ async def create_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_evaluator( @@ -720,6 +750,10 @@ async def retrieve_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_evaluator( @@ -779,6 +813,10 @@ async def delete_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_evaluator( @@ -885,6 +923,10 @@ async def update_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def run_evaluator( @@ -959,6 +1001,10 @@ async def run_evaluator( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_evaluators( @@ -1025,4 +1071,8 @@ async def list_evaluators( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/experiments/raw_client.py b/src/respan/experiments/raw_client.py index ae1a2ff..5f8b94d 100644 --- a/src/respan/experiments/raw_client.py +++ b/src/respan/experiments/raw_client.py @@ -8,6 +8,7 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder from ..core.pagination import AsyncPager, SyncPager +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -16,6 +17,7 @@ from .types.create_experiment_request_workflows_item import CreateExperimentRequestWorkflowsItem from .types.create_experiment_response import CreateExperimentResponse from .types.export_experiment_spans_response import ExportExperimentSpansResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -112,6 +114,10 @@ def create_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def search_experiment( @@ -178,6 +184,10 @@ def search_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_experiment( @@ -234,6 +244,10 @@ def retrieve_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_experiment( @@ -282,6 +296,10 @@ def delete_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def search_experiment_spans( @@ -352,6 +370,10 @@ def search_experiment_spans( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_experiment_span( @@ -416,6 +438,10 @@ def retrieve_experiment_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_experiment_span( @@ -486,6 +512,10 @@ def update_experiment_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def get_experiment_spans_summary( @@ -558,6 +588,10 @@ def get_experiment_spans_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def export_experiment_spans( @@ -665,6 +699,10 @@ def export_experiment_spans( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -759,6 +797,10 @@ async def create_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def search_experiment( @@ -825,6 +867,10 @@ async def search_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_experiment( @@ -881,6 +927,10 @@ async def retrieve_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_experiment( @@ -929,6 +979,10 @@ async def delete_experiment( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def search_experiment_spans( @@ -999,6 +1053,10 @@ async def search_experiment_spans( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_experiment_span( @@ -1063,6 +1121,10 @@ async def retrieve_experiment_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_experiment_span( @@ -1133,6 +1195,10 @@ async def update_experiment_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def get_experiment_spans_summary( @@ -1205,6 +1271,10 @@ async def get_experiment_spans_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def export_experiment_spans( @@ -1315,4 +1385,8 @@ async def _get_next(): _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/gateway/raw_client.py b/src/respan/gateway/raw_client.py index 2b86ac1..26d8528 100644 --- a/src/respan/gateway/raw_client.py +++ b/src/respan/gateway/raw_client.py @@ -6,6 +6,7 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -13,6 +14,7 @@ from ..errors.unauthorized_error import UnauthorizedError from .types.create_chat_completion_response import CreateChatCompletionResponse from .types.create_response_request_input import CreateResponseRequestInput +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -324,6 +326,10 @@ def create_chat_completion( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_response( @@ -544,6 +550,10 @@ def create_response( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -853,6 +863,10 @@ async def create_chat_completion( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_response( @@ -1073,4 +1087,8 @@ async def create_response( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/health/raw_client.py b/src/respan/health/raw_client.py index f623a77..00dacfa 100644 --- a/src/respan/health/raw_client.py +++ b/src/respan/health/raw_client.py @@ -6,11 +6,13 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.service_unavailable_error import ServiceUnavailableError from ..types.service_unavailable_error_body import ServiceUnavailableErrorBody from .types.health_check_response import HealthCheckResponse +from pydantic import ValidationError class RawHealthClient: @@ -68,6 +70,10 @@ def check( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -126,4 +132,8 @@ async def check( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/models/raw_client.py b/src/respan/models/raw_client.py index 7621d35..acad7ad 100644 --- a/src/respan/models/raw_client.py +++ b/src/respan/models/raw_client.py @@ -7,6 +7,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.bad_request_error import BadRequestError @@ -21,6 +22,7 @@ from .types.retrieve_custom_provider_response import RetrieveCustomProviderResponse from .types.update_custom_model_response import UpdateCustomModelResponse from .types.update_custom_provider_response import UpdateCustomProviderResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -81,6 +83,10 @@ def list_models( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_custom_models( @@ -149,6 +155,10 @@ def list_custom_models( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_custom_model( @@ -290,6 +300,10 @@ def create_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_custom_model( @@ -357,6 +371,10 @@ def retrieve_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_custom_model( @@ -416,6 +434,10 @@ def delete_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_custom_model( @@ -544,6 +566,10 @@ def update_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_custom_providers( @@ -597,6 +623,10 @@ def list_custom_providers( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_custom_provider( @@ -677,6 +707,10 @@ def create_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_custom_provider( @@ -744,6 +778,10 @@ def retrieve_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_custom_provider( @@ -803,6 +841,10 @@ def delete_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_custom_provider( @@ -893,6 +935,10 @@ def update_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -951,6 +997,10 @@ async def list_models( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_custom_models( @@ -1019,6 +1069,10 @@ async def list_custom_models( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_custom_model( @@ -1160,6 +1214,10 @@ async def create_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_custom_model( @@ -1227,6 +1285,10 @@ async def retrieve_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_custom_model( @@ -1286,6 +1348,10 @@ async def delete_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_custom_model( @@ -1414,6 +1480,10 @@ async def update_custom_model( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_custom_providers( @@ -1467,6 +1537,10 @@ async def list_custom_providers( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_custom_provider( @@ -1547,6 +1621,10 @@ async def create_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_custom_provider( @@ -1614,6 +1692,10 @@ async def retrieve_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_custom_provider( @@ -1673,6 +1755,10 @@ async def delete_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_custom_provider( @@ -1763,4 +1849,8 @@ async def update_custom_provider( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/multimodal/raw_client.py b/src/respan/multimodal/raw_client.py index 08068a2..c42dfd5 100644 --- a/src/respan/multimodal/raw_client.py +++ b/src/respan/multimodal/raw_client.py @@ -10,6 +10,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.not_found_error import NotFoundError @@ -24,6 +25,7 @@ from .types.text_to_speech_request_model import TextToSpeechRequestModel from .types.text_to_speech_request_response_format import TextToSpeechRequestResponseFormat from .types.text_to_speech_request_voice import TextToSpeechRequestVoice +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -145,6 +147,10 @@ def embeddings( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def speech_to_text( @@ -277,6 +283,10 @@ def speech_to_text( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @contextlib.contextmanager @@ -399,6 +409,13 @@ def _stream() -> HttpResponse[typing.Iterator[bytes]]: raise ApiError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.text ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response.json(), + cause=e, + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) yield _stream() @@ -477,6 +494,10 @@ def assemblyai_integration( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -596,6 +617,10 @@ async def embeddings( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def speech_to_text( @@ -728,6 +753,10 @@ async def speech_to_text( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @contextlib.asynccontextmanager @@ -851,6 +880,13 @@ async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: raise ApiError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.text ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response.json(), + cause=e, + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) yield await _stream() @@ -929,4 +965,8 @@ async def assemblyai_integration( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/open_ai_batch/raw_client.py b/src/respan/open_ai_batch/raw_client.py index 875f1e2..a052fc6 100644 --- a/src/respan/open_ai_batch/raw_client.py +++ b/src/respan/open_ai_batch/raw_client.py @@ -9,6 +9,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.not_found_error import NotFoundError @@ -24,6 +25,7 @@ from .types.retrieve_file_response import RetrieveFileResponse from .types.upload_file_request_purpose import UploadFileRequestPurpose from .types.upload_file_response import UploadFileResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -84,6 +86,10 @@ def list_files( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def upload_file( @@ -156,6 +162,10 @@ def upload_file( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_file( @@ -223,6 +233,10 @@ def retrieve_file( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_file( @@ -290,6 +304,10 @@ def delete_file( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @contextlib.contextmanager @@ -359,6 +377,13 @@ def _stream() -> HttpResponse[typing.Iterator[bytes]]: raise ApiError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.text ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response.json(), + cause=e, + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) yield _stream() @@ -429,6 +454,10 @@ def list_batches( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_batch( @@ -529,6 +558,10 @@ def create_batch( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_batch( @@ -596,6 +629,10 @@ def retrieve_batch( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def cancel_batch( @@ -673,6 +710,10 @@ def cancel_batch( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -731,6 +772,10 @@ async def list_files( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def upload_file( @@ -803,6 +848,10 @@ async def upload_file( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_file( @@ -870,6 +919,10 @@ async def retrieve_file( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_file( @@ -937,6 +990,10 @@ async def delete_file( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @contextlib.asynccontextmanager @@ -1007,6 +1064,13 @@ async def _stream() -> AsyncHttpResponse[typing.AsyncIterator[bytes]]: raise ApiError( status_code=_response.status_code, headers=dict(_response.headers), body=_response.text ) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, + headers=dict(_response.headers), + body=_response.json(), + cause=e, + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) yield await _stream() @@ -1077,6 +1141,10 @@ async def list_batches( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_batch( @@ -1177,6 +1245,10 @@ async def create_batch( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_batch( @@ -1244,6 +1316,10 @@ async def retrieve_batch( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def cancel_batch( @@ -1321,4 +1397,8 @@ async def cancel_batch( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/prompts/raw_client.py b/src/respan/prompts/raw_client.py index 9387076..9beaa7b 100644 --- a/src/respan/prompts/raw_client.py +++ b/src/respan/prompts/raw_client.py @@ -7,6 +7,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -20,6 +21,7 @@ from .types.list_prompts_request_sort_by import ListPromptsRequestSortBy from .types.list_prompts_response import ListPromptsResponse from .types.update_prompt_version_response import UpdatePromptVersionResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -111,6 +113,10 @@ def list_prompts( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_prompt( @@ -181,6 +187,10 @@ def create_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_prompt( @@ -248,6 +258,10 @@ def retrieve_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_prompt( @@ -307,6 +321,10 @@ def delete_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_prompt( @@ -392,6 +410,10 @@ def update_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_versions( @@ -459,6 +481,10 @@ def retrieve_versions( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_version( @@ -599,6 +625,10 @@ def create_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_prompt_version( @@ -674,6 +704,10 @@ def retrieve_prompt_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_version( @@ -741,6 +775,10 @@ def delete_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_prompt_version( @@ -885,6 +923,10 @@ def update_prompt_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def commit_draft_version( @@ -976,6 +1018,10 @@ def commit_draft_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def deploy_committed_version( @@ -1067,6 +1113,10 @@ def deploy_committed_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def get_prompts_summary( @@ -1131,6 +1181,10 @@ def get_prompts_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def get_prompts_summary_with_filters( @@ -1197,6 +1251,10 @@ def get_prompts_summary_with_filters( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -1286,6 +1344,10 @@ async def list_prompts( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_prompt( @@ -1356,6 +1418,10 @@ async def create_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_prompt( @@ -1423,6 +1489,10 @@ async def retrieve_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_prompt( @@ -1482,6 +1552,10 @@ async def delete_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_prompt( @@ -1567,6 +1641,10 @@ async def update_prompt( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_versions( @@ -1634,6 +1712,10 @@ async def retrieve_versions( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_version( @@ -1774,6 +1856,10 @@ async def create_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_prompt_version( @@ -1849,6 +1935,10 @@ async def retrieve_prompt_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_version( @@ -1916,6 +2006,10 @@ async def delete_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_prompt_version( @@ -2060,6 +2154,10 @@ async def update_prompt_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def commit_draft_version( @@ -2151,6 +2249,10 @@ async def commit_draft_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def deploy_committed_version( @@ -2242,6 +2344,10 @@ async def deploy_committed_version( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def get_prompts_summary( @@ -2306,6 +2412,10 @@ async def get_prompts_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def get_prompts_summary_with_filters( @@ -2372,4 +2482,8 @@ async def get_prompts_summary_with_filters( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/scores/raw_client.py b/src/respan/scores/raw_client.py index bde710d..3091c78 100644 --- a/src/respan/scores/raw_client.py +++ b/src/respan/scores/raw_client.py @@ -7,6 +7,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.conflict_error import ConflictError @@ -21,6 +22,7 @@ from .types.retrieve_span_score_response import RetrieveSpanScoreResponse from .types.update_score_response import UpdateScoreResponse from .types.update_span_score_response import UpdateSpanScoreResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -81,6 +83,10 @@ def list_scores( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_score( @@ -171,6 +177,10 @@ def create_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_score( @@ -238,6 +248,10 @@ def retrieve_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_score( @@ -297,6 +311,10 @@ def delete_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_score( @@ -392,6 +410,10 @@ def update_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_span_scores( @@ -459,6 +481,10 @@ def list_span_scores( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def log_scores_create_span_score( @@ -575,6 +601,10 @@ def log_scores_create_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_span_score( @@ -645,6 +675,10 @@ def retrieve_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_span_score( @@ -707,6 +741,10 @@ def delete_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_span_score( @@ -806,6 +844,10 @@ def update_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -864,6 +906,10 @@ async def list_scores( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_score( @@ -954,6 +1000,10 @@ async def create_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_score( @@ -1021,6 +1071,10 @@ async def retrieve_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_score( @@ -1080,6 +1134,10 @@ async def delete_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_score( @@ -1175,6 +1233,10 @@ async def update_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_span_scores( @@ -1242,6 +1304,10 @@ async def list_span_scores( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def log_scores_create_span_score( @@ -1358,6 +1424,10 @@ async def log_scores_create_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_span_score( @@ -1428,6 +1498,10 @@ async def retrieve_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_span_score( @@ -1490,6 +1564,10 @@ async def delete_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_span_score( @@ -1589,4 +1667,8 @@ async def update_span_score( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/spans/raw_client.py b/src/respan/spans/raw_client.py index eafa891..3938ad3 100644 --- a/src/respan/spans/raw_client.py +++ b/src/respan/spans/raw_client.py @@ -10,6 +10,7 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder from ..core.pagination import AsyncPager, SyncPager +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -34,6 +35,7 @@ from .types.list_spans_request_operator import ListSpansRequestOperator from .types.list_spans_response import ListSpansResponse from .types.retrieve_span_response import RetrieveSpanResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -374,6 +376,10 @@ def create_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_spans( @@ -550,6 +556,10 @@ def list_spans( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_span( @@ -650,6 +660,10 @@ def retrieve_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def patch_log_span( @@ -770,6 +784,10 @@ def patch_log_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def get_spans_summary( @@ -886,6 +904,10 @@ def get_spans_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def ingest_spans_from_traces( @@ -950,6 +972,10 @@ def ingest_spans_from_traces( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -1288,6 +1314,10 @@ async def create_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_spans( @@ -1467,6 +1497,10 @@ async def _get_next(): _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_span( @@ -1567,6 +1601,10 @@ async def retrieve_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def patch_log_span( @@ -1687,6 +1725,10 @@ async def patch_log_span( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def get_spans_summary( @@ -1803,6 +1845,10 @@ async def get_spans_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def ingest_spans_from_traces( @@ -1867,4 +1913,8 @@ async def ingest_spans_from_traces( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/temporary_api_keys/raw_client.py b/src/respan/temporary_api_keys/raw_client.py index dcba6a2..13e82a1 100644 --- a/src/respan/temporary_api_keys/raw_client.py +++ b/src/respan/temporary_api_keys/raw_client.py @@ -8,6 +8,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..errors.not_found_error import NotFoundError @@ -16,6 +17,7 @@ from .types.list_api_keys_response_item import ListApiKeysResponseItem from .types.retrieve_api_key_response import RetrieveApiKeyResponse from .types.update_api_key_response import UpdateApiKeyResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -76,6 +78,10 @@ def list_api_keys( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_api_key( @@ -166,6 +172,10 @@ def create_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_api_key( @@ -233,6 +243,10 @@ def retrieve_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_api_key( @@ -292,6 +306,10 @@ def delete_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_api_key( @@ -387,6 +405,10 @@ def update_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -445,6 +467,10 @@ async def list_api_keys( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_api_key( @@ -535,6 +561,10 @@ async def create_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_api_key( @@ -602,6 +632,10 @@ async def retrieve_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_api_key( @@ -661,6 +695,10 @@ async def delete_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_api_key( @@ -756,4 +794,8 @@ async def update_api_key( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/testsets/raw_client.py b/src/respan/testsets/raw_client.py index 63ab7e6..d60407e 100644 --- a/src/respan/testsets/raw_client.py +++ b/src/respan/testsets/raw_client.py @@ -7,6 +7,7 @@ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -21,6 +22,7 @@ from .types.retrieve_testset_response import RetrieveTestsetResponse from .types.update_testset_response import UpdateTestsetResponse from .types.update_testset_row_response import UpdateTestsetRowResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -112,6 +114,10 @@ def create_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_testsets( @@ -177,6 +183,10 @@ def list_testsets( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_testset( @@ -244,6 +254,10 @@ def retrieve_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_testset( @@ -303,6 +317,10 @@ def delete_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_testset( @@ -393,6 +411,10 @@ def update_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list_testset_rows( @@ -460,6 +482,10 @@ def list_testset_rows( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def create_testset_rows( @@ -539,6 +565,10 @@ def create_testset_rows( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_testset_row( @@ -606,6 +636,10 @@ def delete_testset_row( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_testset_row( @@ -690,6 +724,10 @@ def update_testset_row( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -779,6 +817,10 @@ async def create_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_testsets( @@ -844,6 +886,10 @@ async def list_testsets( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_testset( @@ -911,6 +957,10 @@ async def retrieve_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_testset( @@ -970,6 +1020,10 @@ async def delete_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_testset( @@ -1060,6 +1114,10 @@ async def update_testset( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list_testset_rows( @@ -1127,6 +1185,10 @@ async def list_testset_rows( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def create_testset_rows( @@ -1206,6 +1268,10 @@ async def create_testset_rows( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_testset_row( @@ -1273,6 +1339,10 @@ async def delete_testset_row( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_testset_row( @@ -1357,4 +1427,8 @@ async def update_testset_row( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/threads/raw_client.py b/src/respan/threads/raw_client.py index 2ad8e14..738fffb 100644 --- a/src/respan/threads/raw_client.py +++ b/src/respan/threads/raw_client.py @@ -6,6 +6,7 @@ from ..core.api_error import ApiError from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper from ..core.pagination import AsyncPager, SyncPager +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -14,6 +15,7 @@ from .types.threads_list_request_operator import ThreadsListRequestOperator from .types.threads_list_response import ThreadsListResponse from .types.threads_list_response_results_item import ThreadsListResponseResultsItem +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -123,6 +125,10 @@ def list( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -233,4 +239,8 @@ async def _get_next(): _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/traces/raw_client.py b/src/respan/traces/raw_client.py index 84190f1..17c0657 100644 --- a/src/respan/traces/raw_client.py +++ b/src/respan/traces/raw_client.py @@ -9,6 +9,7 @@ from ..core.datetime_utils import serialize_datetime from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -26,6 +27,7 @@ from .types.retrieve_traces_summary_response import RetrieveTracesSummaryResponse from .types.traces_list_request_operator import TracesListRequestOperator from .types.traces_list_response import TracesListResponse +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -115,6 +117,10 @@ def ingest_traces_via_otlp( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def list( @@ -251,6 +257,10 @@ def list( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_trace( @@ -372,6 +382,10 @@ def retrieve_trace( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_trace( @@ -447,6 +461,10 @@ def delete_trace( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_traces_summary( @@ -563,6 +581,10 @@ def retrieve_traces_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def bulk_delete_traces( @@ -679,6 +701,10 @@ def bulk_delete_traces( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def ingest_traces_from_logs( @@ -776,6 +802,10 @@ def ingest_traces_from_logs( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -863,6 +893,10 @@ async def ingest_traces_via_otlp( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def list( @@ -999,6 +1033,10 @@ async def list( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_trace( @@ -1120,6 +1158,10 @@ async def retrieve_trace( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_trace( @@ -1195,6 +1237,10 @@ async def delete_trace( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_traces_summary( @@ -1311,6 +1357,10 @@ async def retrieve_traces_summary( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def bulk_delete_traces( @@ -1427,6 +1477,10 @@ async def bulk_delete_traces( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def ingest_traces_from_logs( @@ -1524,4 +1578,8 @@ async def ingest_traces_from_logs( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) diff --git a/src/respan/users/raw_client.py b/src/respan/users/raw_client.py index 04ad115..453186b 100644 --- a/src/respan/users/raw_client.py +++ b/src/respan/users/raw_client.py @@ -8,6 +8,7 @@ from ..core.http_response import AsyncHttpResponse, HttpResponse from ..core.jsonable_encoder import jsonable_encoder from ..core.pagination import AsyncPager, SyncPager +from ..core.parse_error import ParsingError from ..core.pydantic_utilities import parse_obj_as from ..core.request_options import RequestOptions from ..core.serialization import convert_and_respect_annotation_metadata @@ -21,6 +22,7 @@ from .types.users_search_request_filters import UsersSearchRequestFilters from .types.users_search_response import UsersSearchResponse from .types.users_search_response_results_item import UsersSearchResponseResultsItem +from pydantic import ValidationError # this is used as the default value for optional parameters OMIT = typing.cast(typing.Any, ...) @@ -152,6 +154,10 @@ def search( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def retrieve_user( @@ -241,6 +247,10 @@ def retrieve_user( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def delete_user( @@ -322,6 +332,10 @@ def delete_user( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) def update_user( @@ -443,6 +457,10 @@ def update_user( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) @@ -575,6 +593,10 @@ async def _get_next(): _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def retrieve_user( @@ -664,6 +686,10 @@ async def retrieve_user( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def delete_user( @@ -745,6 +771,10 @@ async def delete_user( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json) async def update_user( @@ -866,4 +896,8 @@ async def update_user( _response_json = _response.json() except JSONDecodeError: raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text) + except ValidationError as e: + raise ParsingError( + status_code=_response.status_code, headers=dict(_response.headers), body=_response.json(), cause=e + ) raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)