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:
- Open “Billing” (open).
- Under “Top up”, pick an “Amount to add” or enter an “Other amount”.
- Check the summary (“You receive”, “Total due excl. VAT”). VAT is added at checkout based on your billing address.
- 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
- Open “API keys” (open).
- In “Create an API key”, give the key a “Name”, for example the name of the app that will use it.
- Click “Create key”.
- 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.
# Nothing to install: curl is all you need.
curl --versionpip install openainpm install openai5. 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:
export MOONAI_API_KEY="sk-moon-..."6. Send your first requestLink to the 6. Send your first request section
The example calls anthropic/. Any ID listed by GET / works; you can read the current list in the “Models” tab or through the API (see Models).
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"}]
}'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)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.
{
"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 }
}idis the request ID at Moon AI. Use it to look up the request’s cost withGET /(see Balance and request cost).v1/ generation? id= … usagegives the tokens, not the cost.modelis 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:
X-Moon-Request-Id: gen-6f1c2b7e9a4d4c0e8b3a5d2f1e0c9b8a
X-Moon-Prompt-Storage: none
X-Moon-Blur: onX-Moon-Blur: 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.