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

# Quickstart

> Create an API key and call Moxus AI from external code, SDKs, scripts, or external tools.

This page explains how to call Moxus AI from outside the web app with an API key you create, such as from server-side code, cURL, SDKs, or external tools.

<Info>
  Conversation is a web testing surface. After you sign in, it uses an internal virtual key automatically. You do not need to paste your newly created API key into Conversation. The `sk-` key you create is for external code, SDKs, scripts, and external tools.
</Info>

## Flow

<Steps>
  <Step title="Sign in">
    Go to `https://moxus.cloud` and sign in with email or an enabled third-party login provider.
  </Step>

  <Step title="Prepare balance">
    Open Billing and confirm that your account has usable balance from top-up, a redemption code, or a platform grant.
  </Step>

  <Step title="Create an API key for external calls">
    Open API Keys and create a key that starts with `sk-`. This key is for external code, SDKs, scripts, and external tools, not a required Conversation setting.
  </Step>

  <Step title="Choose a protocol and model">
    Open Model Square, copy the exact model name, and choose the matching Base URL and request format for your protocol.
  </Step>

  <Step title="Send an external request">
    Send the request with cURL or the SDK that matches your protocol. Most projects can start with the OpenAI SDK.
  </Step>
</Steps>

<Warning>
  API keys are only shown in full when created. Copy the key immediately and never commit it to frontend code, public repositories, screenshots, or shared chat messages.
</Warning>

## Choose a request style

Each protocol has its own Base URL, authentication method, and request body. Do not send an OpenAI request body to the Anthropic or Google native endpoints.

| Request style        | Base URL                     | Authentication                                               | Best for                                                  |
| -------------------- | ---------------------------- | ------------------------------------------------------------ | --------------------------------------------------------- |
| OpenAI compatible    | `https://moxus.cloud/v1`     | `Authorization: Bearer sk-your-key`                          | OpenAI SDK, Chat Completions, Images, most external tools |
| Anthropic compatible | `https://moxus.cloud`        | `x-api-key: sk-your-key`                                     | Claude native Messages API or Anthropic SDK               |
| Google compatible    | `https://moxus.cloud/v1beta` | Query parameter `?key=sk-your-key` or client-specific config | Google native API or Google-compatible clients            |

## Without an SDK: direct HTTP

To verify that your key, model, and endpoint work, you can send a plain HTTP request without installing an AI SDK. Choose the example that matches your protocol: OpenAI, Anthropic, and Google-compatible calls use different URLs, authentication methods, and request bodies. Every example places the key directly in the code, so no terminal or configuration-file environment setup is required. Replace `sk-your-key` in the selected example with your actual key.

<Tabs>
  <Tab title="OpenAI compatible">
    OpenAI-compatible calls are the most common path for chat, tools, and SDK migrations. Use `https://moxus.cloud/v1/chat/completions` with `Authorization: Bearer ...`.

    <CodeGroup>
      ```bash cURL theme={null}
      curl https://moxus.cloud/v1/chat/completions \
        -H "Authorization: Bearer sk-your-key" \
        -H "Content-Type: application/json" \
        -d '{
          "model": "gpt-5.4-mini",
          "messages": [{"role": "user", "content": "Say hello in one sentence"}]
        }'
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Anthropic compatible">
    Anthropic-compatible calls are for Claude-native Messages. Use `https://moxus.cloud/v1/messages` with the `x-api-key` header and an `anthropic-version` header.

    <CodeGroup>
      ```bash cURL theme={null}
      curl https://moxus.cloud/v1/messages \
        -H "x-api-key: sk-your-key" \
        -H "anthropic-version: 2023-06-01" \
        -H "content-type: application/json" \
        -d '{
          "model": "claude-opus-4-6",
          "max_tokens": 512,
          "messages": [{"role": "user", "content": "Say hello in one sentence"}]
        }'
      ```
    </CodeGroup>
  </Tab>

  <Tab title="Google compatible">
    Google-compatible calls are for Google-native `generateContent` request shapes. Use `https://moxus.cloud/v1beta` and pass the key in the `key` query parameter.

    <CodeGroup>
      ```bash cURL theme={null}
      curl "https://moxus.cloud/v1beta/models/gemini-2.5-pro:generateContent?key=sk-your-key" \
        -H "Content-Type: application/json" \
        -d '{
          "contents": [
            {
              "parts": [
                {"text": "Say hello in one sentence"}
              ]
            }
          ]
        }'
      ```
    </CodeGroup>
  </Tab>
</Tabs>

## SDK setup

SDKs assemble the HTTP request for you. When connecting an SDK to Moxus AI, confirm three settings:

| Setting    | Value                                                                                                      |
| ---------- | ---------------------------------------------------------------------------------------------------------- |
| API key    | The `sk-` key created in API Keys                                                                          |
| Base URL   | `https://moxus.cloud/v1`, `https://moxus.cloud`, or `https://moxus.cloud/v1beta` depending on the protocol |
| Model name | The exact model name copied from Model Square                                                              |

For a first call, start with the OpenAI SDK. Use the Anthropic SDK or Google SDK when your project specifically expects Claude-native Messages or Google-native request formats.

<Warning>
  To make the first call easy, the examples place the key directly in an `API_KEY` variable. After copying, replace only `sk-your-key` and run the file. Do not commit a file containing a real key to a public repository or share it. For production, move the key to environment variables or server-side secret management.
</Warning>

For dependency installation, choose either `npm` or `pnpm`; they are alternatives.

## OpenAI SDK

If you are unsure which style to use, start with the OpenAI-compatible API. It works for most model calls, SDKs, and external tools.

