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

# Error Handling

> Understanding and handling errors in Stelis API responses

When using the Stelis API, you may encounter errors. This guide will help you understand and handle these errors effectively.

## Error Response Format

When an error occurs, Stelis returns a JSON response with an error object:

```json theme={null}
{
  "error": {
    "code": "invalid_request",
    "message": "The request was unacceptable, often due to missing a required parameter.",
    "details": {
      "missing_param": "url"
    }
  }
}
```

## Common Error Codes

| Code                   | Description                                                              |
| ---------------------- | ------------------------------------------------------------------------ |
| `invalid_request`      | The request was unacceptable, often due to missing a required parameter. |
| `authentication_error` | No valid API key provided.                                               |
| `permission_denied`    | The API key doesn't have permissions to perform the request.             |
| `rate_limit_exceeded`  | Too many requests hit the API too quickly.                               |
| `not_found`            | The requested resource doesn't exist.                                    |
| `internal_error`       | Something went wrong on Stelis's end.                                    |

## Handling Errors

When working with the Stelis API, always implement proper error handling:

```javascript theme={null}
try {
  const result = await stelis.browse({
    prompt: "Search for wireless headphones on Amazon"
  });
  // Handle successful response
} catch (error) {
  if (error.response) {
    console.error(`API error: ${error.response.data.error.message}`);
    // Handle specific error cases based on error.response.data.error.code
  } else {
    console.error(`Network error: ${error.message}`);
  }
}
```

## Best Practices

* Always check for and handle potential errors in your API requests
* Implement appropriate retry logic for transient errors
* Log errors for debugging and monitoring purposes
* Provide clear error messages to your users when appropriate

For more detailed information on specific error codes and their meanings, please refer to our [API Documentation](https://docs.stelis.app/api#errors).
