# Make Your First Request

> Create an API key, find an available model, and generate text.

## What You Will Do

You will create an account-wide API key, confirm which Makojima account it uses,
find an available model, and submit one text-generation request.

## Before You Start

You need a Makojima account with available Trial or Premium Credits. Open
**Developers** in the main navigation, choose **Create API Key**, give the key
a unique name, and choose its expiration. The default is **90 Days**.

Copy the complete key when it appears. A new key is 48 random letters and
digits with no punctuation and no `mk_` prefix. Makojima shows it once and
stores only a verification value. If you lose it, rotate the key or create
another one.

> **Keep The Key Private**
>
> Store the key in a secret manager or an environment variable. Do not put it in
> source code, URLs, screenshots, browser storage, or logs.

## Confirm The Connected Account

Set your key in the shell without adding it to the command itself, then call
the account endpoint:

```powershell
$env:MAKOJIMA_API_KEY = Read-Host "Makojima API Key"
curl.exe https://api.makojima.com/v1/me `
  -H "Authorization: Bearer $env:MAKOJIMA_API_KEY"
```

A successful response contains only the stable account ID:

```json
{ "object": "account", "id": "00000000-0000-4000-8000-000000000000" }
```

## Find The Available Model

```powershell
curl.exe https://api.makojima.com/v1/models `
  -H "Authorization: Bearer $env:MAKOJIMA_API_KEY"
```

Use the returned model `id` in the next request. That `id` is a UUID. Do not
send the display name as `model`. Each listed model also includes a public
address when one exists and nested `limits` for context and output. An empty
`data` list is a successful response and means no model is currently available
to that account.

## Generate Text

Create two UUIDs. Keep the request ID for retries of this exact request. Reuse
the session ID only for requests that belong to the same client conversation.

```powershell
$requestId = [guid]::NewGuid().ToString()
$sessionId = [guid]::NewGuid().ToString()
$modelId = "<model-id-from-v1-models>"
$body = @{
  model = $modelId
  messages = @(@{ role = "user"; content = "Write one sentence about the ocean." })
  max_tokens = 128
  stream = $false
} | ConvertTo-Json -Depth 5 -Compress

curl.exe https://api.makojima.com/v1/chat/completions `
  -H "Authorization: Bearer $env:MAKOJIMA_API_KEY" `
  -H "Content-Type: application/json" `
  -H "Idempotency-Key: $requestId" `
  -H "X-Makojima-Session-Id: $sessionId" `
  --data-binary $body
```

The response follows the supported chat-completions shape. Save the request ID
so you can read its status or cancel eligible work.

## Check Status Or Cancel

```powershell
curl.exe "https://api.makojima.com/v1/requests/$requestId" `
  -H "Authorization: Bearer $env:MAKOJIMA_API_KEY"

curl.exe -X DELETE "https://api.makojima.com/v1/requests/$requestId" `
  -H "Authorization: Bearer $env:MAKOJIMA_API_KEY"
```

Cancellation is best effort for queued or running work. Makojima settles the
actual recorded usage once; work already performed can still use credits.

## See Your Balance

```powershell
curl.exe https://api.makojima.com/v1/credits `
  -H "Authorization: Bearer $env:MAKOJIMA_API_KEY"
```

Credit amounts are exact integer microcredit strings. Divide by `1000000` to
display Credits. Trial Credits are used first for eligible model processing.
