---
updatedAt: 2026-09-18T18:57:57.000Z
agentTools:
  projectIndex: https://docs.ascerta.com/llms.txt
---

# Handling Requests

## Overview

Regardless of which [technical approach](/docs/operational-modes) you're using, you'll need to implement appropriate logic for processing both successful and failed responses from your GenAI requests. This section focuses on understanding these responses and implementing robust handling for all scenarios.

While handling the basic provider responses is required, handling the Ascerta specific objects (**`xproxy_result`** for successful responses and **`xproxy_error`** for errors) is optional and only necessary if you want to implement business logic that depends on the metrics provided by Ascerta. The availability of these objects varies based on your integration method, as detailed in the following guides.

## Handling Successful Requests

[Handling Successful Requests](/docs/handling-successes) covers how to work with the **`xproxy_result`** object that's returned when requests complete successfully. This guide explains:

* Where the **`xproxy_result`** object appears in different contexts: [Direct Provider Call with Telemetry](/docs/operational-modes#1-direct-provider-call-with-telemetry) and streaming vs. synchronous requests)
* How to interpret cost and limit information contained in the result
* The structure differences between successful and failed requests
* Examples of successful request responses with detailed explanation

The **`xproxy_result`** object provides essential information about your request's execution, including cost calculations and limit status.

Learn more in the [Handling Successful Requests](/docs/handling-successes) guide.

## Handling Failed Requests

[Handling Errors](/docs/handling-errors) explains the structure of error responses when Ascerta returns HTTP 4xx status codes. This guide covers:

* The standard error response properties (`statusCode` and `message`)
* The optional `xproxy_error` and `xproxy_result` properties
* How these properties help diagnose different types of failures
* Examples of error responses with detailed explanation
* How <Glossary>Provider</Glossary> errors are combined with Ascerta's error information

Understanding these error structures is essential for implementing robust error handling in your application.

Learn more in the [Handling Errors](/docs/handling-errors) guide.

## Best Practices

When implementing request handling with Ascerta:

* Always implement proper error handling with appropriate fallbacks
* Consider both GenAI provider errors and Ascerta-specific errors
* For production applications, implement retry logic with exponential backoff
* Monitor error rates to identify potential issues early
* Use [Limit Details](/docs/handling-budget-responses) to handle budget/limit-related responses

By understanding both successful and error response handling, you'll create more robust GenAI applications that can gracefully handle the various conditions that arise in production environments.