SPB Git

Repository Public

fast-mode.md 27.0 KB 782 lines markdown

1---2title: Fast mode (research preview)3url: https://platform.claude.com/docs/en/build-with-claude/fast-mode4description: Get up to 2.5x higher output tokens per second from supported Claude Opus models.5---67Fast mode delivers up to 2.5x higher output tokens per second from Claude Opus 5 and Claude Opus 4.8 at premium pricing. Set `speed: "fast"` with the `fast-mode-2026-02-01` beta header on your request to opt in.89<Note>10  Fast mode is in research preview. Contact your account manager to request access. If you do not have an account manager, [join the waitlist](https://claude.com/fast-mode) for fast mode.11</Note>1213<Note>14  To learn how zero data retention (ZDR) applies to this feature, see [API and data retention](https://platform.claude.com/docs/en/manage-claude/api-and-data-retention).15</Note>1617## Supported models1819Fast mode is supported on the following models:2021* Claude Opus 5 (claude-opus-5)22* Claude Opus 4.8 (claude-opus-4-8)2324<Note>25  Fast mode for Claude Opus 5 and Claude Opus 4.8 is available as a research preview on the Claude API, including [Claude Managed Agents](https://platform.claude.com/docs/en/managed-agents/overview), only. It is not available on Amazon Bedrock, Claude Platform on AWS, Google Cloud, or Microsoft Foundry.26</Note>2728<Note>29  Fast mode is not available on Claude Opus 4.7. Requests to `claude-opus-4-7` with `speed: "fast"` return an error; unlike Claude Opus 4.6 (see the following note), requests do not fall back to standard speed. The model itself remains available at standard speed. To continue using fast mode, migrate to [Claude Opus 5](https://platform.claude.com/docs/en/models/opus-5/migration-guide#migrating-from-claude-opus-47) or Claude Opus 4.8.30</Note>3132<Note>33  Fast mode is not available on Claude Opus 4.6. Requests to `claude-opus-4-6` with `speed: "fast"` do not return an error: they run at standard speed and are billed at [standard rates](https://platform.claude.com/docs/en/about-claude/pricing) rather than fast mode's premium rates, and the response reports [`usage.speed: "standard"`](https://platform.claude.com/docs/en/build-with-claude/fast-mode#checking-which-speed-was-used). To continue using fast mode, migrate to [Claude Opus 5](https://platform.claude.com/docs/en/models/opus-5/migration-guide#migrating-from-claude-opus-46) or Claude Opus 4.8.34</Note>3536## How fast mode works3738Fast mode runs the same model with a faster inference configuration. There is no change to intelligence or capabilities.3940* Up to 2.5x higher output tokens per second compared to standard speed41* Speed benefits are focused on output tokens per second (OTPS), not time to first token (TTFT)42* Same model weights and behavior (not a different model)43* Compatible with [streaming](https://platform.claude.com/docs/en/build-with-claude/streaming), where the OTPS gain is most visible4445## Basic usage4647<CodeGroup>48  ```bash cURL49  curl https://api.anthropic.com/v1/messages \50    -H "x-api-key: $ANTHROPIC_API_KEY" \51    -H "anthropic-version: 2023-06-01" \52    -H "anthropic-beta: fast-mode-2026-02-01" \53    -H "content-type: application/json" \54    -d '{55      "model": "claude-opus-5",56      "max_tokens": 4096,57      "speed": "fast",58      "messages": [{59        "role": "user",60        "content": "Refactor this module to use dependency injection"61      }]62    }'63  ```6465  ```bash CLI66  ant beta:messages create \67    --beta fast-mode-2026-02-01 \68    --transform 'content.#(type=="text").text' \69    --raw-output <<'YAML'70  model: claude-opus-571  max_tokens: 409672  speed: fast73  messages:74    - role: user75      content: Refactor this module to use dependency injection76  YAML77  ```7879  ```python Python80  client = anthropic.Anthropic()8182  response = client.beta.messages.create(83      model="claude-opus-5",84      max_tokens=4096,85      speed="fast",86      betas=["fast-mode-2026-02-01"],87      messages=[88          {"role": "user", "content": "Refactor this module to use dependency injection"}89      ],90  )9192  for block in response.content:93      if block.type == "text":94          print(block.text)95  ```9697  ```typescript TypeScript98  const client = new Anthropic();99100  const response = await client.beta.messages.create({101    model: "claude-opus-5",102    max_tokens: 4096,103    speed: "fast",104    betas: ["fast-mode-2026-02-01"],105    messages: [106      {107        role: "user",108        content: "Refactor this module to use dependency injection"109      }110    ]111  });112113  const textBlock = response.content.find(114    (block): block is Anthropic.Beta.Messages.BetaTextBlock => block.type === "text"115  );116  console.log(textBlock?.text);117  ```118119  ```csharp C#120  AnthropicClient client = new();121122  var response = await client.Beta.Messages.Create(new MessageCreateParams123  {124      Model = "claude-opus-5",125      MaxTokens = 4096,126      Speed = Speed.Fast,127      Betas = ["fast-mode-2026-02-01"],128      Messages = [129          new() { Role = Role.User, Content = "Refactor this module to use dependency injection" }130      ],131  });132133  foreach (var block in response.Content)134  {135      if (block.TryPickText(out var textBlock))136      {137          Console.WriteLine(textBlock.Text);138      }139  }140  ```141142  ```go Go143  client := anthropic.NewClient()144145  response, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{146  	Model:     anthropic.ModelClaudeOpus5,147  	MaxTokens: 4096,148  	Speed:     anthropic.BetaMessageNewParamsSpeedFast,149  	Betas:     []anthropic.AnthropicBeta{anthropic.AnthropicBetaFastMode2026_02_01},150  	Messages: []anthropic.BetaMessageParam{151  		anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("Refactor this module to use dependency injection")),152  	},153  })154  if err != nil {155  	log.Fatal(err)156  }157  for _, block := range response.Content {158  	if textBlock, ok := block.AsAny().(anthropic.BetaTextBlock); ok {159  		fmt.Println(textBlock.Text)160  	}161  }162  ```163164  ```java Java165  AnthropicClient client = AnthropicOkHttpClient.fromEnv();166167  BetaMessage response = client.beta().messages().create(168          MessageCreateParams.builder()169                  .model(Model.CLAUDE_OPUS_5)170                  .maxTokens(4096L)171                  .speed(MessageCreateParams.Speed.FAST)172                  .addBeta(AnthropicBeta.FAST_MODE_2026_02_01)173                  .addUserMessage("Refactor this module to use dependency injection")174                  .build());175176  response.content().stream()177          .flatMap(block -> block.text().stream())178          .forEach(textBlock -> IO.println(textBlock.text()));179  ```180181  ```php PHP182  $client = new Client();183184  $response = $client->beta->messages->create(185      model: 'claude-opus-5',186      maxTokens: 4096,187      speed: 'fast',188      betas: ['fast-mode-2026-02-01'],189      messages: [190          ['role' => 'user', 'content' => 'Refactor this module to use dependency injection'],191      ],192  );193194  foreach ($response->content as $block) {195      if ($block->type === 'text') {196          echo $block->text, PHP_EOL;197      }198  }199  ```200201  ```ruby Ruby202  client = Anthropic::Client.new203204  response = client.beta.messages.create(205    model: "claude-opus-5",206    max_tokens: 4096,207    speed: "fast",208    betas: ["fast-mode-2026-02-01"],209    messages: [{role: "user", content: "Refactor this module to use dependency injection"}]210  )211212  response.content.each do |block|213    puts block.text if block.type == :text214  end215  ```216</CodeGroup>217218## Pricing219220Fast mode is priced at a multiplier on standard rates across the full context window, including requests over 200k input tokens. The following table shows fast mode pricing for the supported models:221222| Model                           | Input          | Output         |223| ------------------------------- | -------------- | -------------- |224| Claude Opus 5 / Claude Opus 4.8 | $10 USD / MTok | $50 USD / MTok |225226Fast mode pricing stacks with other pricing modifiers:227228* [Prompt caching multipliers](https://platform.claude.com/docs/en/about-claude/pricing#prompt-caching) apply on top of fast mode pricing229* [Data residency](https://platform.claude.com/docs/en/manage-claude/data-residency) multipliers apply on top of fast mode pricing230231For complete pricing details, see the [Pricing](https://platform.claude.com/docs/en/about-claude/pricing#fast-mode-pricing) page.232233## Rate limits234235Fast mode has a dedicated rate limit that is separate from standard Opus rate limits. When your fast mode rate limit is exceeded, the API returns a `429` error with a `retry-after` header indicating when capacity will be available.236237The response includes headers that indicate your fast mode rate limit status:238239| Header                                   | Description                                       |240| ---------------------------------------- | ------------------------------------------------- |241| `anthropic-fast-input-tokens-limit`      | Maximum fast mode input tokens per minute         |242| `anthropic-fast-input-tokens-remaining`  | Remaining fast mode input tokens                  |243| `anthropic-fast-input-tokens-reset`      | Time when the fast mode input token limit resets  |244| `anthropic-fast-output-tokens-limit`     | Maximum fast mode output tokens per minute        |245| `anthropic-fast-output-tokens-remaining` | Remaining fast mode output tokens                 |246| `anthropic-fast-output-tokens-reset`     | Time when the fast mode output token limit resets |247248For tier-specific rate limits, see the [Rate limits](https://platform.claude.com/docs/en/api/rate-limits) page.249250## Checking which speed was used251252The response `usage` object includes a `speed` field that indicates which speed was used, either `"fast"` or `"standard"`. Requesting `speed: "fast"` on a [model that doesn't support fast mode](https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models) returns an error, and so does exceeding fast mode's rate limits or capacity (a `429` or `529`). When a request with `speed: "fast"` succeeds, `usage.speed` is `"fast"`. If you are using Claude Opus 4.6 and request fast mode, its behavior is unique. Instead of returning an error like other models that don't support fast mode, it silently switches to standard speed. Though there is no error with Opus 4.6, the `speed` field accurately shows `"standard"`.253254<CodeGroup>255  ```bash cURL256  curl https://api.anthropic.com/v1/messages \257    -H "x-api-key: $ANTHROPIC_API_KEY" \258    -H "anthropic-version: 2023-06-01" \259    -H "anthropic-beta: fast-mode-2026-02-01" \260    -H "content-type: application/json" \261    -d '{262      "model": "claude-opus-5",263      "max_tokens": 1024,264      "speed": "fast",265      "messages": [{"role": "user", "content": "Hello"}]266    }'267  ```268269  ```bash CLI270  ant beta:messages create \271    --beta fast-mode-2026-02-01 \272    --transform usage.speed \273    --raw-output <<'YAML'274  model: claude-opus-5275  max_tokens: 1024276  speed: fast277  messages:278    - role: user279      content: Hello280  YAML281  ```282283  ```python Python284  client = anthropic.Anthropic()285286  response = client.beta.messages.create(287      model="claude-opus-5",288      max_tokens=1024,289      speed="fast",290      betas=["fast-mode-2026-02-01"],291      messages=[{"role": "user", "content": "Hello"}],292  )293294  print(response.usage.speed)  # "fast" or "standard"295  ```296297  ```typescript TypeScript298  const client = new Anthropic();299300  const response = await client.beta.messages.create({301    model: "claude-opus-5",302    max_tokens: 1024,303    speed: "fast",304    betas: ["fast-mode-2026-02-01"],305    messages: [{ role: "user", content: "Hello" }]306  });307308  console.log(response.usage.speed); // "fast" or "standard"309  ```310311  ```csharp C#312  AnthropicClient client = new();313314  var response = await client.Beta.Messages.Create(new MessageCreateParams315  {316      Model = "claude-opus-5",317      MaxTokens = 1024,318      Speed = Speed.Fast,319      Betas = ["fast-mode-2026-02-01"],320      Messages = [new() { Role = Role.User, Content = "Hello" }],321  });322323  Console.WriteLine(response.Usage.Speed);  // "fast" or "standard"324  ```325326  ```go Go327  client := anthropic.NewClient()328329  response, err := client.Beta.Messages.New(context.TODO(), anthropic.BetaMessageNewParams{330  	Model:     anthropic.ModelClaudeOpus5,331  	MaxTokens: 1024,332  	Speed:     anthropic.BetaMessageNewParamsSpeedFast,333  	Betas:     []anthropic.AnthropicBeta{anthropic.AnthropicBetaFastMode2026_02_01},334  	Messages: []anthropic.BetaMessageParam{335  		anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("Hello")),336  	},337  })338  if err != nil {339  	log.Fatal(err)340  }341  fmt.Println(response.Usage.Speed) // "fast" or "standard"342  ```343344  ```java Java345  AnthropicClient client = AnthropicOkHttpClient.fromEnv();346347  MessageCreateParams params = MessageCreateParams.builder()348          .model(Model.CLAUDE_OPUS_5)349          .maxTokens(1024L)350          .speed(MessageCreateParams.Speed.FAST)351          .addBeta(AnthropicBeta.FAST_MODE_2026_02_01)352          .addUserMessage("Hello")353          .build();354355  BetaMessage response = client.beta().messages().create(params);356  IO.println(response.usage().speed().orElseThrow());  // "fast" or "standard"357  ```358359  ```php PHP360  $client = new Client();361362  $response = $client->beta->messages->create(363      model: 'claude-opus-5',364      maxTokens: 1024,365      speed: 'fast',366      betas: ['fast-mode-2026-02-01'],367      messages: [['role' => 'user', 'content' => 'Hello']],368  );369370  echo $response->usage->speed;  // "fast" or "standard"371  ```372373  ```ruby Ruby374  client = Anthropic::Client.new375376  response = client.beta.messages.create(377    model: "claude-opus-5",378    max_tokens: 1024,379    speed: "fast",380    betas: ["fast-mode-2026-02-01"],381    messages: [{ role: "user", content: "Hello" }]382  )383384  puts(response.usage.speed)  # "fast" or "standard"385  ```386</CodeGroup>387388```json Output389{390  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",391  "type": "message",392  "role": "assistant",393// ...394  "usage": {395    "input_tokens": 8,396    "output_tokens": 12,397    "speed": "fast"398  }399}400```401402To track fast mode usage and costs across your organization, see the [Usage and Cost API](https://platform.claude.com/docs/en/manage-claude/usage-cost-api).403404## Retries and fallback405406### Automatic retries407408When fast mode rate limits are exceeded, the API returns a `429` error with a `retry-after` header. The Anthropic SDKs automatically retry these requests up to 2 times by default (configurable with `max_retries`), waiting for the server-specified delay before each retry. Because fast mode uses continuous token replenishment, the `retry-after` delay is typically short and requests succeed once capacity is available.409410### Falling back to standard speed411412<Note>413  This section covers an opt-in client-side fallback when fast mode is rate limited. It is separate from the behavior on [Claude Opus 4.6](https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models), where fast mode is not available and requests run at standard speed automatically.414</Note>415416If you'd prefer to fall back to standard speed rather than wait for fast mode capacity, catch the rate limit error and retry without `speed: "fast"`. Set `max_retries` to `0` on the initial fast request to skip automatic retries and fail immediately on rate limit errors.417418<Note>419  Falling back from fast to standard speed will result in a [prompt cache](https://platform.claude.com/docs/en/build-with-claude/prompt-caching) miss. Requests at different speeds do not share cached prefixes.420</Note>421422Because setting `max_retries` to `0` also disables retries for other transient errors (overloaded, internal server errors), the following examples reissue the original request with default retries for those cases.423424<CodeGroup exclude="shell:cURL">425  ```bash CLI426  # `ant` retries 429/5xx automatically and has no per-request max_retries427  # override, so on a fast-mode 429 the fallback runs after the built-in428  # retries exhaust. --transform-error surfaces error.type for branching.429  create_message_with_fast_fallback() {430    local speed="$1" max_attempts="${2:-3}" body out431    body=${3:-$(cat)}432    out=$(433      ant beta:messages create --beta fast-mode-2026-02-01 \434        ${speed:+--speed "$speed"} \435        --transform-error error.type --format-error yaml <<<"$body" 2>/dev/null436    ) && { printf '%s\n' "$out"; return; }437    case "$out" in438      rate_limit_error)439        if [[ -n "$speed" ]]; then440          create_message_with_fast_fallback "" "$max_attempts" "$body"441          return442        fi ;;443      overloaded_error | api_error | "")444        if (( max_attempts > 1 )); then445          create_message_with_fast_fallback "$speed" $((max_attempts - 1)) "$body"446          return447        fi ;;448    esac449    printf '%s\n' "${out:-connection_error}" >&2450    return 1451  }452453  MESSAGE=$(454    create_message_with_fast_fallback fast <<'YAML'455  model: claude-opus-5456  max_tokens: 1024457  messages:458    - role: user459      content: Hello460  YAML461  )462  ```463464  ```python Python465  client = anthropic.Anthropic()466467468  def create_message_with_fast_fallback(max_retries=0, max_attempts=3, **params):469      try:470          return client.with_options(max_retries=max_retries).beta.messages.create(471              **params472          )473      except anthropic.RateLimitError:474          if params.get("speed") == "fast":475              del params["speed"]476              return create_message_with_fast_fallback(max_retries=max_retries, **params)477          raise478      except (479          anthropic.APIStatusError,480          anthropic.APIConnectionError,481      ) as error:482          if isinstance(error, anthropic.APIStatusError) and error.status_code < 500:483              raise484          if max_attempts > 1:485              return create_message_with_fast_fallback(486                  max_retries=max_retries, max_attempts=max_attempts - 1, **params487              )488          raise489490491  message = create_message_with_fast_fallback(492      model="claude-opus-5",493      max_tokens=1024,494      messages=[{"role": "user", "content": "Hello"}],495      betas=["fast-mode-2026-02-01"],496      speed="fast",497      max_retries=0,498  )499  ```500501  ```typescript TypeScript502  const client = new Anthropic();503504  async function createMessageWithFastFallback(505    params: Anthropic.Beta.MessageCreateParamsNonStreaming,506    requestOptions?: Anthropic.RequestOptions,507    maxAttempts: number = 3508  ): Promise<Anthropic.Beta.Messages.BetaMessage> {509    try {510      return await client.beta.messages.create(params, requestOptions);511    } catch (e) {512      if (e instanceof Anthropic.RateLimitError && params.speed === "fast") {513        const { speed, ...rest } = params;514        return createMessageWithFastFallback(rest);515      }516      if (517        e instanceof Anthropic.InternalServerError ||518        e instanceof Anthropic.APIConnectionError519      ) {520        if (maxAttempts > 1) {521          return createMessageWithFastFallback(params, undefined, maxAttempts - 1);522        }523      }524      throw e;525    }526  }527528  const message = await createMessageWithFastFallback(529    {530      model: "claude-opus-5",531      max_tokens: 1024,532      messages: [{ role: "user", content: "Hello" }],533      betas: ["fast-mode-2026-02-01"],534      speed: "fast"535    },536    { maxRetries: 0 }537  );538  ```539540  ```csharp C#541  AnthropicClient client = new();542543  async Task<BetaMessage> CreateMessageWithFastFallback(544      MessageCreateParams parameters,545      int? maxRetries = null,546      int maxAttempts = 3)547  {548      try549      {550          var requestClient = maxRetries is int retries551              ? client.WithOptions(options => options with { MaxRetries = retries })552              : client;553          return await requestClient.Beta.Messages.Create(parameters);554      }555      catch (AnthropicRateLimitException)556      {557          if (parameters.Speed is not null)558          {559              return await CreateMessageWithFastFallback(560                  parameters with { Speed = null });561          }562          throw;563      }564      catch (Anthropic5xxException)565      {566          if (maxAttempts > 1)567          {568              return await CreateMessageWithFastFallback(569                  parameters, maxAttempts: maxAttempts - 1);570          }571          throw;572      }573  }574575  var message = await CreateMessageWithFastFallback(576      new MessageCreateParams577      {578          Model = "claude-opus-5",579          MaxTokens = 1024,580          Messages = [new() { Role = Role.User, Content = "Hello" }],581          Betas = ["fast-mode-2026-02-01"],582          Speed = Speed.Fast,583      },584      maxRetries: 0);585  ```586587  ```go Go588  func createMessageWithFastFallback(589  	ctx context.Context,590  	client *anthropic.Client,591  	params anthropic.BetaMessageNewParams,592  	maxAttempts int,593  	opts ...option.RequestOption,594  ) (*anthropic.BetaMessage, error) {595  	message, err := client.Beta.Messages.New(ctx, params, opts...)596  	if err != nil {597  		var apierr *anthropic.Error598  		if errors.As(err, &apierr) && apierr.StatusCode == 429 && params.Speed != "" {599  			params.Speed = ""600  			return createMessageWithFastFallback(ctx, client, params, maxAttempts)601  		}602  		if (errors.As(err, &apierr) && apierr.StatusCode >= 500) || !errors.As(err, &apierr) {603  			if maxAttempts > 1 {604  				return createMessageWithFastFallback(ctx, client, params, maxAttempts-1)605  			}606  		}607  		return nil, err608  	}609  	return message, nil610  }611612  func main() {613  	client := anthropic.NewClient()614  	message, err := createMessageWithFastFallback(615  		context.TODO(),616  		&client,617  		anthropic.BetaMessageNewParams{618  			Model:     anthropic.ModelClaudeOpus5,619  			MaxTokens: 1024,620  			Messages: []anthropic.BetaMessageParam{621  				anthropic.NewBetaUserMessage(anthropic.NewBetaTextBlock("Hello")),622  			},623  			Speed: anthropic.BetaMessageNewParamsSpeedFast,624  			Betas: []anthropic.AnthropicBeta{anthropic.AnthropicBetaFastMode2026_02_01},625  		},626  		3,627  		option.WithMaxRetries(0),628  	)629  	if err != nil {630  		panic(err)631  	}632  	fmt.Println(message)633  }634  ```635636  ```java Java637  import com.anthropic.errors.InternalServerException;638  import com.anthropic.errors.RateLimitException;639  // ...640  // Disable SDK auto-retry so the fallback logic below handles it641  AnthropicClient client =642          AnthropicOkHttpClient.builder().fromEnv().maxRetries(0).build();643644  BetaMessage createMessageWithFastFallback(645          MessageCreateParams params, int maxAttempts) {646      try {647          return client.beta().messages().create(params);648      } catch (RateLimitException e) {649          if (params.speed().isPresent()) {650              MessageCreateParams retryParams = params.toBuilder()651                      .speed(Optional.empty())652                      .build();653              return createMessageWithFastFallback(retryParams, maxAttempts);654          }655          throw e;656      } catch (InternalServerException e) {657          if (maxAttempts > 1) {658              return createMessageWithFastFallback(params, maxAttempts - 1);659          }660          throw e;661      }662  }663664  void main() {665      BetaMessage message = createMessageWithFastFallback(666              MessageCreateParams.builder()667                      .model(Model.CLAUDE_OPUS_5)668                      .maxTokens(1024L)669                      .addUserMessage("Hello")670                      .addBeta(AnthropicBeta.FAST_MODE_2026_02_01)671                      .speed(MessageCreateParams.Speed.FAST)672                      .build(),673              3);674      message.content().stream()675              .flatMap(block -> block.text().stream())676              .forEach(textBlock -> IO.println(textBlock.text()));677  }678  ```679680  ```php PHP681  use Anthropic\Core\Exceptions\APIConnectionException;682  use Anthropic\Core\Exceptions\InternalServerException;683  use Anthropic\Core\Exceptions\RateLimitException;684  use Anthropic\RequestOptions;685  // ...686  $client = new Client();687688  function createMessageWithFastFallback(689      Client $client,690      array $params,691      ?RequestOptions $requestOptions = null,692      int $maxAttempts = 3,693  ) {694      try {695          return $client->beta->messages->create(696              ...$params,697              requestOptions: $requestOptions,698          );699      } catch (RateLimitException $e) {700          if (isset($params['speed'])) {701              unset($params['speed']);702              return createMessageWithFastFallback($client, $params);703          }704          throw $e;705      } catch (InternalServerException | APIConnectionException $e) {706          if ($maxAttempts > 1) {707              return createMessageWithFastFallback(708                  $client, $params, maxAttempts: $maxAttempts - 1709              );710          }711          throw $e;712      }713  }714715  $message = createMessageWithFastFallback(716      $client,717      [718          'model' => 'claude-opus-5',719          'maxTokens' => 1024,720          'messages' => [['role' => 'user', 'content' => 'Hello']],721          'betas' => ['fast-mode-2026-02-01'],722          'speed' => 'fast',723      ],724      RequestOptions::with(maxRetries: 0),725  );726  ```727728  ```ruby Ruby729  client = Anthropic::Client.new730731  def create_message_with_fast_fallback(client, request_options: {}, max_attempts: 3, **params)732    client.beta.messages.create(**params, request_options: request_options)733  rescue Anthropic::Errors::RateLimitError734    raise unless params[:speed] == "fast"735    params.delete(:speed)736    create_message_with_fast_fallback(client, **params)737  rescue Anthropic::Errors::InternalServerError, Anthropic::Errors::APIConnectionError738    raise unless max_attempts > 1739    create_message_with_fast_fallback(client, max_attempts: max_attempts - 1, **params)740  end741742  message = create_message_with_fast_fallback(743    client,744    model: "claude-opus-5",745    max_tokens: 1024,746    messages: [{ role: "user", content: "Hello" }],747    betas: ["fast-mode-2026-02-01"],748    speed: "fast",749    request_options: { max_retries: 0 }750  )751  ```752</CodeGroup>753754## Considerations755756* **Prompt caching:** Switching between fast and standard speed invalidates the prompt cache. Requests at different speeds do not share cached prefixes.757* **Supported models:** Fast mode is supported on Claude Opus 5 and Claude Opus 4.8. See [Supported models](https://platform.claude.com/docs/en/build-with-claude/fast-mode#supported-models).758* **TTFT:** Fast mode's benefits are focused on output tokens per second (OTPS), not time to first token (TTFT).759* **Batch API:** Fast mode is not available with the [Batch API](https://platform.claude.com/docs/en/build-with-claude/batch-processing).760* **Priority Tier:** Fast mode is not available with a [Priority Tier](https://platform.claude.com/docs/en/api/service-tiers) commitment.761* **Claude Platform on AWS:** Fast mode is not currently available on [Claude Platform on AWS](https://platform.claude.com/docs/en/build-with-claude/claude-platform-on-aws).762763## Next steps764765<CardGroup cols={2}>766  <Card title="Structured outputs" icon="code-brackets" href="https://platform.claude.com/docs/en/build-with-claude/structured-outputs">767    Get validated JSON results from agent workflows.768  </Card>769770  <Card title="Pricing" icon="calculator" href="https://platform.claude.com/docs/en/about-claude/pricing#fast-mode-pricing">771    Learn about Anthropic's pricing structure for models and features.772  </Card>773774  <Card title="Effort" icon="gauge" href="https://platform.claude.com/docs/en/build-with-claude/effort">775    Control how many tokens Claude uses when responding with the effort parameter, trading off between response thoroughness and token efficiency.776  </Card>777778  <Card title="Streaming messages" icon="arrow-right" href="https://platform.claude.com/docs/en/build-with-claude/streaming">779    Stream Messages API responses incrementally with server-sent events, including text, tool use, and extended thinking deltas.780  </Card>781</CardGroup>782
Files main
Menu

Theme