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

# Overview

Use The Grid's Consumption, Trading, and Platform APIs for market-priced AI inference, live market data, orders, and account management.

The Grid exposes its inference market over HTTP. This section covers what to call, how to authenticate, and how the routing layer behaves at runtime. Per-endpoint schemas and parameter tables live in the OpenAPI blocks on each page.

## Three HTTP APIs

We expose three HTTP surfaces. Most teams only ever hit the Consumption API for inference.

### Consumption API

What you call for inference. One routing engine, two request shapes:

* **OpenAI Chat Completions format** at `https://api.thegrid.ai/v1`. Auth header: `Authorization: Bearer <consumption-key>`. If your code already talks to OpenAI, swap the base URL and the model name and you're done.
* **Anthropic Messages format** at `https://messages-beta.api.thegrid.ai/v1`. Auth header: `x-api-key: <consumption-key>`. Same routing engine, same instruments, same consumption key value. Different request shape so the Anthropic SDK and Claude Code drop in without changes.

Both URLs hit the same Consumption API. Anthropic Messages is not a separate API; it's the Consumption API in a different request format. Pick whichever surface your stack prefers.

See [Consumption API](/docs/api-reference/consumption-api.md).

### Trading API

Everything beyond inference. This is what you call to:

* Fetch instrument specifications and live market data
* Read your balances and account positions
* See past purchases and trade history
* Place orders directly on the order book
* Transfer tokens between Trading and Consumption accounts

Base URL: `https://trading.api.thegrid.ai/v1`. Auth: Ed25519-signed requests. See [Authentication](/docs/api-reference/authentication.md) for the signing scheme.

If you only consume inference and let Auto Mode buy on your behalf, you don't need the Trading API. The moment you want to look at your account balance, list past trades, or place a limit order yourself, you do.

### Platform API

Account control plane for automation: OAuth 2.0 device login, programmatic creation of consumption and trading keys, and account settings ([Auto Mode vs Advanced Mode](/docs/start-here/auto-mode-vs-advanced-mode.md), funding automation).

Base URL: `https://platform.api.thegrid.ai/v1`. Auth: OAuth bearer (`grid_at_*`) or browser session from the dashboard.

Agents and integrations typically start here with [Programmatic onboarding](/docs/start-here/programmatic-onboarding.md), then call Consumption and Trading with the keys they create.

See [Platform API](/docs/api-reference/platform-api.md).

### Diagnostics

Each API surface has a safe read-only diagnostics endpoint for onboarding and support:

* Platform diagnostics checks OAuth/session auth, email/legal readiness, account status, account mode, and key availability.
* Consumption diagnostics checks a Consumption API key, account status, visible model catalog count, and account mode without making an inference request.
* Trading diagnostics checks signed Trading auth, account mode/status, visible trading accounts, routable markets, and order-control readiness.

Run `grid diagnostics` in the CLI, or call the endpoints directly. See [Diagnostics](/docs/api-reference/diagnostics.md).

## Authentication at a glance

We issue two credential types for inference and trading, plus OAuth tokens for account control:

* **Consumption keys** for the Consumption API. Bearer header on the OpenAI-compatible host, `x-api-key` header on the Anthropic Messages host. The same key value works on both.
* **Trading keys** for the Trading API. An Ed25519 keypair you generate locally; you register the public key in the dashboard or via the Platform API and sign every request with the private key. Three headers ride with each request: `x-thegrid-signature`, `x-thegrid-timestamp`, and `x-thegrid-fingerprint`.
* **OAuth access tokens** (`grid_at_*`) for the Platform API — device login, key management, and account settings. Not a substitute for consumption keys on inference endpoints.

Trading keys cover the entire Trading API surface, not just order placement. Reading your balance, fetching instrument specs, listing past trades, transferring between accounts: all of that needs a Trading key.

Create keys in the dashboard at [app.thegrid.ai/profile/api-keys](https://app.thegrid.ai/profile/api-keys) or programmatically after [OAuth login](/docs/start-here/programmatic-onboarding.md). Full details: [Authentication](/docs/api-reference/authentication.md).

## Routing behavior

Requests to the Consumption API return an HTTP `307 Temporary Redirect` on the way to the routing layer that fulfills inference. The OpenAI SDK, Anthropic SDK, `requests`, `httpx`, and most other libraries follow this transparently. cURL needs `-L`. If your environment locks down outbound traffic, `api.thegrid.ai` is the only domain you need to allowlist — the redirect target lives on the same host. See [Request routing and redirects](/docs/api-reference/request-routing-and-redirects.md) for the full client compatibility list.

## Where to start

* [Programmatic onboarding](/docs/start-here/programmatic-onboarding.md): OAuth device flow → keys → first API calls.
* [Authentication](/docs/api-reference/authentication.md): Consumption keys (Bearer / x-api-key), Trading keys (Ed25519), and OAuth tokens.
* [Consumption API](/docs/api-reference/consumption-api.md): chat completions and messages endpoints with full OpenAPI specs.
* [Trading API](/docs/api-reference/trading-api.md): instruments, markets, orders, accounts, transfers, price history.
* [Platform API](/docs/api-reference/platform-api.md): OAuth device flow, key CRUD, account settings.
* [Diagnostics](/docs/api-reference/diagnostics.md): safe read-only checks for Platform, Consumption, and Trading auth paths.
* [Errors and rate limits](/docs/api-reference/errors-and-rate-limits.md): status code catalog, retry guidance, rate limit behavior.
* [Request routing and redirects](/docs/api-reference/request-routing-and-redirects.md): the 307 from the Consumption API and which clients need configuration.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://thegrid.ai/docs/api-reference/api-reference.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
