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

# Gateway Server

> Deploy the Mako Gateway on your own infrastructure.

## Prerequisites

* Node.js 18+
* An Ollama instance (for the 8B model) or Hugging Face Inference Endpoint (for 32B)

## Setup

<Steps>
  <Step title="Clone the repository">
    ```bash theme={null}
    git clone https://github.com/DeepMako/mako.git
    cd mako/mako-platform/gateway
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash theme={null}
    npm install
    ```
  </Step>

  <Step title="Configure environment">
    ```bash theme={null}
    cp .env.example .env
    ```

    Edit `.env` with your configuration. See [Environment Variables](/self-host/environment) for the full reference.
  </Step>

  <Step title="Start the server">
    ```bash theme={null}
    npm start
    ```

    You should see:

    ```
    🦈 Mako Gateway running on http://localhost:3000
    📡 Model: mako @ http://localhost:11434/api/chat
    🆓 Free mode: ON — open access, no auth required
    ```
  </Step>
</Steps>

## API routes

The gateway exposes these endpoints:

| Method | Path                   | Description                         |
| ------ | ---------------------- | ----------------------------------- |
| `POST` | `/v1/chat/completions` | Chat completion (OpenAI-compatible) |
| `GET`  | `/v1/models`           | List models                         |
| `GET`  | `/v1/tools`            | List available tools                |
| `POST` | `/v1/tools/execute`    | Execute a tool directly             |
| `GET`  | `/credits/balance`     | Check credit balance                |
| `POST` | `/credits/grant`       | Grant credits (dev only)            |
| `POST` | `/auth/api-keys`       | Create an API key                   |
| `GET`  | `/health`              | Health check                        |

## Database

The gateway uses SQLite by default, stored at `./data/mako.db`. The database manages:

* User accounts (keyed by wallet address)
* API keys (hashed)
* Credit balances and usage logs

For production, set `DATABASE_PATH` to a persistent volume.

## Deployment

### Railway

The repository includes `railway.json` and `nixpacks.toml` for one-click Railway deployment:

```bash theme={null}
cd mako/mako-platform/gateway
railway up
```

### Docker

Build and run with any container platform:

```bash theme={null}
docker build -t mako-gateway .
docker run -p 3000:3000 --env-file .env mako-gateway
```

### Other platforms

The gateway is a standard Express.js app. It works on Render, Heroku, Fly.io, or any Node.js hosting. Just set the environment variables and run `npm start`.
