> For the complete documentation index, see [llms.txt](https://docs.robinmesh.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.robinmesh.com/api-reference/authentication.md).

# Authentication

Every request to the API carries a bearer token in the `Authorization` header. That token is an API key, and each key is tied to one Ethereum wallet and draws on that wallet's credit balance.

***

## API keys

Generate keys from the Settings tab of the RobinMesh web app at `robinmesh.com/app/settings`.

**Key format:** the prefix `rmesh_live_` followed by 32 alphanumeric characters.

Example: `rmesh_live_a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6`

**Key properties:**

* During beta, each wallet gets a single key. Support for multiple keys per wallet arrives in Phase 2.
* A key spends against the credit balance of the wallet that issued it. API usage draws down the same balance you see in the web app.
* You can revoke a key and issue a replacement from Settings whenever you like.
* The full key value appears exactly once, at creation. There is no way to recover a lost key; generate a fresh one instead.

***

## Making authenticated requests

Pass the key as a bearer token on every call:

```bash
curl https://api.robinmesh.com/v1/models \
  -H "Authorization: Bearer rmesh_live_your_key_here"
```

```python
import httpx

headers = {"Authorization": "Bearer rmesh_live_your_key_here"}
response = httpx.get("https://api.robinmesh.com/v1/models", headers=headers)
```

```typescript
const response = await fetch("https://api.robinmesh.com/v1/models", {
    headers: { "Authorization": "Bearer rmesh_live_your_key_here" }
})
```

***

## Security

**Treat the key as a secret.** Keep it out of source control and out of anything shipped to the browser. Load it from the environment instead.

```bash
export ROBINMESH_API_KEY="rmesh_live_your_key_here"
```

```python
import os
api_key = os.environ["ROBINMESH_API_KEY"]
```

**Key scope:** A key's only power is spending credits from its own wallet. It cannot withdraw credits, move $RMESH, or change anything in your account settings.

**Key revocation:** Suspect a leak? Revoke the key from Settings right away. The revocation applies instantly, and every request made afterward is rejected.

***

## Wallet-native authentication (coming in Phase 2)

Phase 2 adds an alternative to static keys: signing each request directly with your Ethereum wallet via EIP-4361 (Sign-In with Ethereum). Because nothing has to be provisioned ahead of time, this fits automated setups where minting and distributing a long-lived key would be awkward.

***

## Authentication errors

| Status | Code                   | Meaning                                                    |
| ------ | ---------------------- | ---------------------------------------------------------- |
| `401`  | `invalid_api_key`      | No such key, or the key was revoked                        |
| `401`  | `missing_api_key`      | The request arrived without an `Authorization` header      |
| `402`  | `insufficient_credits` | The wallet's balance cannot cover the requested model tier |
| `403`  | `key_suspended`        | The key was suspended following a policy violation         |

The complete error envelope is documented in \[Errors]\(

).

***

## Checking your balance via the API

```bash
curl https://api.robinmesh.com/v1/account \
  -H "Authorization: Bearer rmesh_live_your_key_here"
```

```json
{
  "wallet": "0x7f3ce8b1a94d20c5e6f18b7a2d40953c1e8ba672",
  "credits_remaining": 1420,
  "usdg_value": 14.20,
  "last_topup_at": "2026-06-15T09:43:00Z",
  "api_key_created_at": "2026-06-01T00:00:00Z"
}
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.robinmesh.com/api-reference/authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
