---
title: AI Gateway
description: Access 340+ AI models through a single, OpenAI-compatible API
---

# AI Gateway

Agnic's AI Gateway provides access to **340+ AI models** from leading providers through a single, OpenAI-compatible API. Pay-per-use with your Agnic Wallet balance.

## What is the AI Gateway?

The AI Gateway is a unified API that gives you access to models from:

- **OpenAI** - GPT-4o, GPT-4 Turbo, o1
- **Anthropic** - Claude 3.5 Sonnet, Claude 3 Opus
- **Google** - Gemini Pro, Gemini 1.5 Pro, Gemini 2.0 Flash
- **Meta** - Llama 3.3 70B, Llama 3.1 405B
- **Plus 300+ more** from Mistral, DeepSeek, Qwen, and others

## Key Features

<Cards>
  <Card title="OpenAI Compatible" icon="code">
    Drop-in replacement for OpenAI SDK. Just change your base URL.
  </Card>
  <Card title="340+ Models" icon="cpu">
    Access models from every major AI provider in one place.
  </Card>
  <Card title="Pay Per Use" icon="credit-card">
    No subscriptions. Pay only for what you use from your USDC balance.
  </Card>
  <Card title="Free Models" icon="gift">
    Access Llama, Gemma, and Mistral models completely free.
  </Card>
</Cards>

## How It Works

```mermaid
graph LR
    A[Your App] --> B[Agnic AI Gateway]
    B --> C[OpenAI]
    B --> D[Anthropic]
    B --> E[Google]
    B --> F[Meta/Llama]
    B --> G[300+ Others]
```

1. **Send requests** to `https://api.agnic.ai/v1`
2. **Use your Agnic token** for authentication
3. **Choose any model** from 340+ available options
4. **Pay per request** - costs deducted from your USDC balance

## Quick Example

```python
from openai import OpenAI

client = OpenAI(
    api_key="agnic_tok_YOUR_TOKEN",
    base_url="https://api.agnic.ai/v1"
)

response = client.chat.completions.create(
    model="openai/gpt-4o",  # or anthropic/claude-3.5-sonnet, etc.
    messages=[{"role": "user", "content": "Hello!"}]
)

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

## Base URL

All AI Gateway endpoints use:

```
https://api.agnic.ai/v1
```

## Authentication

Use either authentication method:

| Method | Header | Token Format |
|--------|--------|--------------|
| API Token | `Authorization: Bearer {token}` | `agnic_tok_...` |
| OAuth2 | `Authorization: Bearer {token}` | `agnic_at_...` |
| Alternative | `X-Agnic-Token: {token}` | `agnic_tok_...` |

## Pricing

Costs vary by model and are charged per token. We offer many **free models** including Llama, Gemma, and Mistral for development and testing.

<Callout type="info">
  View the complete list of 340+ models with live pricing at [**AI Gateway Pricing**](https://app.agnic.ai/ai-gateway/pricing).
</Callout>

## Spending Limits

Control your costs with built-in spending limits:

- **Per-transaction limit** - Maximum cost per API call
- **Daily limit** - Total spend allowed per day
- **Monthly limit** - Total spend allowed per month

Configure limits when creating your API token or during OAuth authorization.

## Next Steps

<Cards>
  <Card title="Available Models" href="/docs/ai-gateway/models" />
  <Card title="Quick Start" href="/docs/ai-gateway/quickstart" />
  <Card title="SDK Examples" href="/docs/ai-gateway/sdks" />
  <Card title="Streaming" href="/docs/ai-gateway/streaming" />
</Cards>
