Claude & GPT overview
Claude and GPT, one integration. Use your Moonez.ai key with the OpenAI SDK or any client that supports a custom OpenAI-compatible base URL:
https://api.moonez.ai/v1All available Claude and GPT models share this endpoint. Choose a model ID in the request; you do not need a different client or base URL for each family. GPT Image uses the same base URL with the Images API. Your existing Moonez.ai balance and model permissions apply.
For ready-to-run JavaScript and Python examples, start with the SDK quickstart.
Before you start
Section titled “Before you start”- Create a key in API Keys and enable Claude models, GPT text models, or GPT Image models, as needed.
- Add your server’s public egress IP to IP Whitelist.
- Fund your account and check the rates for your chosen model in Pricing.
Keep the key on your server, not in browser code. See Authentication for details.
Discover models
Section titled “Discover models”Use Bearer authentication to retrieve the OpenAI-compatible catalog:
export MOONEZ_API_KEY="YOUR_MOONEZ_API_KEY"
curl -sS https://api.moonez.ai/v1/models \ -H "Authorization: Bearer $MOONEZ_API_KEY"The response contains a data array. For each entry, inspect:
| Field | Meaning |
|---|---|
id | Exact value to pass as model. |
model_type | text for text models or image for image models. |
endpoints | Supported operations, such as /v1/chat/completions or /v1/images/generations. |
The catalog is specific to your key and account configuration. It includes models with a configured compatible route and applicable pricing; it is not a fixed list of every model released by a model developer. Availability can change. Use the returned IDs rather than guessing names or adding version suffixes.
Claude Haiku, Sonnet, and Opus, GPT text models, and GPT Image are model families
to look for. Example IDs such as claude-haiku-4-5, gpt-4o, and gpt-image-2
are usable only when your catalog lists them for the operation you need.
Chat Completions
Section titled “Chat Completions”Select a Claude or GPT model whose endpoints includes /v1/chat/completions.
The request format is the same for both families:
export MOONEZ_MODEL="claude-haiku-4-5"
curl -sS https://api.moonez.ai/v1/chat/completions \ -H "Authorization: Bearer $MOONEZ_API_KEY" \ -H "Content-Type: application/json" \ --data @- <<JSON{ "model": "$MOONEZ_MODEL", "messages": [{ "role": "user", "content": "Explain idempotency in one sentence." }]}JSONReplace MOONEZ_MODEL with an ID from your catalog. To switch from Claude to
GPT, change only the model ID, for example to gpt-4o if listed. Read generated
text from choices[].message.content; responses may also contain tool calls or
other model-specific fields.
Streaming
Section titled “Streaming”Set stream to true. The response uses Server-Sent Events (SSE), not native
job polling. With cURL, -N disables output buffering:
curl -sS -N https://api.moonez.ai/v1/chat/completions \ -H "Authorization: Bearer $MOONEZ_API_KEY" \ -H "Content-Type: application/json" \ --data @- <<JSON{ "model": "$MOONEZ_MODEL", "messages": [{"role": "user", "content": "Write a short welcome message."}], "stream": true}JSONRead text deltas as they arrive and handle completion or stream errors. The SDK examples handle SSE parsing for you.
GPT Image
Section titled “GPT Image”Use an image model whose endpoints includes /v1/images/generations:
export MOONEZ_IMAGE_MODEL="gpt-image-2"
curl -sS https://api.moonez.ai/v1/images/generations \ -H "Authorization: Bearer $MOONEZ_API_KEY" \ -H "Content-Type: application/json" \ --data @- <<JSON{ "model": "$MOONEZ_IMAGE_MODEL", "prompt": "A ceramic cup in soft studio lighting."}JSONUse the returned image data or URL as supplied by the model. Supported image parameters and response fields depend on the selected model. Do not send an image model to Chat Completions unless its catalog entry explicitly lists that operation. See Python and JavaScript image examples.
Compatibility and billing
Section titled “Compatibility and billing”OpenAI-compatible means you can reuse the supported SDK request formats; it
does not imply support for every OpenAI endpoint or parameter. Check endpoints
before using another operation. In particular, do not assume Responses or image
editing is available just because a model appears in the catalog.
Text pricing uses input and output tokens, with separate cache-related rates where configured. GPT Image has its own image-token rates. Your account’s Pricing page is the source of your rates; do not assume models share a price. Usage fields are preserved when supplied by the model, not filled with synthetic counters. A failed or interrupted request may still report billable usage.
The OpenAI-compatible API returns JSON or SSE directly. It does not return a
native job_id, and the native jobs API’s Idempotency-Key behavior must not be
assumed here. Avoid blindly retrying generation requests after an ambiguous
network failure: the original request may already have been accepted.
Existing Gemini-compatible clients and native generation jobs remain available at their own base URLs.