Skip to main content
blackthorn serve reports token usage and errors the way each API it serves does, so an OpenAI or Anthropic SDK reads them as it would from OpenAI or Anthropic.

Token usage

Every answer carries its API’s usage object. The part of the prompt the engine already held, from earlier turns of the same conversation, is reported as cached.
  • In Chat Completions and Responses, the prompt’s count includes its cached tokens. In Anthropic’s Messages, input_tokens counts only the tokens that weren’t cached, as Anthropic’s API does.
  • cache_creation_input_tokens and reasoning_tokens are always 0.
  • POST /v1/messages/count_tokens returns a prompt’s exact count as input_tokens, without running it.

In a stream

The portal’s usage page shows the same three counts for each API key: input, cached input and output.

Why an answer stopped

Errors

A request that fails gets an HTTP status and an error in its API’s own format:
The message says what went wrong. The status tells you whether sending the request again can help: The 402 needs blackthorn 0.8.2 or newer.

In a stream

A stream that has already started has sent its 200, so a failure after that arrives as an event, and the stream ends: