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

# Organizations API

> Read, set, test, and remove the organization's own OpenRouter key for the Squasher Agent.

The organizations API manages the organization's AI provider key. With a key set, the Squasher
Agent runs its model calls on your own OpenRouter account. Those calls use no AI credits. See
[Use your own model key](/features/plans-and-billing#use-your-own-model-key).

## Operations

| Operation | Method and path | Purpose |
| - | - | - |
| `organizations.getAiProviderKey` | `GET /v1/organizations/{organization_id}/ai-provider-key` | Read the key status. |
| `organizations.setAiProviderKey` | `PUT /v1/organizations/{organization_id}/ai-provider-key` | Add or replace the key. |
| `organizations.testAiProviderKey` | `POST /v1/organizations/{organization_id}/ai-provider-key/test` | Check the saved key with OpenRouter. |
| `organizations.deleteAiProviderKey` | `DELETE /v1/organizations/{organization_id}/ai-provider-key` | Remove the key and go back to AI credits. |

Find the organization ID in **Organization settings > General**.

## Access

* Any member, and an API key of a project in the organization, can read the key status.
* Only an owner or admin, in a signed-in session, can set, test, or remove the key. An API key
  cannot change it, even with write scopes.
* A change and a test are written to the organization's audit log. The log never holds the key.

## Set a key

```http theme={null}
PUT /v1/organizations/{organization_id}/ai-provider-key
Content-Type: application/json

{ "provider": "openrouter", "api_key": "sk-or-v1-..." }
```

Squasher checks the key with OpenRouter before it saves it. This check runs no model, so it costs
nothing. A key that OpenRouter rejects returns `422` with the reason, and nothing is saved.
`openrouter` is the only provider.

## Response

No response contains the key. Squasher stores it encrypted and returns only its last four
characters.

```json theme={null}
{
  "ai_provider_key": {
    "provider": "openrouter",
    "last_four": "a1b2",
    "status": "active",
    "last_error": null,
    "last_error_at": null,
    "last_verified_at": "2026-10-20T09:12:44.000Z",
    "created_at": "2026-10-20T09:12:44.000Z",
    "updated_at": "2026-10-20T09:12:44.000Z",
    "month_to_date_cost_usd": 3.42
  }
}
```

* `ai_provider_key` is `null` when the organization has no key.
* `status` is `failing` after OpenRouter refused the key during a run. `last_error` says why. A
  passing test sets `active` again.
* `month_to_date_cost_usd` is the model cost that ran on your key this month (UTC).
* `POST .../test` also returns `test: { "passed": true, "message": "..." }`.

## CLI and MCP

The CLI has no organization settings, and hosted MCP does not expose these operations: agents
never read or write provider keys.

Related: [Plans and billing](/features/plans-and-billing).


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