# Quickstart

## Three steps from sign-up to first call

1. **Sign up** at [thegrid.ai](https://thegrid.ai). New accounts get a $25 signup credit (limited time), enough for millions of test calls on `text-prime`.
2. **Get an API key.** Go to [Settings → API Keys](https://app.thegrid.ai/profile) in the dashboard and create a Consumption API key. Copy it now. We don't show it after this.
3. **Make your first call.** Pick the API surface your code already speaks.

## Make your first call

The Grid is compatible with both OpenAI and Anthropic messaging formats. The same Grid API key and instrument strings work on both. We route your request to the supplier offering the best price for that instrument.

### OpenAI Chat Completions

Base URL: `https://api.thegrid.ai/v1`. Auth header: `Authorization: Bearer YOUR_GRID_API_KEY`. Model field: an instrument string like `text-prime` (Text Prime).

{% tabs %}
{% tab title="curl" %}

```bash
curl https://api.thegrid.ai/v1/chat/completions \
  -H "Authorization: Bearer YOUR_GRID_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-prime",
    "messages": [
      {"role": "user", "content": "What is a spot market for AI inference?"}
    ]
  }'
```

{% endtab %}

{% tab title="Python" %}

```python
from openai import OpenAI

client = OpenAI(base_url="https://api.thegrid.ai/v1", api_key="YOUR_GRID_API_KEY")

response = client.chat.completions.create(
    model="text-prime",
    messages=[{"role": "user", "content": "What is a spot market for AI inference?"}],
)

print(response.choices[0].message.content)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.thegrid.ai/v1",
  apiKey: "YOUR_GRID_API_KEY",
});

const response = await client.chat.completions.create({
  model: "text-prime",
  messages: [
    { role: "user", content: "What is a spot market for AI inference?" },
  ],
});

console.log(response.choices[0].message.content);
```

{% endtab %}
{% endtabs %}

### Anthropic Messages (beta)

Base URL: `https://messages-beta.api.thegrid.ai/v1`. Auth header: `x-api-key: YOUR_GRID_API_KEY`. Model field: an instrument string like `text-prime`.

{% tabs %}
{% tab title="curl" %}

```bash
curl https://messages-beta.api.thegrid.ai/v1/messages \
  -H "x-api-key: YOUR_GRID_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "text-prime",
    "max_tokens": 1024,
    "messages": [
      {"role": "user", "content": "What is a spot market for AI inference?"}
    ]
  }'
```

{% endtab %}

{% tab title="Python" %}

```python
from anthropic import Anthropic

client = Anthropic(base_url="https://messages-beta.api.thegrid.ai/v1", api_key="YOUR_GRID_API_KEY")

response = client.messages.create(
    model="text-prime",
    max_tokens=1024,
    messages=[{"role": "user", "content": "What is a spot market for AI inference?"}],
)

print(response.content[0].text)
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic({
  baseURL: "https://messages-beta.api.thegrid.ai/v1",
  apiKey: "YOUR_GRID_API_KEY",
});

const response = await client.messages.create({
  model: "text-prime",
  max_tokens: 1024,
  messages: [
    { role: "user", content: "What is a spot market for AI inference?" },
  ],
});

console.log(response.content[0].text);
```

{% endtab %}
{% endtabs %}

That's it. You're live on The Grid. By default, your account runs in [Auto Mode](/docs/start-here/auto-mode-vs-advanced-mode.md), so we handle token purchasing in the background as you call the API. Add credits at [app.thegrid.ai](https://app.thegrid.ai); we charge against your credit balance per request, and auto-reload tops your balance up when it runs low (configurable in the dashboard).

## What to do next

* Read [Choose an instrument](/docs/start-here/choose-an-instrument.md) before routing production traffic. For the full list, see [Current Instruments](/docs/instrument-specifications/current-instruments.md).
* Add a payment method and configure auto-reload in [Auto Mode vs Advanced Mode](/docs/start-here/auto-mode-vs-advanced-mode.md).
* To place orders directly on the order book, see [Advanced Mode](/docs/start-here/auto-mode-vs-advanced-mode.md).


---

# 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/start-here/quickstart.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.
