# Overview

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.

## Two HTTP APIs

We expose two HTTP APIs. Most teams only ever hit the first one.

### 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.

## Authentication at a glance

We issue two key types, one per API:

* **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 and sign every request with the private key. Three headers ride with each request: `x-thegrid-signature`, `x-thegrid-timestamp`, and `x-thegrid-fingerprint`.

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.

Both key types live in the dashboard at [app.thegrid.ai/profile/api-keys](https://app.thegrid.ai/profile/api-keys). Full generation and signing details are on the [Authentication](/docs/api-reference/authentication.md) page.

## Routing behavior

Requests to the Consumption API return an HTTP `307 Temporary Redirect` on the way to the supplier serving your 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, allowlist the supplier domains alongside `api.thegrid.ai`. See [Request routing and redirects](/docs/api-reference/request-routing-and-redirects.md) for the full client compatibility list.

## Where to start

* [Authentication](/docs/api-reference/authentication.md): Consumption keys (Bearer / x-api-key) and Trading keys (Ed25519). Generation, signing, rotation.
* [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.
* [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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
