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

# Use Moonshot AI with the AI Gateway

> Call Moonshot AI Kimi models through the ngrok AI Gateway with ngrok.ai credits or your own Moonshot AI API key.

[Moonshot AI](https://www.moonshot.ai) builds the Kimi family of models.

Moonshot AI supports Chat Completions requests.

> [!NOTE]
>
> Moonshot AI is a **built-in provider** you can pay for with credits, so a provider key is optional.
> Add your own Moonshot AI key to bill usage to your Moonshot AI account instead of your ngrok.ai credits.

## Setup

### 1. Create an access key and add credits

Follow the [quickstart](https://ngrok.com/docs/ai-gateway/quickstart.md) to create an access key and purchase [credits](https://ngrok.com/docs/ai-gateway/concepts/credits.md) in [app.ngrok.ai](https://app.ngrok.ai).

### 2. Store your Moonshot AI API key (optional)

Skip this step to pay with credits.
To bring your own key, create an API key in your [Moonshot AI](https://www.moonshot.ai) account.
Then [add a provider key](https://ngrok.com/docs/ai-gateway/guides/attaching-provider-keys.md#add-a-provider-key) and [create an access key configuration](https://ngrok.com/docs/ai-gateway/guides/access-key-configurations.md#create-a-configuration) with a `moonshotai` routing rule that uses it.

### 3. Send requests

Send requests with your access key:

```python theme={"theme":{"light":"css-variables","dark":"css-variables"}}
from openai import OpenAI

client = OpenAI(
    base_url="https://gateway.ngrok.ai/v1",
    api_key="ng-xxxxx-g1-xxxxx",
)

response = client.chat.completions.create(
    model="moonshotai:kimi-k3",
    messages=[{"role": "user", "content": "Hello!"}]
)
```

QwenCloud and Tencent TokenHub also serve Kimi models, so the `moonshotai:` prefix keeps the request on Moonshot AI.

## Available models

See the [model catalog](https://ngrok.com/docs/ai-gateway/reference/model-catalog.md#moonshot-ai).

## Next steps

* [Provider keys](https://ngrok.com/docs/ai-gateway/guides/attaching-provider-keys.md)
* [Access key configurations](https://ngrok.com/docs/ai-gateway/guides/access-key-configurations.md)


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