Install dependencies:

<CodeGroup>
  ```bash npm theme={null}
  npm install openai tsx
  ```

  ```bash pnpm theme={null}
  pnpm add openai tsx
  ```
</CodeGroup>

Copy the code below into `openai_example.py` for Python or `openai-example.ts` for TypeScript.

<CodeGroup>
  ```python Python theme={null}
  from openai import OpenAI

  API_KEY = "sk-your-key"

  client = OpenAI(
      api_key=API_KEY,
      base_url="https://moxus.cloud/v1",
  )

  response = client.chat.completions.create(
      model="gpt-5.4-mini",
      messages=[{"role": "user", "content": "Say hello in one sentence"}],
  )

  print(response.choices[0].message.content)
  ```

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

  const API_KEY = "sk-your-key";

  const client = new OpenAI({
    apiKey: API_KEY,
    baseURL: "https://moxus.cloud/v1",
  });

  const response = await client.chat.completions.create({
    model: "gpt-5.4-mini",
    messages: [{ role: "user", content: "Say hello in one sentence" }],
  });

  console.log(response.choices[0].message.content);
  ```
</CodeGroup>

## Anthropic SDK

Use the Anthropic SDK when your project already uses Claude-native Messages. Set Base URL to `https://moxus.cloud`; the SDK appends `/v1/messages`.

Install dependencies:

<CodeGroup>
  ```bash npm theme={null}
  npm install @anthropic-ai/sdk tsx
  ```

  ```bash pnpm theme={null}
  pnpm add @anthropic-ai/sdk tsx
  ```
</CodeGroup>

Copy the code below into `anthropic_example.py` for Python or `anthropic-example.ts` for TypeScript.

<CodeGroup>
  ```python Python theme={null}
  import httpx
  from anthropic import Anthropic

  API_KEY = "sk-your-key"

  client = Anthropic(
      api_key=API_KEY,
      base_url="https://moxus.cloud",
      http_client=httpx.Client(
          trust_env=False,
          timeout=60.0,
      ),
  )

  message = client.messages.create(
      model="claude-opus-4-6",
      max_tokens=512,
      messages=[{"role": "user", "content": "Say hello in one sentence"}],
  )

  print(message.content[0].text)
  ```

  ```typescript TypeScript theme={null}
  import Anthropic from "@anthropic-ai/sdk";

  const API_KEY = "sk-your-key";

  const client = new Anthropic({
    apiKey: API_KEY,
    baseURL: "https://moxus.cloud",
  });

  const message = await client.messages.create({
    model: "claude-opus-4-6",
    max_tokens: 512,
    messages: [{ role: "user", content: "Say hello in one sentence" }],
  });

  const text = message.content.find((block) => block.type === "text")?.text;
  console.log(text);
  ```
</CodeGroup>

## Google SDK

Use the Google GenAI SDK when your project expects Google-native request formats. For the Google SDK, set `base_url` / `baseUrl` to `https://moxus.cloud` and set the API version to `v1beta`; do not repeat `/v1beta` in the SDK Base URL.

Install dependencies:

<CodeGroup>
  ```bash npm theme={null}
  npm install @google/genai tsx
  ```

  ```bash pnpm theme={null}
  pnpm add @google/genai tsx
  ```
</CodeGroup>

Copy the code below into `google_example.py` for Python or `google-example.ts` for TypeScript.

<CodeGroup>
  ```python Python theme={null}
  from google import genai
  from google.genai import types

  API_KEY = "sk-your-key"

  client = genai.Client(
      api_key=API_KEY,
      http_options=types.HttpOptions(
          api_version="v1beta",
          base_url="https://moxus.cloud",
      ),
  )

  response = client.models.generate_content(
      model="gemini-2.5-pro",
      contents="Say hello in one sentence",
  )

  print(response.text)
  ```

  ```typescript TypeScript theme={null}
  import { GoogleGenAI } from "@google/genai";

  const API_KEY = "sk-your-key";

  const ai = new GoogleGenAI({
    apiKey: API_KEY,
    httpOptions: {
      apiVersion: "v1beta",
      baseUrl: "https://moxus.cloud",
    },
  });

  const response = await ai.models.generateContent({
    model: "gemini-2.5-pro",
    contents: "Say hello in one sentence",
  });

  console.log(response.text);
  ```
</CodeGroup>

## Verify the request

After an external request succeeds, open Usage and check API activity records for request time, API key, model name, input tokens, output tokens, total tokens, and cost.

Calls from Conversation also appear in logs, but they use the platform's internal virtual key. To verify your external API key, run one of the cURL or SDK examples on this page.

## Common first-call errors

| Error                       | Likely cause                                                           | Fix                                                     |
| --------------------------- | ---------------------------------------------------------------------- | ------------------------------------------------------- |
| `401 Unauthorized`          | Wrong key, mismatched auth header, disabled key, or expired key        | Use the authentication method for the selected protocol |
| `insufficient quota`        | Account balance or key quota is exhausted                              | Top up or raise the key quota limit                     |
| `model not found`           | Wrong model name, unavailable model, or key model limits               | Copy the exact model name from Model Square             |
| Request body error          | A request body from one protocol was sent to another protocol endpoint | Use the matching OpenAI, Anthropic, or Google example   |
| Timeout or connection error | Wrong Base URL or network issue                                        | Confirm the Base URL and retry                          |

## Next steps

* [API keys](/en/platform/account-and-keys)
* [Models and pricing](/en/overview/models-and-pricing)
* [Quickstart](/en/overview/quickstart)
* [Cursor](/en/integrations/clients/cursor)
