Where is usage reported for a non-streamed Brave Answers request?

The Citead team, updated

In short. Read the documented X-Request usage fields from the response headers when Brave Answers returns a non-streamed response.

Definition: For a non-streamed Brave Answers request, the usage metadata documented by Brave is returned in the HTTP response headers. The documented header keys report request, query, token and cost values for the completed answer.

Key facts

  • Brave's Answers service guide shows stream=False in its basic request example.
  • The same guide says that streaming places usage metadata in the last message and that synchronous requests include the keys in response headers.
  • The documented metadata names include X-Request-Requests, X-Request-Queries, X-Request-Tokens-In, X-Request-Tokens-Out and X-Request-Total-Cost.
  • Brave's Answers API reference documents POST /v1/chat/completions and sets stream to true by default.
  • Brave's rate limiting guide says every API response includes headers for tracking rate limits.

Which request produces a synchronous response?

The Answers endpoint is OpenAI-compatible. Brave's service guide gives this endpoint:

https://api.search.brave.com/res/v1/chat/completions

Its basic Python example passes stream=False. The API reference describes the operation as POST /v1/chat/completions. Because that reference lists stream with a default of true, a client that needs a complete response before reading the result should set it explicitly to false.

The service guide's cURL example also sends a JSON request with "stream": false and authenticates with the x-subscription-token header. The response is therefore read as one completed HTTP response, including its headers.

Which headers contain the usage values?

Brave's service guide provides this usage metadata example:

{
  "X-Request-Requests": 1,
  "X-Request-Queries": 2,
  "X-Request-Tokens-In": 1234,
  "X-Request-Tokens-Out": 300,
  "X-Request-Requests-Cost": 0,
  "X-Request-Queries-Cost": 0.008,
  "X-Request-Tokens-In-Cost": 0.00617,
  "X-Request-Tokens-Out-Cost": 0.0015,
  "X-Request-Total-Cost": 0.01567
}

For a synchronous request, read the X-Request-* values from the HTTP response headers. They describe the number of API requests and search queries, input and output tokens, and the corresponding costs. The same documentation places this metadata in the last message when the request uses streaming, so the two response modes expose the information at different points in the response handling path.

How do rate limit headers relate to usage headers?

Rate limit headers are a separate group. Brave's rate limiting guide names X-RateLimit-Limit, X-RateLimit-Policy, X-RateLimit-Remaining and X-RateLimit-Reset. It describes X-RateLimit-Remaining as the quota left in each limit window and X-RateLimit-Reset as the seconds until those windows reset.

The same guide says rate limits use a 1-second sliding window and that an exceeded limit returns HTTP 429. A client can therefore inspect both groups after a synchronous answer: X-Request-* for the answer's resource and cost metadata, and X-RateLimit-* for quota state.

The API reference also lists an optional usage object in its successful response schema, with completion_tokens, prompt_tokens and total_tokens. The service guide's specific instruction for synchronous usage metadata points to the response headers, so the header names above are the documented fields to capture for this question.

FAQ

Does stream: false put usage in the JSON body?

Brave's service guide directs synchronous clients to the response headers for the documented X-Request-* metadata. The API reference separately lists an optional usage object in the successful response schema, so implementations should preserve the headers while reviewing the schema behavior for their client.

Which headers show remaining quota?

Read X-RateLimit-Remaining for the quota remaining in each window. Brave's rate limiting guide also documents X-RateLimit-Reset for the time until the windows reset.

Sources

  1. Brave, "Answers", undated
  2. Brave, "Answers API reference", undated
  3. Brave, "Rate limiting", undated

Check how a page reads to answer engines. Open the GEO score analyzer

Test a page and see what to fix first

The analysis usually takes less than 10 seconds and needs no account.

400,000+ pages scored in the public benchmark