Skip to content
Docs

AI Gateway Fast Mode

Some models expose a faster serving path that trades a higher per-token cost for lower latency. You can request this fast tier through AI Gateway with the unified gateway.speed option or by using a fast slug.

Requesting speed: 'fast' on a model that has no fast tier has no effect. The request runs at standard speed. See the supported models below for the current list.

Fast mode is available for a growing set of models. Find the supported fast mode models in the AI Gateway models list. Use a model's fast slug, or set speed: 'fast' on the base model.

There are two ways to request fast mode, and they produce the same result:

  • gateway.speed: 'fast': A unified option that upgrades the primary model to its fast serving path when one is routable. For example, anthropic/claude-opus-5 with speed: 'fast' behaves like calling anthropic/claude-opus-5-fast, and moonshotai/kimi-k2.7-code with speed: 'fast' routes to that model's fast slug.
  • An explicit fast slug: Address the fast variant directly using its fast slug. This is the same as setting speed: 'fast' on the base model.

Use the speed option when you want one configuration that stays on the base model ID and falls back to standard speed if fast mode is not available. Use an explicit fast slug when you want to name the fast variant directly, such as in a gateway.models fallback list.

These examples use AI SDK 7 and the AI SDK for Python beta. Set AI_GATEWAY_API_KEY before running them. See API format differences for setup, request fields, and response handling.

fast-mode.ts
import { generateText } from 'ai';
 
const { text } = await generateText({
  model: 'anthropic/claude-opus-5',
  prompt: 'Explain quantum computing in two sentences.',
  providerOptions: {
    gateway: {
      speed: 'fast',
    },
  },
});
 
console.log(text);
fast-mode_ai.py
import asyncio
import ai
 
async def main():
    model = ai.get_model("anthropic/claude-opus-5")
    messages = [ai.user_message("Explain quantum computing in two sentences.")]
    params = ai.InferenceRequestParams(
        extra_body={"providerOptions": {"gateway": {"speed": "fast"}}}
    )
    async with ai.stream(model, messages, params=params) as stream:
        async for event in stream:
            if isinstance(event, ai.events.TextDelta):
                print(event.chunk, end="", flush=True)
    print()
 
asyncio.run(main())
fast-mode-chat.ts
import OpenAI from 'openai';
 
const client = new OpenAI({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh/v1',
});
 
const response = await client.chat.completions.create({
  model: 'anthropic/claude-opus-5',
  messages: [
    {
      role: 'user',
      content: 'Explain quantum computing in two sentences.',
    },
  ],
  // AI Gateway extension fields are not included in the upstream SDK types.
  ...{
    providerOptions: {
      gateway: {
        speed: 'fast',
      },
    },
  },
});
 
console.log(response.choices[0]?.message.content);
fast-mode_chat.py
import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.environ["AI_GATEWAY_API_KEY"],
    base_url="https://ai-gateway.vercel.sh/v1",
)
 
response = client.chat.completions.create(
    model="anthropic/claude-opus-5",
    messages=[{"role": "user", "content": "Explain quantum computing in two sentences."}],
    extra_body={"providerOptions": {"gateway": {"speed": "fast"}}},
)
 
print(response.choices[0].message.content)
fast-mode-chat.sh
curl --fail-with-body https://ai-gateway.vercel.sh/v1/chat/completions \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "anthropic/claude-opus-5",
  "messages": [
    {
      "role": "user",
      "content": "Explain quantum computing in two sentences."
    }
  ],
  "providerOptions": {
    "gateway": {
      "speed": "fast"
    }
  }
}'
fast-mode-messages.ts
import Anthropic from '@anthropic-ai/sdk';
 
const client = new Anthropic({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh',
});
 
const response = await client.messages.create({
  model: 'anthropic/claude-opus-5',
  messages: [
    {
      role: 'user',
      content: 'Explain quantum computing in two sentences.',
    },
  ],
  max_tokens: 1024,
  ...{
    providerOptions: {
      gateway: {
        speed: 'fast',
      },
    },
  },
});
 
for (const block of response.content) {
  if (block.type === 'text') console.log(block.text);
}
fast-mode_messages.py
import os
from anthropic import Anthropic
 
client = Anthropic(
    api_key=os.environ["AI_GATEWAY_API_KEY"],
    base_url="https://ai-gateway.vercel.sh",
)
 
response = client.messages.create(
    model="anthropic/claude-opus-5",
    messages=[{"role": "user", "content": "Explain quantum computing in two sentences."}],
    max_tokens=1024,
    extra_body={"providerOptions": {"gateway": {"speed": "fast"}}},
)
 
