Getting started as a Consumer
Sending your first consumption request
Last updated
Was this helpful?
This section walks you through buying your first Instrument Unit (1M tokens) and making your first consumption call. You can plug and play our scripts within your app to get started with buying and consuming inference instantly.
Create an account at thegrid.ai
Navigate to API Keys (accessible here).
Create a Consumption Key for making API calls
Store your keys securely:
Use our App to Market Buy 1 Unit of your chosen Instrument (Chat Fast or Chat Prime).
Chat Fast: suited for latency-sensitive UX, high throughput, instantaneous responses
Chat Prime: suited for higher reasoning quality, thoughtful or calculative responses, deeper workflows
Read more about Current Instruments to guide your decision. Note: Today, Units bought in your Trading Account transfer to your Consumption Account automatically. Read more here.
The Units you purchased need to be consumed within 4 hours, as per Consumption Rules.
Where to go next:
Use the Trading API to buy units programmatically.
Use our Onboarding Guides for ready-to-go scripts to automate your buying and inference consumption on The Grid. These scripts cover common use cases for production implementation.
To ensure performant and efficient service, follow our Best Practices for moving your workloads from other inference providers/aggregators to The Grid
Last updated
Was this helpful?
Was this helpful?
# Environment variables (recommended)
export GRID_CONSUMPTION_API_KEY="<your_consumption_key>"import os
import openai
client = openai.OpenAI(
api_key=os.environ['GRID_CONSUMPTION_API_KEY'],
base_url='https://consumption.api.thegrid.ai/api/v1'
)
response = client.chat.completions.create(
model='chat-fast',
messages=[
{'role': 'system', 'content': 'Be concise and correct.'},
{'role': 'user', 'content': 'Write one paragraph on why inference needs a market.'},
],
)
print('Response:', response.choices[0].message.content)import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.GRID_CONSUMPTION_API_KEY,
baseURL: 'https://consumption.api.thegrid.ai/api/v1'
});
const response = await client.chat.completions.create({
model: 'chat-fast',
messages: [
{ role: 'system', content: 'Be concise and correct.' },
{ role: 'user', content: 'Write one paragraph on why inference needs a market.' }
]
});
console.log('Response:', response.choices[0].message.content);import os
package main
import (
"context"
"fmt"
"log"
"os"
"github.com/openai/openai-go"
"github.com/openai/openai-go/option"
)
func main() {
client := openai.NewClient(
option.WithAPIKey(os.Getenv("GRID_CONSUMPTION_API_KEY")),
option.WithBaseURL("https://consumption.api.thegrid.ai/api/v1"),
)
response, err := client.Chat.Completions.New(context.Background(), openai.ChatCompletionNewParams{
Model: "chat-fast",
Messages: []openai.ChatCompletionMessageParamUnion{
openai.SystemMessage("Be concise and correct."),
openai.UserMessage("Write one paragraph on why inference needs a market."),
},
})
if err != nil {
log.Fatal(err)
}
fmt.Println("Response:", response.Choices[0].Message.Content)