# gram auth

The `auth` command authenticates with the Gram platform by opening a browser
window for login. After successful authentication, it creates and saves a
[Producer API key](/docs/mcp/secure/api-keys#producer-keys) for the local
profile configuration.

<Callout type="info">
    The `gram auth` command is typically run once during initial setup. The
    API key and profile information it creates are stored in
    `~/.gram/profile.json`.
</Callout>

## Usage

Authenticate with Gram:

```bash
gram auth
```

This command will:

- Open a browser window to the Gram authentication page
- Prompt for login credentials
- Create a Producer API key in the Gram dashboard
- Save the API key and profile information locally
- Save the current project in the browser as your default project

After authentication, verify the setup with [`gram whoami`](/docs/mcp/reference/command-line/whoami).

## Subcommands

Change your default project context:
```bash
gram auth switch --project {project-slug}
```

Completely clear auth information in your local profile so you can `gram auth` fresh:
```bash
gram auth clear
```

## Options

### <code>api-url</code>

This option adds the URL of a Gram web application. It's useful for connecting to
custom or self-hosted Gram instances.

```bash
gram auth --api-url https://custom.gram.instance [other options]
```

You can also set the URL of a Gram web app via the `GRAM_API_URL` environment variable.
