🛣️
Fastlane
  • 🛣️Fastlane
  • Publishers
    • Basic setup
    • Agent Verification Endpoint
  • Agent Developers
  • Apply as a publisher
  • Get developer access
Powered by GitBook
On this page
  • Step 1: Basic Setup
  • Step 2: Redirecting other requests to Fastlane
  • Additional verification (optional)
  1. Publishers

Basic setup

PreviousPublishersNextAgent Verification Endpoint

Last updated 3 days ago

Step 1: Basic Setup

The basic setup of Fastlane consists of whitelisting the Fastlane IP range in your firewall.

User Agent
IP Ranges
IP Ranges (CIDR)

Toolhouse-Fastlane/1.0.0

54.173.229.200 54.175.230.252

All Fastlane requests will always be generated from these IP ranges.

Every time you receive a GET request from these IP ranges, it means that Fastlane has already validated an agent and it has collected the access fee. You may also receive HEAD requests from the same IP ranges and user agent; these requests are used to validate that the content is found before attempting to charge the agent.

Step 2: Redirecting other requests to Fastlane

You can then redirect other agents to Fastlane at the WAF level. You can also block any requests if you prefer.

Cloudflare Workers Example
// List of known agents to forward immediately. You can change this list.
const agentList = [
  'ChatGPT-User',
  'PerplexityBot',
  'GPTBot',
  'anthropic-ai',
  'CCBot',
  'Claude-Web',
  'ClaudeBot',
  'cohere-ai',
  'YouBot',
  'Diffbot',
  'OAI-SearchBot',
  'meta-externalagent',
  'Timpibot',
  'Amazonbot',
  'Bytespider',
  'Perplexity-User',
];

const CF_APP_VERSION = '1.0.0';

const sleep = (ms) => {
  return new Promise((resolve) => {
    setTimeout(resolve, ms);
  });
};

const makeid = (length) => {
  let text = '';
  const possible = 'ABCDEFGHIJKLMNPQRSTUVWXYZ0123456789';
  for (let i = 0; i < length; i += 1) {
    text += possible.charAt(Math.floor(Math.random() * possible.length));
  }
  return text;
};

const WORKER_ID = makeid(6);

// Forwarding
const handleRequest = async (event) => {
  const { request } = event;
  const isAgentRequest = checkIfAgentRequest(request);

  if (isAgentRequest) {
    const path = request.url.replace(`https://${request.headers.get('host')}`, '');
    let host = request.headers.get('host') || '';
    if (host.startsWith('www.')) {
      host = host.slice(4);
    }
    return Response.redirect(`https://fastlane.toolhouse.ai${path}`, 302);
  } else {
    return await fetch(request);
  }
};

const checkIfAgentRequest = (request) => {
  const userAgent = request.headers.get('User-Agent') || '';

  return agentList.some((agent) => userAgent.toLowerCase().includes(agent.toLowerCase()));
};

addEventListener('fetch', (event) => {
  event.passThroughOnException();
  event.respondWith(handleRequest(event));
});

Additional verification (optional)

Additionally, Fastlane will always send a X-Fastlane-Token header which identifies the agent and the request. For an additional (but optional) layer of security, you can use the Agent Verification Endpoint to check that the request

fastlane.json