# The Grid

## The Grid

- [Overview - The Grid Docs](https://thegrid.ai/docs/readme.md): Start seeing real savings on your LLM costs. Sign up and integrate in <5 mins.
- [Introduction](https://thegrid.ai/docs/start-here/introduction.md): A quick orientation to The Grid: what it does, what you get out of it, and how it fits into your stack.
- [Choose an instrument](https://thegrid.ai/docs/start-here/choose-an-instrument.md): Pick the right task type (Text, Code, or Agent) and tier (Standard, Prime, or Max) for your workload.
- [Quickstart](https://thegrid.ai/docs/start-here/quickstart.md): Get from sign-up to your first API call.
- [Programmatic onboarding](https://thegrid.ai/docs/start-here/programmatic-onboarding.md): Onboard an agent or integration to The Grid over HTTP. Log in with the OAuth device flow, create a consumption API key, and make your first inference call, with optional trading setup.
- [Auto Mode and Advanced Mode](https://thegrid.ai/docs/start-here/auto-mode-vs-advanced-mode.md): Two ways to buy inference on The Grid. Same Consumption API, same endpoint, same errors. The difference is who places the orders behind the scenes.
- [Benefits of consuming market priced inference](https://thegrid.ai/docs/benefits/benefits.md): Why buying inference from a live market beats paying rate-card on a single vendor.
- [Current instruments](https://thegrid.ai/docs/instrument-specifications/current-instruments.md): Compare live Text, Code, and Agent instruments by their associated specifications, including quality, context windows, and speed.
- [How specifications evolve](https://thegrid.ai/docs/instrument-specifications/how-specifications-evolve.md): The cadence and governance behind threshold changes. When we revise specs, how much notice you get, and how supplier rollover works so your code keeps running.
- [Integrations](https://thegrid.ai/docs/integrations-and-best-practices/integrations.md): Set up The Grid in IDEs, coding agents, routers, and agent frameworks.
- [AgentSea | Launch AI agents wired to The Grid](https://thegrid.ai/docs/integrations-and-best-practices/integrations/agentsea.md): Launch a supported AI agent locally or on a fresh cloud VM with one command, pre-wired to The Grid. Install the agentsea CLI, add your key, and connect.
- [Custom Agent Integration with The Grid | OpenAI API Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/general-agent-skill.md): Connect any custom agent to The Grid with the OpenAI API. Set the base URL, add a consumption key, choose an instrument, and handle 402 retries.
- [Cline Integration with The Grid | OpenAI API Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/cline.md): Connect Cline to The Grid with the OpenAI-compatible API. Set the base URL, add your consumption key, choose an instrument, and start coding.
- [Continue Integration with The Grid | config.yaml Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/continue.md): Set up Continue with The Grid in config.yaml. Add your API key, point to the OpenAI-compatible endpoint, and map models to chat, edit, and autocomplete.
- [Cursor Integration with The Grid | Custom Provider Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/cursor.md): Use The Grid in Cursor by overriding the OpenAI base URL, adding your API key, and registering Grid instruments as custom chat models.
- [Claude Code Integration with The Grid | Anthropic API Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/claude-code.md): Use Claude Code with The Grid through the Anthropic Messages API. Set environment variables, map model aliases, and run Claude Code normally.
- [Kilo Code Integration with The Grid | VS Code and CLI Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/kilocode.md): Connect Kilo Code to The Grid in VS Code or the CLI. Add your consumption key, select The Grid, and choose instruments for each mode.
- [OpenCode Integration with The Grid | Provider Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/opencode.md): Connect OpenCode to The Grid with opencode auth /connect. Add your consumption key, choose model and small\_model, and run the agent loop.
- [OpenClaw Integration with The Grid | Custom Backend Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/openclaw.md): Set up OpenClaw with The Grid as a custom OpenAI-compatible backend. Add a provider, allowlist instruments, and restart the gateway.
- [CrewAI Integration with The Grid | Agent LLM Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/crewai.md): Connect CrewAI to The Grid with the LLM class. Use the OpenAI-compatible endpoint, assign Grid models to agents, and tier by role.
- [Deep Agents Integration with The Grid | LangChain Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/deepagents.md): Use Deep Agents with The Grid through ChatOpenAI. Point to the OpenAI-compatible endpoint and set use\_responses\_api=False.
- [DeerFlow Integration with The Grid | config.yaml Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/deerflow.md): Set up DeerFlow with The Grid in config.yaml. Add ChatOpenAI models, point to the Grid endpoint, and set use\_responses\_api to false.
- [Hermes Agent Integration with The Grid | Provider Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/hermes-agent.md): Use The Grid as the AI model behind Hermes Agent. Copy and paste a few commands into your terminal. No coding required.
- [LiteLLM Integration with The Grid | SDK and Proxy Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/litellm.md): Use LiteLLM with The Grid as an OpenAI-compatible backend. Connect through the Python SDK or proxy and route downstream tools.
- [ClawRouter with The Grid | Supported Routing Options](https://thegrid.ai/docs/integrations-and-best-practices/integrations/clawrouter.md): ClawRouter cannot route to The Grid as a backend; here's what works instead in OpenClaw.
- [Manifest Integration with The Grid | Custom Backend Setup](https://thegrid.ai/docs/integrations-and-best-practices/integrations/manifest.md): Connect Manifest to The Grid as a custom OpenAI-compatible backend. Add Grid models, map them to routing tiers, and automate selection.
- [Migrating from OpenAI](https://thegrid.ai/docs/integrations-and-best-practices/migrating-from-openai.md): Switch from the OpenAI API to The Grid by changing three values in your existing code, base URL, API key, and model string. Your SDK, request body, and response shape stay the same.
- [Migrating from Anthropic](https://thegrid.ai/docs/integrations-and-best-practices/migrating-from-anthropic.md): Move an Anthropic-based application to The Grid. Keep the Anthropic SDK against our Messages API beta, or swap to the OpenAI SDK against the Consumption API.
- [Any OpenAI-compatible tool](https://thegrid.ai/docs/integrations-and-best-practices/any-openai-compatible-tool.md): Any tool that targets OpenAI's Chat Completions API works with The Grid. Set the base URL, API key, and model. Tools built on OpenAI's Responses API (Codex and similar) don't work yet.
- [Routing patterns](https://thegrid.ai/docs/integrations-and-best-practices/routing-patterns.md): How to allocate workloads across Grid instruments. Default to Prime, escalate to Max for hard tasks, demote to Standard for volume.
- [Troubleshooting](https://thegrid.ai/docs/integrations-and-best-practices/troubleshooting.md): Common errors when integrating with The Grid and how to fix them. Auth, base URLs, instrument strings, balance, and the "is it me or The Grid" diagnostic flow.
- [Best practices for development](https://thegrid.ai/docs/integrations-and-best-practices/best-practices.md): Production patterns for The Grid. Tier routing, two-balance accounting, retry-on-retryable, streaming, FIFO consumption, Auto Mode limits, instrument pinning, reselling the remainder.
- [Trading bot safety patterns](https://thegrid.ai/docs/integrations-and-best-practices/trading-bot-safety.md): Guardrails for scripts that place real Trading API orders.
- [Overview](https://thegrid.ai/docs/api-reference/api-reference.md): Use The Grid's Consumption, Trading, and Platform APIs for market-priced AI inference, live market data, orders, and account management.
- [Authentication](https://thegrid.ai/docs/api-reference/authentication.md): The Grid issues two types of API keys plus OAuth access tokens for programmatic account control. This page covers generation, use, rotation, and the agent onboarding path.
- [Consumption API](https://thegrid.ai/docs/api-reference/consumption-api.md): The Consumption API is what you call to run inference. Two surfaces (OpenAI Chat Completions and Anthropic Messages) sit in front of the same routing engine.
- [Trading API | Market Data, Trading Balances, & Orders](https://thegrid.ai/docs/api-reference/trading-api.md): API reference for trading and reselling. Read instrument specs, market data, balances, trades, and place orders. Only necessary for advanced mode users.
- [Platform API | OAuth, Key Management & Account Settings](https://thegrid.ai/docs/api-reference/platform-api.md): API reference for OAuth, Trading & Consumption API Key management, and Account Settings, most commonly used by agents.
- [Diagnostics](https://thegrid.ai/docs/api-reference/diagnostics.md): Safe, read-only diagnostics for The Grid CLI and for raw HTTP clients using Platform, Trading, or Consumption authentication.
- [API Errors and Rate Limits](https://thegrid.ai/docs/api-reference/errors-and-rate-limits.md): How both APIs report failure, which errors are retryable, and how rate limits behave. Use this page when your client hits something other than a 200.
- [Request routing and redirects](https://thegrid.ai/docs/api-reference/request-routing-and-redirects.md): How a request to the Consumption API gets to the supplier fulfilling your inference, and which clients need configuration to follow the routing redirect.
- [Order book and matching](https://thegrid.ai/docs/concepts/order-book-and-matching.md): A deep dive into the market mechanisms powering The Grid
- [Reselling tokens](https://thegrid.ai/docs/concepts/reselling.md): Resell unused tokens from your Trading account back on the order book.
- [Instruments as commodities](https://thegrid.ai/docs/concepts/instruments-as-commodities.md): Why we standardize inference into instruments, and what that unlocks for buyers.
- [Data handling and privacy](https://thegrid.ai/docs/data-handling-and-privacy/data-handling-and-privacy.md): What we store, what we don't, and how your prompts and credentials are handled.


---

# 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
This site has an agentic ask interface you may use to query the documentation dynamically 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/index.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.
