# Consumption API

The Consumption API is what you call to run inference. It's the API behind the [Quickstart](/docs/start-here/quickstart.md) and the one most teams ever touch. Two surfaces sit in front of the same routing engine:

* **OpenAI Chat Completions** at `https://api.thegrid.ai/v1` with `Authorization: Bearer YOUR_KEY`.
* **Anthropic Messages (beta)** at `https://messages-beta.api.thegrid.ai/v1` with `x-api-key: YOUR_KEY`.

Same instruments, same routing, same Consumption key. Pick whichever request shape fits your stack. The canonical instrument list lives in [Current instruments](/docs/instrument-specifications/current-instruments.md); pass the instrument name (Text-Prime, Code-Max, Vision-Standard, etc.) in the `model` field.

## Create a chat completion

{% openapi src="/files/2oEceb4dLmiu7td9HxSC" path="/chat/completions" method="post" %}
[consumption-api-swagger.yaml](https://132387983-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAFL4lTMN4MTksJiuTkKd%2Fuploads%2Fgit-blob-b46fc1297b2b733436a371e824cad8f4f8b43dff%2Fconsumption-api-swagger.yaml?alt=media)
{% endopenapi %}

## Create a message (Anthropic-compatible)

{% openapi src="/files/2oEceb4dLmiu7td9HxSC" path="/messages" method="post" %}
[consumption-api-swagger.yaml](https://132387983-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAFL4lTMN4MTksJiuTkKd%2Fuploads%2Fgit-blob-b46fc1297b2b733436a371e824cad8f4f8b43dff%2Fconsumption-api-swagger.yaml?alt=media)
{% endopenapi %}

## Quick example

A minimal chat completion call:

```bash
curl -L https://api.thegrid.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "Text-Prime",
    "messages": [
      {"role": "system", "content": "Be concise."},
      {"role": "user", "content": "What is a spot market?"}
    ],
    "max_tokens": 500
  }'
```

The `-L` flag is required. The Consumption API returns a `307 Temporary Redirect` on the way to the supplier endpoint, and cURL does not follow redirects by default. The OpenAI and Anthropic SDKs handle this automatically. See [Request routing and redirects](/docs/api-reference/request-routing-and-redirects.md) for details.

## Where next

* [Authentication](/docs/api-reference/authentication.md): Bearer keys, x-api-key headers, key rotation
* [Current instruments](/docs/instrument-specifications/current-instruments.md): the live instrument catalog
* [Errors and rate limits](/docs/api-reference/errors-and-rate-limits.md)
* [Request routing and redirects](/docs/api-reference/request-routing-and-redirects.md): what the 307 is 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/consumption-api.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.