for block in response.content:
    if block.type == "text":
        print(block.text)
fast-mode-messages.sh
curl --fail-with-body https://ai-gateway.vercel.sh/v1/messages \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
  "model": "anthropic/claude-opus-5",
  "messages": [
    {
      "role": "user",
      "content": "Explain quantum computing in two sentences."
    }
  ],
  "max_tokens": 1024,
  "providerOptions": {
    "gateway": {
      "speed": "fast"
    }
  }
}'
fast-mode-responses.ts
import OpenAI from 'openai';
 
const client = new OpenAI({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh/v1',
});
 
const response = await client.responses.create({
  model: 'anthropic/claude-opus-5',
  input: 'Explain quantum computing in two sentences.',
  ...{
    providerOptions: {
      gateway: {
        speed: 'fast',
      },
    },
  },
});
 
console.log(response.output_text);
fast-mode_responses.py
import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.environ["AI_GATEWAY_API_KEY"],
    base_url="https://ai-gateway.vercel.sh/v1",
)
 
response = client.responses.create(
    model="anthropic/claude-opus-5",
    input="Explain quantum computing in two sentences.",
    extra_body={"providerOptions": {"gateway": {"speed": "fast"}}},
)
 
print(response.output_text)
fast-mode-responses.sh
curl --fail-with-body https://ai-gateway.vercel.sh/v1/responses \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "anthropic/claude-opus-5",
  "input": "Explain quantum computing in two sentences.",
  "providerOptions": {
    "gateway": {
      "speed": "fast"
    }
  }
}'

Use any fast slug from the supported models list.

fast-slug.ts
import { generateText } from 'ai';
 
const { text } = await generateText({
  model: "anthropic/claude-opus-5-fast",
  prompt: "Explain quantum computing in two sentences.",
});
 
console.log(text);
fast-slug_ai.py
import asyncio
import ai
 
async def main():
    model = ai.get_model("anthropic/claude-opus-5-fast")
    messages = [ai.user_message("Explain quantum computing in two sentences.")]
    async with ai.stream(model, messages) as stream:
        async for event in stream:
            if isinstance(event, ai.events.TextDelta):
                print(event.chunk, end="", flush=True)
    print()
 
asyncio.run(main())
fast-slug-chat.ts
import OpenAI from 'openai';
 
const client = new OpenAI({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh/v1',
});
 
const response = await client.chat.completions.create({
  model: 'anthropic/claude-opus-5-fast',
  messages: [
    {
      role: 'user',
      content: 'Explain quantum computing in two sentences.',
    },
  ],
});
 
console.log(response.choices[0]?.message.content);
fast-slug_chat.py
import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.environ["AI_GATEWAY_API_KEY"],
    base_url="https://ai-gateway.vercel.sh/v1",
)
 
response = client.chat.completions.create(
    model="anthropic/claude-opus-5-fast",
    messages=[{"role": "user", "content": "Explain quantum computing in two sentences."}],
)
 
print(response.choices[0].message.content)
fast-slug-chat.sh
curl --fail-with-body https://ai-gateway.vercel.sh/v1/chat/completions \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "anthropic/claude-opus-5-fast",
  "messages": [
    {
      "role": "user",
      "content": "Explain quantum computing in two sentences."
    }
  ]
}'
fast-slug-messages.ts
import Anthropic from '@anthropic-ai/sdk';
 
const client = new Anthropic({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh',
});
 
const response = await client.messages.create({
  model: 'anthropic/claude-opus-5-fast',
  messages: [
    {
      role: 'user',
      content: 'Explain quantum computing in two sentences.',
    },
  ],
  max_tokens: 1024,
});
 
for (const block of response.content) {
  if (block.type === 'text') console.log(block.text);
}
fast-slug_messages.py
import os
from anthropic import Anthropic
 
client = Anthropic(
    api_key=os.environ["AI_GATEWAY_API_KEY"],
    base_url="https://ai-gateway.vercel.sh",
)
 
response = client.messages.create(
    model="anthropic/claude-opus-5-fast",
    messages=[{"role": "user", "content": "Explain quantum computing in two sentences."}],
    max_tokens=1024,
)
 
for block in response.content:
    if block.type == "text":
        print(block.text)
fast-slug-messages.sh
curl --fail-with-body https://ai-gateway.vercel.sh/v1/messages \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
  "model": "anthropic/claude-opus-5-fast",
  "messages": [
    {
      "role": "user",
      "content": "Explain quantum computing in two sentences."
    }
  ],
  "max_tokens": 1024
}'
fast-slug-responses.ts
import OpenAI from 'openai';
 
