> ## Documentation Index
> Fetch the complete documentation index at: https://docs.dgrid.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AI Gateway

> DGrid AI Gateway provides one unified, OpenAI-compatible API to call 200+ leading AI models with crypto billing, routing, and global edge access.

DGrid AI Gateway provides a single, unified API to access 200+ leading AI models. Users can directly plug their own API keys into tools like Claude Code, Codex, and Moltbot (Clawdbot), which dramatically reduces integration complexity and operational costs.

## Manage funding and notifications

> [card] [Auto Deposit](https://docs.dgrid.ai/ai-gateway/auto-deposit.md)
>
> Automatically replenish your recharge balance from a funding wallet and manage your cumulative USDT authorization.

> [card] [Notifications](https://docs.dgrid.ai/ai-gateway/notifications.md)
>
> Set up email, Lark, or a custom Webhook for balance alerts and Auto Deposit results.

## Quickstart

DGrid AI Gateway unifies the interfaces of hundreds of AI models. You don't need to handle compatibility adaptations for different models in your code—with a single API endpoint and a standardized API request format, you can freely switch and access all the hundreds of models provided by DGrid.

> [!TIP]
>
> Looking for tool-specific guides (OpenClaw / Cursor / SDK / etc.)? See [Integration Tutorials](https://docs.dgrid.ai/ai-gateway/integrations.md).

> [!TIP]
>
> Looking for endpoint-level API reference? See [Model API](https://docs.dgrid.ai/api-reference/introduction.md).

> [!TIP]
>
> Want a free route that chooses available model capacity automatically? See [Free Models Router](https://docs.dgrid.ai/ai-gateway/free-models-router.md).

> [!NOTE]
>
> The DGrid official SDK is currently under active development—stay tuned for its release. Below are the available temporary request methods to interact with DGrid AI Gateway.

### Prerequisites

Before getting started, you need to:

1. Obtain a valid `DGRID_API_KEY` ([Guide](https://blog.dgrid.ai/posts/2026-01-04/)).
2. Ensure your development environment has network access to `https://api.dgrid.ai/v1`.
3. For SDK usage, install the corresponding OpenAI SDK package in your project.

### Direct API Request via cURL

You can send a direct HTTP POST request to the DGrid AI Gateway endpoint using cURL.

```bash theme={null}
curl https://api.dgrid.ai/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $DGRID_API_KEY" \
  -d '{
  "model": "openai/gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "What is the meaning of life?"
    }
  ]
}'
```

### Using the OpenAI SDK (DGrid Compatible)

DGrid AI Gateway is fully compatible with the OpenAI SDK specification. You only need to modify the `baseURL` (and fill in the `DGRID_API_KEY`) to quickly migrate or integrate.

#### Prerequisite: Install the OpenAI SDK

First, install the OpenAI SDK in your project:

```bash theme={null}
# For TypeScript/Node.js
npm install openai

# For Python
pip install openai
```

#### TypeScript Implementation

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

// Initialize the OpenAI client with DGrid AI Gateway configuration
const openai = new OpenAI({
  baseURL: 'https://api.dgrid.ai/v1', // Point to DGrid AI Gateway endpoint
  apiKey: '<DGRID_API_KEY>', // Replace with your valid DGrid API key
  defaultHeaders: {
    'HTTP-Referer': '<YOUR_SITE_URL>', // Optional: Your application's site URL
    'X-Title': '<YOUR_SITE_NAME>', // Optional: Your application's name
  },
});

// Async function to send chat completion request
async function getChatCompletion() {
  const completion = await openai.chat.completions.create({
    model: 'openai/gpt-4o', // Specify the target model (DGrid-supported format)
    messages: [
      {
        role: 'user',
        content: 'What is the meaning of life?',
      },
    ],
  });

  // Print the response result
  console.log(completion.choices[0].message);
}

getChatCompletion();
```

#### Python Implementation

```python theme={null}
from openai import OpenAI

# Initialize the OpenAI client with DGrid AI Gateway configuration
client = OpenAI(
  base_url="https://api.dgrid.ai/v1", # Point to DGrid AI Gateway endpoint
  api_key="<DGRID_API_KEY>", # Replace with your valid DGrid API key
)
completion = client.chat.completions.create(
    extra_headers={
        "HTTP-Referer": "<YOUR_SITE_URL>", # Optional: Your application's site URL
        "X-Title": "<YOUR_SITE_NAME>", # Optional: Your application's name
    },
    model="openai/gpt-4o", # Specify the target model (DGrid-supported format)
    messages=[
        {
            "role": "user",
            "content": "What is the meaning of life?"
        }
    ]
)

# Print the response content
print(completion.choices[0].message.content)
```

### Additional Notes

1. **Optional Headers**: The `HTTP-Referer` and `X-Title` headers are optional, but filling them in helps DGrid better identify your application and provide more optimized service support.
2. **Model Naming Format**: The model parameter uses the format `[provider]/[model-name]` (e.g., `openai/gpt-4o`), which is consistent across all DGrid-supported models for easy switching.
3. **SDK Development Update**: The official DGrid SDK is under development and will provide more native features and optimized performance—please pay attention to the official DGrid documentation updates for release information.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.