Skip to main content
OpenRouter provides a debug option that allows you to inspect the exact request body that was sent to the upstream provider. This works with both the Chat Completions API (/api/v1/chat/completions) and the Responses API (/api/v1/responses). Useful for understanding how OpenRouter transforms your request parameters for different providers.

Debug option shape

The debug option is an object with the following shape:

Usage

To enable debug output, include the debug parameter in your request:

Chat Completions

Output

Responses API

Output

Debug response format

Chat Completions

When debug.echo_upstream_body is set to true, OpenRouter sends a debug chunk as the first chunk in the streaming response. This chunk has an empty choices array and includes a debug field with the transformed request body:

Responses API

On the Responses API, debug data arrives as a response.debug SSE event:

Important notes

Streaming OnlyThe debug option only works with streaming mode (stream: true). Non-streaming requests will ignore the debug parameter.
Not for ProductionThe debug flag should not be used in production environments. It is intended for development and debugging purposes only, as it may potentially return sensitive information included in the request that was not intended to be visible elsewhere.

Use cases

The debug output is particularly useful for:
  1. Understanding Parameter Transformations: See how OpenRouter maps your parameters to provider-specific formats (e.g., how max_tokens is set, how temperature is handled).
  2. Verifying Message Formatting: Check how OpenRouter combines and formats your messages for different providers (e.g., how system messages are concatenated, how user messages are merged).
  3. Checking Applied Defaults: See what default values OpenRouter applies when parameters are not specified in your request.
  4. Debugging Provider Fallbacks: When using provider fallbacks, a debug chunk will be sent for each attempted provider, allowing you to see which providers were tried and what parameters were sent to each.

Privacy and redaction

OpenRouter will make a best effort to automatically redact potentially sensitive or noisy data from debug output. Remember that the debug option is not intended for production. For error response shapes and codes, see Errors and Debugging.