const client = new OpenAI({
  apiKey: process.env.AI_GATEWAY_API_KEY,
  baseURL: 'https://ai-gateway.vercel.sh/v1',
});
 
const response = await client.responses.create({
  model: "anthropic/claude-opus-5-fast",
  input: "Explain quantum computing in two sentences.",
});
 
console.log(response.output_text);
fast-slug_responses.py
import os
from openai import OpenAI
 
client = OpenAI(
    api_key=os.environ["AI_GATEWAY_API_KEY"],
    base_url="https://ai-gateway.vercel.sh/v1",
)
 
response = client.responses.create(
    model="anthropic/claude-opus-5-fast",
    input="Explain quantum computing in two sentences.",
)
 
print(response.output_text)
fast-slug-responses.sh
curl --fail-with-body https://ai-gateway.vercel.sh/v1/responses \
  -H "Authorization: Bearer $AI_GATEWAY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "anthropic/claude-opus-5-fast",
  "input": "Explain quantum computing in two sentences."
}'

By default, a fast-tier request automatically falls back to the base model when the fast tier is exhausted. For a model served by more than one provider, AI Gateway first tries the fast tier on every provider that supports it, and only then falls back to the base model on the providers that serve it. This base fallback is tried before any explicit gateway.models fallbacks and is de-duplicated against them.

Set gateway.allowFallbackFromFast: false to opt out and get fast-or-fail behavior, where the request errors instead of falling back to standard speed.

app/api/chat/route.ts
import { generateText } from 'ai';
 
const { text, providerMetadata } = await generateText({
  model: 'anthropic/claude-opus-5',
  prompt: 'Explain quantum computing in two sentences.',
  providerOptions: {
    gateway: {
      speed: 'fast',
      // Do not fall back to standard speed if the fast tier is unavailable.
      allowFallbackFromFast: false,
    },
  },
});
 
console.log(text);
const routing = providerMetadata?.gateway?.routing;
console.log('Served speed:',
  typeof routing === 'object' && routing !== null && !Array.isArray(routing)
    ? routing.speed
    : undefined,
);

The tier the provider actually served appears on the response as providerMetadata.gateway.routing.speed in the AI SDK, or provider_metadata.gateway.routing.speed on Chat Completions, OpenAI Responses, and Anthropic Messages responses. AI Gateway only sets this field to fast when the request was genuinely served fast, not merely routed to a fast variant slug. If the request was served at standard speed (for example, after falling back to the base model), the field is omitted, so a missing value is an honest signal that you weren't billed at the fast rate.

const { providerMetadata } = await generateText({
  model: 'anthropic/claude-opus-5',
  prompt: 'Hello',
  providerOptions: {
    gateway: {
      speed: 'fast',
    },
  },
});
 
// 'fast' if served fast, undefined otherwise.
console.log(providerMetadata?.gateway?.routing?.speed);

Fast mode works the same way with streaming. Read providerMetadata.gateway.routing.speed from the awaited result once the stream completes.

app/api/chat/route.ts
import { streamText } from 'ai';
 
const result = streamText({
  model: 'anthropic/claude-opus-5',
  prompt: 'Explain quantum computing in two sentences.',
  providerOptions: {
    gateway: {
      speed: 'fast',
    },
  },
});
 
for await (const textPart of result.textStream) {
  process.stdout.write(textPart);
}
 
const [usage, providerMetadata] = await Promise.all([result.usage, result.providerMetadata]);
const routing = providerMetadata?.gateway?.routing;
console.log('Served speed:',
  typeof routing === 'object' && routing !== null && !Array.isArray(routing)
    ? routing.speed
    : undefined,
);
console.log('Usage:', usage);

For models native to Claude Code (Anthropic Opus), you can toggle fast mode interactively with /fast after completing the setup in Claude Code.

For non-Anthropic models, or if you prefer not to configure Claude Code's fast mode settings, select the fast variant in your agent's model configuration. Use a fast slug from the supported models list, such as anthropic/claude-opus-5-fast, zai/glm-5.2-fast, or moonshotai/kimi-k2.7-code-highspeed.

AI Gateway adjusts pricing based on the speed the provider actually served. For current fast mode rates, refer to the AI Gateway models list.

Pin fast mode on a virtual model to serve all of its traffic on the fast tier, with optional fallback to the base model, or pick the model's (Fast) variant as the slug's target model.

Last updated September 10, 2026

Was this helpful?

supported.