Skip to content

Meta Information

Every API response includes HTTP headers with rate limit data, request IDs, and token limits. The client exposes these through the meta() method on response objects.

Accessing meta information

Call meta() on any response:

$response = $client->messages()->create([
    'model' => 'claude-sonnet-5-5',
    'max_tokens' => 1024,
    'messages' => [
        ['role' => 'user', 'content' => 'Hello, world'],
    ],
]);

$meta = $response->meta();

Request ID

Every request gets a unique identifier:

$meta->requestId; // 'req_012nTzj6kLoP8vZ1SGANvcgR'

Include this when contacting support about a specific request.

Organization and workspace

The API names the organization behind every response, and the workspace the key resolved to, the Default Workspace included:

$meta->organizationId; // the organization's ID, or null
$meta->workspaceId;    // the workspace's ID; null on Admin API requests

workspaceId is useful when one app holds keys for several workspaces and you want logs to say which one served a call.

Rate limits

The API enforces rate limits on both requests per minute and tokens per minute. The meta() object tells you where you stand:

Request limits

$meta->requestLimit->limit;     // 3000 (max requests per period)
$meta->requestLimit->remaining; // 2999 (requests left)
$meta->requestLimit->reset;     // '2024-05-01T13:29:17Z' (when the limit resets)

Token limits

$meta->tokenLimit->limit;     // 250000
$meta->tokenLimit->remaining; // 249984
$meta->tokenLimit->reset;     // '2024-05-01T13:29:17Z'

Input and output token limits

These are tracked separately from the combined token limit:

$meta->inputTokenLimit->limit;      // 20000
$meta->inputTokenLimit->remaining;  // 19500
$meta->inputTokenLimit->reset;      // '2024-05-01T13:29:17Z'

$meta->outputTokenLimit->limit;     // 5000
$meta->outputTokenLimit->remaining; // 4900
$meta->outputTokenLimit->reset;     // '2024-05-01T13:29:17Z'

Each limit object has the same three fields: limit (the maximum), remaining (how much is left), and reset (when it resets, as an ISO 8601 timestamp).

Priority Tier limits

If your organization is on Priority Tier, two extra rate limits apply on top of the standard ones. They're exposed as typed properties and stay null when the request didn't use Priority Tier:

$meta->priorityInputTokenLimit?->limit;     // 50000
$meta->priorityInputTokenLimit?->remaining; // 48000
$meta->priorityInputTokenLimit?->reset;     // '2024-05-01T13:29:17Z'

$meta->priorityOutputTokenLimit?->limit;     // 10000
$meta->priorityOutputTokenLimit?->remaining; // 9500
$meta->priorityOutputTokenLimit?->reset;     // '2024-05-01T13:29:17Z'

These track your Priority Tier allocation separately from the shared standard pool. When you want to know whether a request drew from Priority capacity or spilled over into standard capacity, these are the fields to check.

Fast mode limits

Requests sent with fast mode draw from their own token limits, reported in the anthropic-fast-* headers. The typed properties are null on other requests:

$meta->fastInputTokenLimit?->limit;
$meta->fastInputTokenLimit?->remaining;
$meta->fastInputTokenLimit?->reset;

$meta->fastOutputTokenLimit?->limit;
$meta->fastOutputTokenLimit?->remaining;
$meta->fastOutputTokenLimit?->reset;

Retry-After

retryAfter holds the Retry-After header as whole seconds:

$meta->retryAfter; // 30, or null

A successful response rarely carries it: the API sends it with a 429, which throws an exception before you get a response object. Read it from the exception with getRetryAfter() instead, as Error Handling shows. A Retry-After given as an HTTP date leaves retryAfter null; the raw value stays in custom.

Raw header format

The toArray() method returns the meta information using the original HTTP header names:

$meta->toArray();

// [
//   'anthropic-ratelimit-requests-limit' => 3000,
//   'anthropic-ratelimit-tokens-limit' => 250000,
//   'anthropic-ratelimit-requests-remaining' => 2999,
//   'anthropic-ratelimit-tokens-remaining' => 249983,
//   'anthropic-ratelimit-requests-reset' => '2024-05-01T13:29:17Z',
//   'anthropic-ratelimit-tokens-reset' => '2024-05-01T13:29:17Z',
//   'anthropic-ratelimit-input-tokens-limit' => 20000,
//   'anthropic-ratelimit-input-tokens-remaining' => 19500,
//   'anthropic-ratelimit-input-tokens-reset' => '2024-05-01T13:29:17Z',
//   'anthropic-ratelimit-output-tokens-limit' => 5000,
//   'anthropic-ratelimit-output-tokens-remaining' => 4900,
//   'anthropic-ratelimit-output-tokens-reset' => '2024-05-01T13:29:17Z',
//   'anthropic-organization-id' => '...',
//   'request-id' => 'req_012nTzj6kLoP8vZ1SGANvcgR',
// ]

Priority Tier headers (anthropic-priority-input-tokens-* and anthropic-priority-output-tokens-*), the anthropic-fast-* headers, anthropic-workspace-id and retry-after are included in the same array when they're present on the response.

Custom headers

Every other header the response carries is available via the custom property:

$meta->custom; // additional headers as a key-value object

The organization and workspace IDs, retry-after and the fast mode headers stay in custom too, where earlier releases put them, so code that reads them there keeps working.

Streaming responses

For streamed responses, call meta() on the stream object (not on individual events):

$stream = $client->messages()->createStreamed([
    'model' => 'claude-sonnet-5-5',
    'max_tokens' => 1024,
    'messages' => [
        ['role' => 'user', 'content' => 'Hello, world'],
    ],
]);

$stream->meta(); // same MetaInformation object

The meta information comes from the HTTP response headers, which are set at the start of the stream.

Batch results

Batch result responses also support meta():

$results = $client->batches()->results('msgbatch_04Rka1yCsMLGPnR7kfPdgR8x');

// Process results...
foreach ($results as $individual) {
    // ...
}

$results->meta(); // rate limit headers for this request

Handling rate limits

For details on catching rate limit errors and implementing retry logic, see Error Handling. The Anthropic documentation on rate limits covers the full details on limit tiers and how they work.

Scroll to top