> ## Documentation Index
> Fetch the complete documentation index at: https://magica-adi.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Create a key, queue a turn, and poll until the run finishes.

Set `BASE` to the API origin. Production is `https://magica-backend-oda9.onrender.com`. Keys are created while you are signed in. Public calls use the key, not the session.

```bash theme={null}
export BASE=https://magica-backend-oda9.onrender.com
```

<Steps>
  <Step title="Create an API key">
    In the product, open **API / MCP** and create a key. Or, with a signed-in session:

    ```bash theme={null}
    curl -X POST "$BASE/api/keys" \
      -H "Authorization: Bearer $CLERK_SESSION_TOKEN" \
      -H "Content-Type: application/json" \
      -d '{"name":"local"}'
    ```

    Store the `key` field. Later list calls only return `prefix`.
  </Step>

  <Step title="Send a message">
    You do not create a chat first. Omit `chatId` and the API creates one. Attach a file with multipart, or pass `image_urls` if you already have a URL.

    ```bash theme={null}
    curl -X POST "$BASE/api/v1/completions" \
      -H "Authorization: Bearer $GALAXY_API_KEY" \
      -F "text=What is in this photo?" \
      -F "file=@./photo.jpg;type=image/jpeg"
    ```

    Response `202`:

    ```json theme={null}
    {
      "chatId": "…",
      "messageId": "…",
      "runId": "…",
      "triggerRunId": "…",
      "status": "queued"
    }
    ```
  </Step>

  <Step title="Poll the run">
    ```bash theme={null}
    curl "$BASE/api/v1/chats/$CHAT_ID/runs/$RUN_ID" \
      -H "Authorization: Bearer $GALAXY_API_KEY"
    ```

    Stop when `status` is `COMPLETE`, `FAILED`, or `CANCELLED`. Read `assistant.contentBlocks` for the reply and `errorMessage` if it failed.
  </Step>
</Steps>

<CardGroup cols={2}>
  <Card title="Send into an existing chat" icon="messages" href="/messages">
    `POST /completions` with `chatId`, `text`, and `file` in one multipart request.
  </Card>

  <Card title="Call a Magica tool" icon="image" href="/magica">
    Crop, generate, or merge without waiting on the agent loop.
  </Card>
</CardGroup>


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