DocsOpen Moon AI
Browse the docs

Quickstart

Create a key, fund the workspace wallet, install the OpenAI SDK and send your first request to the Moon AI API, step by step.

On this page

Before you beginLink to the Before you begin section

  • A Moon AI account that is the owner or an admin of the workspace that will pay for the requests.
  • Python or Node.js, in a version supported by the official OpenAI SDK (or curl).

1. Open the portalLink to the 1. Open the portal section

Open “Settings” › “Developer API”, in the “Tools” group, or search for “Developer API” with CtrlK. The portal opens on the “Overview” tab (open the portal).

2. Fund the walletLink to the 2. Fund the wallet section

Requests are charged to the workspace wallet. If your plan includes API credit, it is added to the balance at the start of each plan period (see Included API credit). Otherwise, or in addition:

  1. Open “Billing” (open).
  2. Under “Top up”, pick an “Amount to add” or enter an “Other amount”.
  3. Check the summary (“You receive”, “Total due excl. VAT”). VAT is added at checkout based on your billing address.
  4. Click “Continue to payment” and pay by card. Your balance is credited as soon as the payment is confirmed.

Top-ups, fees and invoices are covered in Costs and wallet.

3. Create a keyLink to the 3. Create a key section

  1. Open “API keys” (open).
  2. In “Create an API key”, give the key a “Name”, for example the name of the app that will use it.
  3. Click “Create key”.
  4. The “Save your API key” window shows the sk-moon-… key. Copy it, store it in a secrets manager, then click “I have saved my key”.

4. Install the SDKLink to the 4. Install the SDK section

The API is compatible with the official OpenAI SDKs: you don’t need a Moon AI-specific SDK.

cURL
# Nothing to install: curl is all you need.
curl --version
Python
pip install openai
JavaScript
npm install openai

5. Put the key in the environmentLink to the 5. Put the key in the environment section

Never paste the key into your code or a Git repository. Keep it in an environment variable; the examples read MOONAI_API_KEY, like the ones in the portal:

Terminal
export MOONAI_API_KEY="sk-moon-..."

6. Send your first requestLink to the 6. Send your first request section

The example calls anthropic/claude-haiku-4.5. Any ID listed by GET /v1/models works; you can read the current list in the “Models” tab or through the API (see Models).

cURL
curl https://api.realmoon.ai/v1/chat/completions \
  -H "Authorization: Bearer $MOONAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
        "model": "anthropic/claude-haiku-4.5",
        "messages": [{"role": "user", "content": "Hello"}]
      }'
Python
import os
from openai import OpenAI

client = OpenAI(
    base_url="https://api.realmoon.ai/v1",
    api_key=os.environ["MOONAI_API_KEY"],
)

response = client.chat.completions.create(
    model="anthropic/claude-haiku-4.5",
    messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
JavaScript
import OpenAI from 'openai';

const client = new OpenAI({
  baseURL: 'https://api.realmoon.ai/v1',
  apiKey: process.env.MOONAI_API_KEY,
});

const response = await client.chat.completions.create({
  model: 'anthropic/claude-haiku-4.5',
  messages: [{ role: 'user', content: 'Hello' }],
});
console.log(response.choices[0].message.content);

7. Read the responseLink to the 7. Read the response section

The response has the shape of an OpenAI chat completion.

Response
{
  "id": "gen-6f1c2b7e9a4d4c0e8b3a5d2f1e0c9b8a",
  "object": "chat.completion",
  "created": 1793577600,
  "model": "anthropic/claude-haiku-4.5",
  "choices": [
    {
      "index": 0,
      "message": { "role": "assistant", "content": "Hello. How can I help you?" },
      "finish_reason": "stop"
    }
  ],
  "usage": { "prompt_tokens": 9, "completion_tokens": 12, "total_tokens": 21 }
}
  • id is the request ID at Moon AI. Use it to look up the request’s cost with GET /v1/generation?id=… (see Balance and request cost).
  • usage gives the tokens, not the cost.
  • model is the ID you called, or the exact name of the version the provider served. For a Moon AI in-house model, it is always the Moon AI ID.

The response also carries Moon AI-specific headers:

Response headers
X-Moon-Request-Id: gen-6f1c2b7e9a4d4c0e8b3a5d2f1e0c9b8a
X-Moon-Prompt-Storage: none
X-Moon-Blur: on

X-Moon-Blur: on means Moon Blur scanned the request; X-Moon-Blur-Redactions is added when it replaced values. The full list is in Authentication.

A few seconds after the call, the request shows up in “Overview” › “Recent requests” and in “Usage” › “Request log”, without its content.

See alsoLink to the See also section

Moon AI

Moon AI in action

0:00

Explore

Screenshots of chat.realmoon.ai taken on October 29, 2026, with fictional data.

Moon AI

Your preferences

Visits counted without cookies.

Our server counts visits without cookies or trackers. Your theme and your answer about ad measurement are remembered on this device.

Ad measurement

With your consent, our ad networks’ trackers (Google) measure our ads, from the visit to the sign-up and then to the first subscription and its amount, and may show you our ads. Your answer is valid for 13 months; you can change it here at any time.

No answer saved on this device.

After you decline, no tag is loaded anymore and the site deletes the cookies they had set on realmoon.ai. Those on the ad networks’ own domains are managed with them or in your browser.

The Moon AI app has its own privacy settings.