> ## Documentation Index
> Fetch the complete documentation index at: https://mintlify.com/cheahjs/free-llm-api-resources/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI Gateway

> Free AI gateway routing to various supported providers

<Note>
  Vercel AI Gateway provides a unified interface to route requests to various AI providers with free monthly credits.
</Note>

## Overview

Vercel AI Gateway acts as a single endpoint that routes your AI requests to various supported providers, offering features like caching, rate limiting, and observability.

## Rate Limits

<Info>
  **Monthly Credits**: \$5/month in free credits
</Info>

[View detailed pricing](https://vercel.com/docs/ai-gateway/pricing)

## Supported Providers

Vercel AI Gateway can route to multiple AI providers:

<CardGroup cols={3}>
  <Card title="OpenAI" icon="openai">
    GPT models and embeddings
  </Card>

  <Card title="Anthropic" icon="robot">
    Claude models
  </Card>

  <Card title="Google" icon="google">
    Gemini models
  </Card>

  <Card title="Mistral" icon="m">
    Mistral models
  </Card>

  <Card title="Cohere" icon="c">
    Command models
  </Card>

  <Card title="Groq" icon="g">
    Fast inference models
  </Card>
</CardGroup>

## API Usage

<CodeGroup>
  ```python Python theme={null}
  import openai

  client = openai.OpenAI(
      base_url="https://gateway.ai.cloudflare.com/v1/YOUR_ACCOUNT_ID/YOUR_GATEWAY/openai",
      api_key="YOUR_OPENAI_API_KEY"
  )

  response = client.chat.completions.create(
      model="gpt-4",
      messages=[
          {"role": "user", "content": "Hello, how are you?"}
      ]
  )

  print(response.choices[0].message.content)
  ```

  ```javascript JavaScript theme={null}
  import OpenAI from 'openai';

  const client = new OpenAI({
      baseURL: 'https://gateway.ai.cloudflare.com/v1/YOUR_ACCOUNT_ID/YOUR_GATEWAY/openai',
      apiKey: process.env.OPENAI_API_KEY
  });

  const response = await client.chat.completions.create({
      model: 'gpt-4',
      messages: [
          { role: 'user', content: 'Hello, how are you?' }
      ]
  });

  console.log(response.choices[0].message.content);
  ```

  ```bash cURL theme={null}
  curl https://gateway.ai.cloudflare.com/v1/YOUR_ACCOUNT_ID/YOUR_GATEWAY/openai/chat/completions \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer YOUR_OPENAI_API_KEY" \
    -d '{
      "model": "gpt-4",
      "messages": [
        {"role": "user", "content": "Hello, how are you?"}
      ]
    }'
  ```
</CodeGroup>

## Getting Started

<Steps>
  <Step title="Create Vercel Account">
    Sign up at [vercel.com](https://vercel.com)
  </Step>

  <Step title="Create AI Gateway">
    Set up a new AI Gateway from your dashboard
  </Step>

  <Step title="Configure Providers">
    Add API keys for the providers you want to use
  </Step>

  <Step title="Update Endpoint">
    Point your AI requests to the gateway endpoint
  </Step>
</Steps>

## Key Features

<CardGroup cols={2}>
  <Card title="Unified Interface" icon="layer-group">
    Single endpoint for multiple providers
  </Card>

  <Card title="Caching" icon="database">
    Cache responses to reduce costs
  </Card>

  <Card title="Rate Limiting" icon="gauge">
    Control request rates across providers
  </Card>

  <Card title="Observability" icon="chart-line">
    Monitor usage and performance
  </Card>

  <Card title="Fallbacks" icon="arrows-rotate">
    Automatic failover between providers
  </Card>

  <Card title="Cost Tracking" icon="dollar-sign">
    Track spending across providers
  </Card>
</CardGroup>

## Use Cases

<Info>
  * **Multi-Provider Apps**: Use different models for different tasks
  * **Cost Optimization**: Cache responses and track spending
  * **Reliability**: Implement failover strategies
  * **Development**: Test different providers easily
  * **Rate Limiting**: Protect your applications from overuse
</Info>

## Benefits

* No need to manage multiple SDKs
* Built-in caching reduces API costs
* Centralized observability and analytics
* Easy provider switching without code changes
* Automatic rate limiting and quota management

## Additional Resources

<CardGroup cols={2}>
  <Card title="Vercel Dashboard" icon="browser" href="https://vercel.com/dashboard">
    Manage your AI Gateway
  </Card>

  <Card title="Documentation" icon="book" href="https://vercel.com/docs/ai-gateway">
    Official documentation
  </Card>

  <Card title="Pricing" icon="dollar-sign" href="https://vercel.com/docs/ai-gateway/pricing">
    Detailed pricing information
  </Card>

  <Card title="Supported Providers" icon="plug" href="https://vercel.com/docs/ai-gateway/providers">
    View all supported providers
  </Card>
</CardGroup>
