---
title: Modalità veloce
url: https://platform.claude.com/docs/it/build-with-claude/fast-mode
description: Ottieni fino a 2,5 volte più token di output al secondo dai modelli Claude supportati.
---

La "fast mode" (modalità veloce) offre fino a 2,5 volte più token di output al secondo da Claude Opus 5.5, Claude Opus 5, e Claude Opus 4.8 a un prezzo premium. Imposta `speed: "fast"` nella tua richiesta per attivarla.

<Note>
  La modalità veloce per Claude Opus 5.5 non richiede l'header beta `fast-mode-2026-02-01` né una richiesta di accesso. Le richieste che inviano ancora l'header continuano a funzionare. La modalità veloce per Claude Opus 5 e Claude Opus 4.8 è in anteprima di ricerca: contatta il tuo account manager o [iscriviti alla lista d'attesa](https://claude.com/fast-mode) per richiedere l'accesso, e invia l'[header beta](https://platform.claude.com/docs/it/api/beta-headers) nelle tue richieste.
</Note>

<Note>
  Per scoprire come la "zero data retention" (conservazione zero dei dati), o ZDR, si applica a questa funzionalità, consulta [API e conservazione dei dati](https://platform.claude.com/docs/it/manage-claude/api-and-data-retention).
</Note>

## Modelli e piattaforme supportati

La modalità veloce è supportata sui seguenti modelli e piattaforme:

| Modello supportato                | Piattaforme supportate                                                                                                                                                                                                                                             |
| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| Claude Opus 5.5 (claude-opus-5-5) | Claude API, incluso [Claude Managed Agents](https://platform.claude.com/docs/it/managed-agents/overview)<br />[Claude in Microsoft Foundry](https://platform.claude.com/docs/it/build-with-claude/claude-in-microsoft-foundry), per i deployment ospitati su Azure |
| Claude Opus 5 (claude-opus-5)     | Claude API, incluso [Claude Managed Agents](https://platform.claude.com/docs/it/managed-agents/overview)                                                                                                                                                           |
| Claude Opus 4.8 (claude-opus-4-8) | Claude API, incluso [Claude Managed Agents](https://platform.claude.com/docs/it/managed-agents/overview)                                                                                                                                                           |

Se stavi usando la modalità veloce su un modello precedente, [esegui la migrazione a un modello che supporta la modalità veloce](https://platform.claude.com/docs/it/models/opus-5-5/migration-guide).

La modalità veloce non è disponibile per i deployment di Claude in Microsoft Foundry [ospitati su Anthropic](https://platform.claude.com/docs/it/build-with-claude/claude-in-microsoft-foundry#hosting-options).

## Come funziona la modalità veloce

La modalità veloce esegue lo stesso modello con una configurazione di inferenza più rapida. Non vi è alcun cambiamento nell'intelligenza o nelle capacità.

* Fino a 2,5 volte più token di output al secondo rispetto alla velocità standard
* I vantaggi in termini di velocità si concentrano sugli "output tokens per second" (token di output al secondo), o OTPS, non sul "time to first token" (tempo al primo token), o TTFT
* Stessi pesi e comportamento del modello (non è un modello diverso)
* Compatibile con lo [streaming](https://platform.claude.com/docs/it/build-with-claude/streaming), dove il guadagno in OTPS è più visibile

## Utilizzo di base

I modelli in anteprima di ricerca richiedono anche l'[header beta](https://platform.claude.com/docs/it/api/beta-headers) `fast-mode-2026-02-01`.

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 4096,
      "speed": "fast",
      "messages": [{
        "role": "user",
        "content": "Refactor this module to use dependency injection"
      }]
    }'
  ```

  ```bash CLI
  ant messages create <<'YAML'
  model: claude-opus-5-5
  max_tokens: 4096
  speed: fast
  messages:
    - role: user
      content: Refactor this module to use dependency injection
  YAML
  ```

  ```python Python
  client = anthropic.Anthropic()

  response = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=4096,
      speed="fast",
      messages=[
          {"role": "user", "content": "Refactor this module to use dependency injection"}
      ],
  )

  for block in response.content:
      if block.type == "text":
          print(block.text)
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const response = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 4096,
    speed: "fast",
    messages: [
      {
        role: "user",
        content: "Refactor this module to use dependency injection"
      }
    ]
  });

  const textBlock = response.content.find(
    (block): block is Anthropic.TextBlock => block.type === "text"
  );
  console.log(textBlock?.text);
  ```

  ```csharp C#
  AnthropicClient client = new();

  var response = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 4096,
      Speed = Speed.Fast,
      Messages = [
          new() { Role = Role.User, Content = "Refactor this module to use dependency injection" }
      ],
  });

  foreach (var block in response.Content)
  {
      if (block.TryPickText(out var textBlock))
      {
          Console.WriteLine(textBlock.Text);
      }
  }
  ```

  ```go Go
  client := anthropic.NewClient()

  response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 4096,
  	Speed:     anthropic.MessageNewParamsSpeedFast,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(anthropic.NewTextBlock("Refactor this module to use dependency injection")),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }
  for _, block := range response.Content {
  	if textBlock, ok := block.AsAny().(anthropic.TextBlock); ok {
  		fmt.Println(textBlock.Text)
  	}
  }
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  Message response = client.messages().create(
          MessageCreateParams.builder()
                  .model(Model.CLAUDE_OPUS_5_5)
                  .maxTokens(4096L)
                  .speed(MessageCreateParams.Speed.FAST)
                  .addUserMessage("Refactor this module to use dependency injection")
                  .build());

  response.content().stream()
          .flatMap(block -> block.text().stream())
          .forEach(textBlock -> IO.println(textBlock.text()));
  ```

  ```php PHP
  $client = new Client();

  $response = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 4096,
      speed: 'fast',
      messages: [
          ['role' => 'user', 'content' => 'Refactor this module to use dependency injection'],
      ],
  );

  foreach ($response->content as $block) {
      if ($block instanceof \Anthropic\Messages\TextBlock) {
          echo $block->text, PHP_EOL;
      }
  }
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  response = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 4096,
    speed: "fast",
    messages: [{role: "user", content: "Refactor this module to use dependency injection"}]
  )

  response.content.each do |block|
    puts block.text if block.type == :text
  end
  ```
</CodeGroup>

## Prezzi

La modalità veloce ha un prezzo pari a un moltiplicatore delle tariffe standard sull'intera "context window" (finestra di contesto), incluse le richieste con oltre 200k token di input. La tabella seguente mostra i prezzi della modalità veloce per i modelli supportati:

| Modello                         | Input          | Output         |
| ------------------------------- | -------------- | -------------- |
| Claude Opus 5.5                 | $8 USD / MTok  | $40 USD / MTok |
| Claude Opus 5 / Claude Opus 4.8 | $10 USD / MTok | $50 USD / MTok |

I prezzi della modalità veloce si cumulano con altri modificatori di prezzo:

* I [moltiplicatori della cache dei prompt](https://platform.claude.com/docs/it/about-claude/pricing#prompt-caching) si applicano in aggiunta ai prezzi della modalità veloce
* I moltiplicatori della [residenza dei dati](https://platform.claude.com/docs/it/manage-claude/data-residency) si applicano in aggiunta ai prezzi della modalità veloce

Per i dettagli completi sui prezzi, consulta la pagina [Prezzi](https://platform.claude.com/docs/it/about-claude/pricing#fast-mode-pricing).

## Limiti di velocità

La modalità veloce ha un "rate limit" (limite di velocità) dedicato, separato dai limiti di velocità standard di Opus. Quando il limite di velocità della modalità veloce viene superato, l'API restituisce un errore `429` con un header `retry-after` che indica quando la capacità sarà disponibile.

Claude Opus 5.5 ha un limite di velocità predefinito per la modalità veloce nei [livelli di utilizzo](https://platform.claude.com/docs/it/api/rate-limits) Start, Build e Scale, quindi non è necessario richiedere l'accesso per usare la modalità veloce con questo modello. Le organizzazioni nel livello Evaluation possono usare la modalità veloce con Claude Opus 5.5 una volta passate al livello Start, Build o Scale.

La risposta include header che indicano lo stato del tuo limite di velocità della modalità veloce:

| Header                                   | Descrizione                                                                       |
| ---------------------------------------- | --------------------------------------------------------------------------------- |
| `anthropic-fast-input-tokens-limit`      | Numero massimo di token di input in modalità veloce al minuto                     |
| `anthropic-fast-input-tokens-remaining`  | Token di input in modalità veloce rimanenti                                       |
| `anthropic-fast-input-tokens-reset`      | Momento in cui il limite dei token di input in modalità veloce viene reimpostato  |
| `anthropic-fast-output-tokens-limit`     | Numero massimo di token di output in modalità veloce al minuto                    |
| `anthropic-fast-output-tokens-remaining` | Token di output in modalità veloce rimanenti                                      |
| `anthropic-fast-output-tokens-reset`     | Momento in cui il limite dei token di output in modalità veloce viene reimpostato |

Per visualizzare i tuoi limiti di velocità della modalità veloce, vai alla pagina [Limiti di velocità](https://platform.claude.com/usage/limits) nella Claude Console.

## Verificare quale velocità è stata utilizzata

L'oggetto `usage` della risposta include un campo `speed` che indica quale velocità è stata utilizzata, `"fast"` oppure `"standard"`. Richiedere `speed: "fast"` su un [modello che non supporta la modalità veloce](https://platform.claude.com/docs/it/build-with-claude/fast-mode#supported-models-and-platforms) restituisce un errore, così come superare i limiti di velocità o la capacità della modalità veloce (un `429` o `529`). Quando una richiesta con `speed: "fast"` ha successo, `usage.speed` è `"fast"`. Claude Opus 4.6 è un'eccezione: invece di restituire un errore, una richiesta con `speed: "fast"` e l'header beta `fast-mode-2026-02-01` ha successo, ma viene eseguita a velocità standard. Questo comportamento è correttamente riflesso in `usage.speed`, che in questa situazione mostra `"standard"`.

<CodeGroup>
  ```bash cURL
  curl https://api.anthropic.com/v1/messages \
    -H "x-api-key: $ANTHROPIC_API_KEY" \
    -H "anthropic-version: 2023-06-01" \
    -H "content-type: application/json" \
    -d '{
      "model": "claude-opus-5-5",
      "max_tokens": 1024,
      "speed": "fast",
      "messages": [{"role": "user", "content": "Hello"}]
    }'
  ```

  ```bash CLI
  ant messages create \
    --transform usage.speed \
    --raw-output <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  speed: fast
  messages:
    - role: user
      content: Hello
  YAML
  ```

  ```python Python
  client = anthropic.Anthropic()

  response = client.messages.create(
      model="claude-opus-5-5",
      max_tokens=1024,
      speed="fast",
      messages=[{"role": "user", "content": "Hello"}],
  )

  print(response.usage.speed)  # "fast" or "standard"
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  const response = await client.messages.create({
    model: "claude-opus-5-5",
    max_tokens: 1024,
    speed: "fast",
    messages: [{ role: "user", content: "Hello" }]
  });

  console.log(response.usage.speed); // "fast" or "standard"
  ```

  ```csharp C#
  AnthropicClient client = new();

  var response = await client.Messages.Create(new MessageCreateParams
  {
      Model = Model.ClaudeOpus5_5,
      MaxTokens = 1024,
      Speed = Speed.Fast,
      Messages = [new() { Role = Role.User, Content = "Hello" }],
  });

  Console.WriteLine(response.Usage.Speed);  // "fast" or "standard"
  ```

  ```go Go
  client := anthropic.NewClient()

  response, err := client.Messages.New(context.TODO(), anthropic.MessageNewParams{
  	Model:     anthropic.ModelClaudeOpus5_5,
  	MaxTokens: 1024,
  	Speed:     anthropic.MessageNewParamsSpeedFast,
  	Messages: []anthropic.MessageParam{
  		anthropic.NewUserMessage(anthropic.NewTextBlock("Hello")),
  	},
  })
  if err != nil {
  	log.Fatal(err)
  }
  fmt.Println(response.Usage.Speed) // "fast" or "standard"
  ```

  ```java Java
  AnthropicClient client = AnthropicOkHttpClient.fromEnv();

  MessageCreateParams params = MessageCreateParams.builder()
          .model(Model.CLAUDE_OPUS_5_5)
          .maxTokens(1024L)
          .speed(MessageCreateParams.Speed.FAST)
          .addUserMessage("Hello")
          .build();

  Message response = client.messages().create(params);
  IO.println(response.usage().speed().orElseThrow());  // "fast" or "standard"
  ```

  ```php PHP
  $client = new Client();

  $response = $client->messages->create(
      model: 'claude-opus-5-5',
      maxTokens: 1024,
      speed: 'fast',
      messages: [['role' => 'user', 'content' => 'Hello']],
  );

  echo $response->usage->speed;  // "fast" or "standard"
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  response = client.messages.create(
    model: "claude-opus-5-5",
    max_tokens: 1024,
    speed: "fast",
    messages: [{ role: "user", content: "Hello" }]
  )

  puts(response.usage.speed)  # "fast" or "standard"
  ```
</CodeGroup>

```json Output
{
  "id": "msg_01XFDUDYJgAACzvnptvVoYEL",
  "type": "message",
  "role": "assistant",
// ...
  "usage": {
    "input_tokens": 8,
    "output_tokens": 12,
    "speed": "fast"
  }
}
```

Per monitorare l'utilizzo e i costi della modalità veloce in tutta la tua organizzazione, consulta l'[Usage and Cost API](https://platform.claude.com/docs/it/manage-claude/usage-cost-api).

## Nuovi tentativi e fallback

### Nuovi tentativi automatici

Quando i limiti di velocità della modalità veloce vengono superati, l'API restituisce un errore `429` con un header `retry-after`. L'SDK ripete automaticamente queste richieste fino a 2 volte per impostazione predefinita (configurabile con `max_retries` (typescript, java, php: `maxRetries`; csharp: `MaxRetries`; go: `option.WithMaxRetries`)), attendendo il ritardo specificato dal server prima di ogni tentativo. Poiché la modalità veloce utilizza un rifornimento continuo dei token, il ritardo `retry-after` è in genere breve e le richieste hanno esito positivo non appena la capacità è disponibile.

### Ripiegare sulla velocità standard

Se preferisci ripiegare sulla velocità standard anziché attendere la capacità della modalità veloce, intercetta l'errore di limite di velocità e riprova senza `speed: "fast"`. Imposta `max_retries` (typescript, java, php: `maxRetries`; csharp: `MaxRetries`; go: `option.WithMaxRetries`) a `0` nella richiesta veloce iniziale per saltare i nuovi tentativi automatici e fallire immediatamente in caso di errori di limite di velocità.

<Note>
  Ripiegare dalla velocità veloce a quella standard comporterà un mancato riscontro nella [cache dei prompt](https://platform.claude.com/docs/it/build-with-claude/prompt-caching). Le richieste a velocità diverse non condividono i prefissi memorizzati nella cache.
</Note>

Poiché impostare `max_retries` (typescript, java, php: `maxRetries`; csharp: `MaxRetries`; go: `option.WithMaxRetries`) a `0` disabilita anche i nuovi tentativi per altri errori transitori (sovraccarico, errori interni del server), gli esempi seguenti riemettono la richiesta originale con i nuovi tentativi predefiniti per questi casi.

<CodeGroup exclude="shell:cURL">
  ```bash CLI
  # `ant` ritenta automaticamente in caso di 429/5xx e non ha un override max_retries
  # per singola richiesta, quindi con un 429 in modalità veloce il fallback parte dopo che i
  # tentativi integrati si esauriscono. --transform-error espone error.type per le diramazioni.
  create_message_with_fast_fallback() {
    local speed="$1" max_attempts="${2:-3}" body out
    body=${3:-$(cat)}
    out=$(
      ant messages create \
        ${speed:+--speed "$speed"} \
        --transform-error error.type --format-error yaml <<<"$body" 2>/dev/null
    ) && { printf '%s\n' "$out"; return; }
    case "$out" in
      rate_limit_error)
        if [[ -n "$speed" ]]; then
          create_message_with_fast_fallback "" "$max_attempts" "$body"
          return
        fi ;;
      overloaded_error | api_error | "")
        if (( max_attempts > 1 )); then
          create_message_with_fast_fallback "$speed" $((max_attempts - 1)) "$body"
          return
        fi ;;
    esac
    printf '%s\n' "${out:-connection_error}" >&2
    return 1
  }

  MESSAGE=$(
    create_message_with_fast_fallback fast <<'YAML'
  model: claude-opus-5-5
  max_tokens: 1024
  messages:
    - role: user
      content: Hello
  YAML
  )
  ```

  ```python Python
  client = anthropic.Anthropic()


  def create_message_with_fast_fallback(max_retries=0, max_attempts=3, **params):
      try:
          return client.with_options(max_retries=max_retries).messages.create(**params)
      except anthropic.RateLimitError:
          if params.get("speed") == "fast":
              del params["speed"]
              return create_message_with_fast_fallback(max_retries=max_retries, **params)
          raise
      except (
          anthropic.APIStatusError,
          anthropic.APIConnectionError,
      ) as error:
          if isinstance(error, anthropic.APIStatusError) and error.status_code < 500:
              raise
          if max_attempts > 1:
              return create_message_with_fast_fallback(
                  max_retries=max_retries, max_attempts=max_attempts - 1, **params
              )
          raise


  message = create_message_with_fast_fallback(
      model="claude-opus-5-5",
      max_tokens=1024,
      messages=[{"role": "user", "content": "Hello"}],
      speed="fast",
      max_retries=0,
  )
  ```

  ```typescript TypeScript
  const client = new Anthropic();

  async function createMessageWithFastFallback(
    params: Anthropic.MessageCreateParamsNonStreaming,
    requestOptions?: Anthropic.RequestOptions,
    maxAttempts: number = 3
  ): Promise<Anthropic.Message> {
    try {
      return await client.messages.create(params, requestOptions);
    } catch (e) {
      if (e instanceof Anthropic.RateLimitError && params.speed === "fast") {
        const { speed, ...rest } = params;
        return createMessageWithFastFallback(rest);
      }
      if (
        e instanceof Anthropic.InternalServerError ||
        e instanceof Anthropic.APIConnectionError
      ) {
        if (maxAttempts > 1) {
          return createMessageWithFastFallback(params, undefined, maxAttempts - 1);
        }
      }
      throw e;
    }
  }

  const message = await createMessageWithFastFallback(
    {
      model: "claude-opus-5-5",
      max_tokens: 1024,
      messages: [{ role: "user", content: "Hello" }],
      speed: "fast"
    },
    { maxRetries: 0 }
  );
  ```

  ```csharp C#
  AnthropicClient client = new();

  async Task<Message> CreateMessageWithFastFallback(
      MessageCreateParams parameters,
      int? maxRetries = null,
      int maxAttempts = 3)
  {
      try
      {
          var requestClient = maxRetries is int retries
              ? client.WithOptions(options => options with { MaxRetries = retries })
              : client;
          return await requestClient.Messages.Create(parameters);
      }
      catch (AnthropicRateLimitException)
      {
          if (parameters.Speed is not null)
          {
              return await CreateMessageWithFastFallback(
                  parameters with { Speed = null });
          }
          throw;
      }
      catch (Anthropic5xxException)
      {
          if (maxAttempts > 1)
          {
              return await CreateMessageWithFastFallback(
                  parameters, maxAttempts: maxAttempts - 1);
          }
          throw;
      }
  }

  var message = await CreateMessageWithFastFallback(
      new MessageCreateParams
      {
          Model = Model.ClaudeOpus5_5,
          MaxTokens = 1024,
          Messages = [new() { Role = Role.User, Content = "Hello" }],
          Speed = Speed.Fast,
      },
      maxRetries: 0);
  ```

  ```go Go
  func createMessageWithFastFallback(
  	ctx context.Context,
  	client *anthropic.Client,
  	params anthropic.MessageNewParams,
  	maxAttempts int,
  	opts ...option.RequestOption,
  ) (*anthropic.Message, error) {
  	message, err := client.Messages.New(ctx, params, opts...)
  	if err != nil {
  		var apierr *anthropic.Error
  		if errors.As(err, &apierr) && apierr.StatusCode == 429 && params.Speed != "" {
  			params.Speed = ""
  			return createMessageWithFastFallback(ctx, client, params, maxAttempts)
  		}
  		if (errors.As(err, &apierr) && apierr.StatusCode >= 500) || !errors.As(err, &apierr) {
  			if maxAttempts > 1 {
  				return createMessageWithFastFallback(ctx, client, params, maxAttempts-1)
  			}
  		}
  		return nil, err
  	}
  	return message, nil
  }

  func main() {
  	client := anthropic.NewClient()
  	message, err := createMessageWithFastFallback(
  		context.TODO(),
  		&client,
  		anthropic.MessageNewParams{
  			Model:     anthropic.ModelClaudeOpus5_5,
  			MaxTokens: 1024,
  			Messages: []anthropic.MessageParam{
  				anthropic.NewUserMessage(anthropic.NewTextBlock("Hello")),
  			},
  			Speed: anthropic.MessageNewParamsSpeedFast,
  		},
  		3,
  		option.WithMaxRetries(0),
  	)
  	if err != nil {
  		panic(err)
  	}
  	fmt.Println(message)
  }
  ```

  ```java Java
  import com.anthropic.errors.InternalServerException;
  import com.anthropic.errors.RateLimitException;
  // ...
  // Disattiva i tentativi automatici dell'SDK affinché li gestisca la logica di fallback sottostante
  AnthropicClient client =
          AnthropicOkHttpClient.builder().fromEnv().maxRetries(0).build();

  Message createMessageWithFastFallback(
          MessageCreateParams params, int maxAttempts) {
      try {
          return client.messages().create(params);
      } catch (RateLimitException e) {
          if (params.speed().isPresent()) {
              MessageCreateParams retryParams = params.toBuilder()
                      .speed(Optional.empty())
                      .build();
              return createMessageWithFastFallback(retryParams, maxAttempts);
          }
          throw e;
      } catch (InternalServerException e) {
          if (maxAttempts > 1) {
              return createMessageWithFastFallback(params, maxAttempts - 1);
          }
          throw e;
      }
  }

  void main() {
      Message message = createMessageWithFastFallback(
              MessageCreateParams.builder()
                      .model(Model.CLAUDE_OPUS_5_5)
                      .maxTokens(1024L)
                      .addUserMessage("Hello")
                      .speed(MessageCreateParams.Speed.FAST)
                      .build(),
              3);
      message.content().stream()
              .flatMap(block -> block.text().stream())
              .forEach(textBlock -> IO.println(textBlock.text()));
  }
  ```

  ```php PHP
  use Anthropic\Core\Exceptions\APIConnectionException;
  use Anthropic\Core\Exceptions\InternalServerException;
  use Anthropic\Core\Exceptions\RateLimitException;
  use Anthropic\RequestOptions;
  // ...
  $client = new Client();

  function createMessageWithFastFallback(
      Client $client,
      array $params,
      ?RequestOptions $requestOptions = null,
      int $maxAttempts = 3,
  ) {
      try {
          return $client->messages->create(
              ...$params,
              requestOptions: $requestOptions,
          );
      } catch (RateLimitException $e) {
          if (isset($params['speed'])) {
              unset($params['speed']);
              return createMessageWithFastFallback($client, $params);
          }
          throw $e;
      } catch (InternalServerException | APIConnectionException $e) {
          if ($maxAttempts > 1) {
              return createMessageWithFastFallback(
                  $client, $params, maxAttempts: $maxAttempts - 1
              );
          }
          throw $e;
      }
  }

  $message = createMessageWithFastFallback(
      $client,
      [
          'model' => 'claude-opus-5-5',
          'maxTokens' => 1024,
          'messages' => [['role' => 'user', 'content' => 'Hello']],
          'speed' => 'fast',
      ],
      RequestOptions::with(maxRetries: 0),
  );
  ```

  ```ruby Ruby
  client = Anthropic::Client.new

  def create_message_with_fast_fallback(client, request_options: {}, max_attempts: 3, **params)
    client.messages.create(**params, request_options: request_options)
  rescue Anthropic::Errors::RateLimitError
    raise unless params[:speed] == "fast"
    params.delete(:speed)
    create_message_with_fast_fallback(client, **params)
  rescue Anthropic::Errors::InternalServerError, Anthropic::Errors::APIConnectionError
    raise unless max_attempts > 1
    create_message_with_fast_fallback(client, max_attempts: max_attempts - 1, **params)
  end

  message = create_message_with_fast_fallback(
    client,
    model: "claude-opus-5-5",
    max_tokens: 1024,
    messages: [{ role: "user", content: "Hello" }],
    speed: "fast",
    request_options: { max_retries: 0 }
  )
  ```
</CodeGroup>

## Considerazioni

* **Cache dei prompt:** il passaggio tra velocità veloce e standard invalida la cache dei prompt. Le richieste a velocità diverse non condividono i prefissi memorizzati nella cache.
* **TTFT:** i vantaggi della modalità veloce riguardano i token di output al secondo (OTPS), non il tempo al primo token (TTFT).
* **Batch API:** la modalità veloce non è disponibile con la [Batch API](https://platform.claude.com/docs/it/build-with-claude/batch-processing).
* **Priority Tier:** la modalità veloce non è disponibile con un impegno [Priority Tier](https://platform.claude.com/docs/it/api/service-tiers).
* **Claude Platform on AWS:** la modalità veloce non è attualmente disponibile su [Claude Platform on AWS](https://platform.claude.com/docs/it/build-with-claude/claude-platform-on-aws).

## Prossimi passi

<CardGroup cols={2}>
  <Card title="Output strutturati" icon="code-brackets" href="https://platform.claude.com/docs/it/build-with-claude/structured-outputs">
    Ottieni risultati JSON validati dai flussi di lavoro degli agenti.
  </Card>

  <Card title="Prezzi" icon="calculator" href="https://platform.claude.com/docs/it/about-claude/pricing#fast-mode-pricing">
    Scopri la struttura dei prezzi di Anthropic per modelli e funzionalità.
  </Card>

  <Card title="Effort" icon="gauge" href="https://platform.claude.com/docs/it/build-with-claude/effort">
    Controlla quanti token Claude utilizza nelle risposte con il parametro effort, bilanciando tra completezza della risposta ed efficienza dei token.
  </Card>

  <Card title="Streaming dei messaggi" icon="arrow-right" href="https://platform.claude.com/docs/it/build-with-claude/streaming">
    Trasmetti in streaming le risposte della Messages API in modo incrementale con server-sent events, inclusi testo, uso degli strumenti e delta del ragionamento esteso.
  </Card>
</CardGroup>
