{
  "openapi": "3.0.3",
  "info": {
    "title": "The Grid API -- AI Inference Spot Market",
    "description": "OpenAPI spec for The Grid's Consumption and Trading APIs, including auth, endpoints, and instruments.\n\n# The Grid API -- AI Inference Spot Market\n\nThe Grid (thegrid.ai) is a real-time spot market for AI inference. This specification covers both APIs:\n\n## Consumption API (https://api.thegrid.ai/v1)\n\nFully OpenAI-compatible chat completions and model listing. Drop-in replacement for the OpenAI SDK: change your base_url and API key, keep everything else. Authenticated via Bearer token.\n\n## Trading API (https://trading.api.thegrid.ai/v1)\n\nProgrammatic access to the central limit order book. Place market and limit orders, manage positions, track balances across Trading and Consumption accounts, view real-time market data. For advanced users. Authenticated via Ed25519 signatures.\n\n## Platform API (https://platform.api.thegrid.ai/v1)\n\nAccount control plane for programmatic and agentic onboarding. OAuth 2.0 device-flow login, consumption API key creation, Ed25519 trading signing key registration, and account settings. Agents authenticate here, mint a consumption key, then call the Consumption API with it. Authenticated via OAuth bearer tokens. See https://thegrid.ai/docs/api-reference/platform-api.\n\n---\n\nThe Grid is NOT affiliated with Grid AI (grid.ai / Lightning AI), GridAI Technologies (NASDAQ: GRDX), DGrid (dgrid.ai), or the defunct \"The Grid\" website builder. The correct domain is thegrid.ai.",
    "version": "1.0.0",
    "contact": {
      "name": "The Grid Support",
      "email": "support@thegrid.ai",
      "url": "https://thegrid.ai/docs"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://thegrid.ai/terms-of-use"
    },
    "x-logo": {
      "url": "https://thegrid.ai/logo.png",
      "altText": "The Grid -- Real-Time AI Inference Spot Market"
    },
    "x-resource-description": "OpenAPI spec for The Grid's Consumption and Trading APIs, including auth, endpoints, and instruments.",
    "termsOfService": "https://thegrid.ai/terms-of-use"
  },
  "externalDocs": {
    "description": "The Grid Documentation -- full API reference, concepts, and quickstart guides",
    "url": "https://thegrid.ai/docs"
  },
  "servers": [
    {
      "url": "https://api.thegrid.ai/v1",
      "description": "Consumption API -- OpenAI-compatible inference endpoint"
    },
    {
      "url": "https://platform.api.thegrid.ai/v1",
      "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
    },
    {
      "url": "https://trading.api.thegrid.ai/v1",
      "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
    }
  ],
  "tags": [
    {
      "name": "Consumption: Chat Completions",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- the chat completions endpoint is fully OpenAI-compatible. It works identically to OpenAI's /v1/chat/completions -- same request body, same response shape, same streaming behavior, same SDK. Requests are routed to competing suppliers at market-driven prices with quality guaranteed by the instrument selected as the model, such as text-prime, code-prime, or agent-standard. Supports streaming, tool calling, structured output (JSON schema), and reasoning effort control."
    },
    {
      "name": "Consumption: Models",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- the models endpoint returns all available Grid instruments. Current instruments: text-standard, text-prime, text-max, code-standard, code-prime, code-max, agent-standard, agent-prime, agent-max. Use the instrument id as the model parameter in chat completion requests."
    },
    {
      "name": "Trading: Accounts",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- account endpoints return balances for Trading Accounts (Units eligible for resale), Consumption Accounts (Units locked for API inference with 4-hour expiry windows), and Currency Accounts (USD balances)."
    },
    {
      "name": "Trading: Instruments",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- instruments are standardized contracts that define minimum quality guarantees for inference. Current instruments: Text Standard, Text Prime, Text Max, Code Standard, Code Prime, Code Max, Agent Standard, Agent Prime, Agent Max. Each is defined by benchmark thresholds that qualifying supplier models must meet."
    },
    {
      "name": "Trading: Markets",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- market endpoints return information about active trading markets, including real-time order book depth, market statistics, ticker data, and the instruments available for trading. Markets are where buyers and suppliers discover prices for standardized inference capacity."
    },
    {
      "name": "Trading: Orders",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- order endpoints manage buy and sell orders on the central limit order book. Market orders fill immediately at best available prices. Limit orders specify a price ceiling (buys) or floor (sells) and may rest on the book until filled."
    },
    {
      "name": "Trading: Trades",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- trade endpoints return completed trade records where Units of an Instrument changed hands at a market-determined price."
    },
    {
      "name": "Trading: Transfers",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- transfer endpoints move Units between your Trading Account and Consumption Account. Units in the Consumption Account are locked for API usage and cannot be resold."
    },
    {
      "name": "Platform: OAuth",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- the Platform API is the account control plane. OAuth 2.0 device flow login (RFC 8628), token refresh and revocation (RFC 7009), and scope discovery. Agents use it to self-provision credentials over HTTP without a human copying a key out of a dashboard."
    },
    {
      "name": "Platform: Credentials",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- credential endpoints create and revoke the two key types: consumption API keys for inference on the Consumption API, and Ed25519 signing keys for request signing on the Trading API. Both require the keys:manage OAuth scope."
    },
    {
      "name": "Consumption: Responses",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- the responses endpoint implements OpenAI's /v1/responses contract. Same request body, same response shape, same SDK. Requests are routed to competing suppliers at market-driven prices with quality guaranteed by the instrument selected as the model, such as text-prime, code-prime, or agent-standard."
    },
    {
      "name": "Consumption: Messages",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- the messages endpoint is Anthropic Messages API compatible, so an existing Anthropic SDK client can target The Grid by changing its base URL. Requests are routed to competing suppliers at market-driven prices with quality guaranteed by the instrument selected as the model."
    },
    {
      "name": "Consumption: Usage",
      "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- the usage endpoints return per-request receipts and aggregated spend for the calling account, including token counts, timing (time to first token, tokens per second), settled cost and cost status. Because instruments are market priced, these endpoints are the authoritative source of what a request actually cost."
    }
  ],
  "paths": {
    "/chat/completions": {
      "post": {
        "summary": "Create chat completion",
        "description": "The Grid (thegrid.ai) is a real-time spot market for AI inference with a fully OpenAI-compatible API. This endpoint works identically to OpenAI's /v1/chat/completions -- same request body, same response shape, same streaming behavior, same SDK. Point your existing OpenAI client at https://api.thegrid.ai/v1, and requests are routed to competing suppliers at market-driven prices with quality guaranteed by the Instrument specification you selected.\n\nCreates a chat completion for the provided messages using the specified model. This endpoint is compatible with the OpenAI chat completions API format.\n\nThe request is validated and then routed to the appropriate LLM provider. Your account balance is checked before processing.",
        "operationId": "createChatCompletion",
        "tags": [
          "Consumption: Chat Completions"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X POST 'https://api.thegrid.ai/v1/chat/completions' \\\n  -H 'Authorization: Bearer YOUR_API_KEY' \\\n  -H 'Content-Type: application/json' \\\n  -d '{\n    \"model\": \"text-prime\",\n    \"messages\": [\n      {\"role\": \"system\", \"content\": \"Be concise and to the point.\"},\n      {\"role\": \"user\", \"content\": \"Write one paragraph on why inference needs a market.\"}\n    ],\n    \"max_tokens\": 500\n  }'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nresponse = requests.post(\n    'https://api.thegrid.ai/v1/chat/completions',\n    headers={\n        'Authorization': 'Bearer YOUR_API_KEY',\n        'Content-Type': 'application/json'\n    },\n    json={\n        'model': 'text-prime',\n        'messages': [\n            {'role': 'system', 'content': 'Be concise and to the point.'},\n            {'role': 'user', 'content': 'Write one paragraph on why inference needs a market.'}\n        ],\n        'max_tokens': 500\n    }\n)\ncompletion = response.json()"
          },
          {
            "lang": "JavaScript",
            "source": "const response = await fetch('https://api.thegrid.ai/v1/chat/completions', {\n  method: 'POST',\n  headers: {\n    'Authorization': 'Bearer YOUR_API_KEY',\n    'Content-Type': 'application/json'\n  },\n  body: JSON.stringify({\n    model: 'text-prime',\n    messages: [\n      { role: 'system', content: 'Be concise and to the point.' },\n      { role: 'user', content: 'Write one paragraph on why inference needs a market.' }\n    ],\n    max_tokens: 500\n  })\n});\nconst completion = await response.json();"
          },
          {
            "lang": "Python",
            "label": "OpenAI SDK",
            "source": "from openai import OpenAI\n\nclient = OpenAI(\n    api_key='YOUR_API_KEY',\n    base_url='https://api.thegrid.ai/v1'\n)\n\ncompletion = client.chat.completions.create(\n    model='text-prime',\n    messages=[\n        {'role': 'system', 'content': 'Be concise and to the point.'},\n        {'role': 'user', 'content': 'Write one paragraph on why inference needs a market.'}\n    ],\n    max_tokens=500\n)"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "description": "Chat completion request parameters",
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionsRequest"
              },
              "example": {
                "model": "text-prime",
                "messages": [
                  {
                    "role": "system",
                    "content": "Be concise and to the point."
                  },
                  {
                    "role": "user",
                    "content": "Write one paragraph on why inference needs a market."
                  }
                ],
                "max_tokens": 500,
                "temperature": 0.7
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                },
                "example": {
                  "id": "chatcmpl-abc123",
                  "object": "chat.completion",
                  "created": 1677858242,
                  "model": "text-prime",
                  "choices": [
                    {
                      "index": 0,
                      "message": {
                        "role": "assistant",
                        "content": "Inference - the real‑time application of trained AI models to generate predictions, classifications, or recommendations - requires a market because its value is realized only when it can be delivered as a scalable, reliable service to end users. A market provides the economic incentives for developers to invest in optimizing hardware, software, and infrastructure that reduce latency, improve accuracy, and lower cost per query; it creates competition that drives innovation in model compression, edge deployment, and pricing models (pay‑per‑call, subscription, or platform‑as‑a‑service). Moreover, a market facilitates the aggregation of demand across diverse industries—healthcare, finance, retail, autonomous systems—allowing providers to achieve economies of scale, standardize APIs, and ensure compliance and security standards. Without such a marketplace, inference would remain a fragmented, research‑only capability, lacking the financial and operational mechanisms needed for widespread, sustainable adoption."
                      },
                      "finish_reason": "stop"
                    }
                  ],
                  "usage": {
                    "prompt_tokens": 25,
                    "completion_tokens": 18,
                    "total_tokens": 43
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request - Invalid parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "Invalid model specified"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "Invalid API key"
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found - Model not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "Model not found"
                  }
                }
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": [
                    {
                      "path": "messages",
                      "message": "is required",
                      "value": null
                    }
                  ]
                }
              }
            }
          },
          "429": {
            "description": "Rate Limit Exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "Rate limit exceeded. Please retry after 60 seconds."
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "Internal server error"
                  }
                }
              }
            }
          },
          "503": {
            "description": "Service Unavailable - Balance replenishment in progress. Retry the request after a short delay.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BalanceError"
                },
                "example": {
                  "error": {
                    "code": "balance_replenishing",
                    "message": "Balance replenishment in progress. Please retry shortly.",
                    "type": "balance_replenishing",
                    "param": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://api.thegrid.ai/v1",
          "description": "Consumption API -- OpenAI-compatible inference endpoint"
        }
      ]
    },
    "/models": {
      "get": {
        "summary": "List available models",
        "description": "On The Grid (thegrid.ai) -- a real-time spot market for AI inference -- this endpoint lists all available instruments you can use as the model parameter. Current instruments span Text, Code, and Agent task types across Standard, Prime, and Max tiers: text-standard, text-prime, text-max, code-standard, code-prime, code-max, agent-standard, agent-prime, agent-max. Prices are set by real-time supplier competition on a live order book.\n\nReturns a list of all available Grid instruments that can be passed in the chat completions \"model\" field. Each instrument includes its ID, display name, and metadata. Use the instrument id when making chat completion requests.",
        "operationId": "listModels",
        "tags": [
          "Consumption: Models"
        ],
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://api.thegrid.ai/v1/models' \\\n  -H 'Authorization: Bearer YOUR_API_KEY'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nresponse = requests.get(\n    'https://api.thegrid.ai/v1/models',\n    headers={'Authorization': 'Bearer YOUR_API_KEY'}\n)\nmodels = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "const response = await fetch('https://api.thegrid.ai/v1/models', {\n  headers: {\n    'Authorization': 'Bearer YOUR_API_KEY'\n  }\n});\nconst { data: models } = await response.json();"
          },
          {
            "lang": "Python",
            "label": "OpenAI SDK",
            "source": "from openai import OpenAI\n\nclient = OpenAI(\n    api_key='YOUR_API_KEY',\n    base_url='https://api.thegrid.ai/v1'\n)\n\nmodels = client.models.list()"
          }
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of available models",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelsResponse"
                },
                "example": {
                  "object": "list",
                  "data": [
                    {
                      "id": "text-standard",
                      "object": "model",
                      "display_name": "Text Standard",
                      "created": 1709251200,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "text-prime",
                      "object": "model",
                      "display_name": "Text Prime",
                      "created": 1709251201,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "text-max",
                      "object": "model",
                      "display_name": "Text Max",
                      "created": 1709251202,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "code-standard",
                      "object": "model",
                      "display_name": "Code Standard",
                      "created": 1709251203,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "code-prime",
                      "object": "model",
                      "display_name": "Code Prime",
                      "created": 1709251204,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "code-max",
                      "object": "model",
                      "display_name": "Code Max",
                      "created": 1709251205,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "agent-standard",
                      "object": "model",
                      "display_name": "Agent Standard",
                      "created": 1709251206,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "agent-prime",
                      "object": "model",
                      "display_name": "Agent Prime",
                      "created": 1709251207,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "agent-max",
                      "object": "model",
                      "display_name": "Agent Max",
                      "created": 1709251208,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "gpt-sol-latest",
                      "object": "model",
                      "display_name": "GPT Sol Latest",
                      "created": 1709251209,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "claude-opus-latest",
                      "object": "model",
                      "display_name": "Claude Opus Latest",
                      "created": 1709251210,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "gemini-pro-latest",
                      "object": "model",
                      "display_name": "Gemini Pro Latest",
                      "created": 1709251211,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "minimax-latest",
                      "object": "model",
                      "display_name": "MiniMax Latest",
                      "created": 1709251212,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "glm-latest",
                      "object": "model",
                      "display_name": "GLM Latest",
                      "created": 1709251213,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "deepseek-pro-latest",
                      "object": "model",
                      "display_name": "DeepSeek Pro Latest",
                      "created": 1709251214,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "kimi-latest",
                      "object": "model",
                      "display_name": "Kimi Latest",
                      "created": 1709251215,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "bytedance-pro-latest",
                      "object": "model",
                      "display_name": "ByteDance Pro Latest",
                      "created": 1709251216,
                      "owned_by": "The Grid"
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized - Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "Invalid API key"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "Internal server error"
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://api.thegrid.ai/v1",
          "description": "Consumption API -- OpenAI-compatible inference endpoint"
        }
      ]
    },
    "/consumption-accounts": {
      "get": {
        "tags": [
          "Trading: Accounts"
        ],
        "summary": "List consumption accounts",
        "description": "View your consumption accounts by instrument, including balances and tokens used.",
        "operationId": "listConsumptionAccounts",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/consumption-accounts' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/consumption-accounts'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\naccounts = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/consumption-accounts';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst accounts = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/consumption-accounts\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []struct {\n\t\tAccountID          string `json:\"account_id\"`\n\t\tUserID             string `json:\"user_id\"`\n\t\tInstrumentID       string `json:\"instrument_id\"`\n\t\tTotalBalance       string `json:\"total_balance\"`\n\t\tCommittedBalance   string `json:\"committed_balance\"`\n\t\tUncommittedBalance string `json:\"uncommitted_balance\"`\n\t\tStatus             string `json:\"status\"`\n\t} `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by account ID"
          },
          {
            "name": "instrument_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by instrument ID"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ]
            },
            "description": "Filter by account status"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "account_id",
                "total_balance",
                "committed_balance",
                "uncommitted_balance",
                "status",
                "created_at",
                "updated_at"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "Consumption accounts",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionAccountsResponse"
                },
                "example": {
                  "data": [
                    {
                      "account_id": "test-consumption-account-user_5f6f9f3c-fa96-4400-a5e1-61abf0a6017e-test-instrument-123",
                      "user_id": "user_5f6f9f3c-fa96-4400-a5e1-61abf0a6017e",
                      "instrument_id": "test-instrument-123",
                      "total_balance": 5,
                      "committed_balance": 2,
                      "uncommitted_balance": 3,
                      "tokens_allocated": 2000000,
                      "tokens_available": 500000,
                      "status": "active",
                      "total_commitments": 0,
                      "total_deposits": 2,
                      "total_transfers_in": 2,
                      "total_transfers_out": 0,
                      "total_withdrawals": 0,
                      "last_commitment_at": null,
                      "last_deposit_at": "2026-02-25T17:07:40Z",
                      "last_transfer_at": "2026-02-25T17:07:40Z",
                      "last_withdrawal_at": null,
                      "created_at": "2026-02-25T17:07:40Z",
                      "updated_at": "2026-02-25T17:07:40Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/consumption-accounts/{account_id}": {
      "get": {
        "tags": [
          "Trading: Accounts"
        ],
        "summary": "Get consumption account details",
        "description": "Get detailed information about a specific consumption account.",
        "operationId": "tradingGetConsumptionAccount",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/consumption-accounts/consumption_account_cbf73393ef9e2ed0' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\naccount_id = 'consumption_account_cbf73393ef9e2ed0'\npath = f'/v1/consumption-accounts/{account_id}'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\naccount = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst accountId = 'consumption_account_cbf73393ef9e2ed0';\nconst path = `/v1/consumption-accounts/${accountId}`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst account = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\naccountID := \"consumption_account_cbf73393ef9e2ed0\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/consumption-accounts/%s\", accountID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData ConsumptionAccount `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the consumption account (e.g., \"consumption_account_cbf73393ef9e2ed0\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Consumption account details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/ConsumptionAccount"
                    }
                  }
                },
                "example": {
                  "data": {
                    "account_id": "test-consumption-account-user_3c9b0fd6-4183-431e-9973-cfcd54c3136f-test-instrument-123",
                    "user_id": "user_3c9b0fd6-4183-431e-9973-cfcd54c3136f",
                    "instrument_id": "test-instrument-123",
                    "total_balance": 5,
                    "committed_balance": 2,
                    "uncommitted_balance": 3,
                    "tokens_allocated": 2000000,
                    "tokens_available": 500000,
                    "status": "active",
                    "total_commitments": 0,
                    "total_deposits": 2,
                    "total_transfers_in": 2,
                    "total_transfers_out": 0,
                    "total_withdrawals": 0,
                    "last_commitment_at": null,
                    "last_deposit_at": "2026-02-25T17:07:40Z",
                    "last_transfer_at": "2026-02-25T17:07:40Z",
                    "last_withdrawal_at": null,
                    "created_at": "2026-02-25T17:07:40Z",
                    "updated_at": "2026-02-25T17:07:40Z"
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/currency-trading-accounts": {
      "get": {
        "tags": [
          "Trading: Accounts"
        ],
        "summary": "List currency trading accounts",
        "description": "List all currency trading accounts (USD, etc.).",
        "operationId": "tradingListCurrencyAccounts",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/currency-trading-accounts' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/currency-trading-accounts'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\ncurrency_accounts = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/currency-trading-accounts';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst currencyAccounts = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/currency-trading-accounts\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []CurrencyAccount `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "user_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by user ID"
          },
          {
            "name": "account_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by account ID"
          },
          {
            "name": "currency",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by currency (e.g., \"USD\")"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ]
            },
            "description": "Filter by account status"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "account_id",
                "currency",
                "total_balance",
                "available_balance",
                "status",
                "created_at",
                "updated_at"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "List of currency trading accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/CurrencyTradingAccount"
                      }
                    },
                    "paging": {
                      "$ref": "#/components/schemas/CursorPaging"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "account_id": "currency_trading_account_e927ad93f9c4aaa8",
                      "user_id": "user_2e605810-1e39-4d5a-a8e2-e46c89ac4b26",
                      "currency": "USD",
                      "total_balance": "1200",
                      "available_balance": "700",
                      "locked_balance": "500",
                      "status": "active",
                      "last_deposit_at": null,
                      "last_trading_activity_at": null,
                      "last_withdrawal_at": null,
                      "created_at": "2025-12-10T18:19:01Z",
                      "updated_at": "2025-12-10T18:19:01Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/currency-trading-accounts/{account_id}": {
      "get": {
        "tags": [
          "Trading: Accounts"
        ],
        "summary": "Get currency account details",
        "description": "Get specific currency trading account details.",
        "operationId": "tradingGetCurrencyAccount",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/currency-trading-accounts/currency_trading_account_57252e83c212e7a9' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\naccount_id = 'currency_trading_account_57252e83c212e7a9'\npath = f'/v1/currency-trading-accounts/{account_id}'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\naccount = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst accountId = 'currency_trading_account_57252e83c212e7a9';\nconst path = `/v1/currency-trading-accounts/${accountId}`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst account = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\naccountID := \"currency_trading_account_57252e83c212e7a9\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/currency-trading-accounts/%s\", accountID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData CurrencyAccount `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the currency trading account (e.g., \"currency_trading_account_57252e83c212e7a9\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Currency account details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/CurrencyTradingAccount"
                    }
                  }
                },
                "example": {
                  "data": {
                    "account_id": "currency_trading_account_57252e83c212e7a9",
                    "user_id": "user_2ce466b1-d257-4337-98e4-54b4fd254702",
                    "currency": "USD",
                    "total_balance": "1200",
                    "available_balance": "700",
                    "locked_balance": "500",
                    "status": "active",
                    "last_deposit_at": null,
                    "last_trading_activity_at": null,
                    "last_withdrawal_at": null,
                    "created_at": "2025-12-10T18:19:01Z",
                    "updated_at": "2025-12-10T18:19:01Z"
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/instruments": {
      "get": {
        "tags": [
          "Trading: Instruments"
        ],
        "summary": "List instruments",
        "description": "Lists all available instruments with optional filtering and sorting.",
        "operationId": "listInstruments",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/instruments' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/instruments'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\ninstruments = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/instruments';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst instruments = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/instruments\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []Instrument `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "symbol",
                "created_at",
                "updated_at"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ]
            },
            "description": "Sort direction"
          },
          {
            "name": "symbol",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by exact symbol match (e.g., \"text-prime\")"
          },
          {
            "name": "instrument_type",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "ai_commodity",
                "currency",
                "commodity"
              ]
            },
            "description": "Filter by instrument type"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "draft",
                "active",
                "inactive",
                "suspended",
                "deleted"
              ]
            },
            "description": "Filter by status"
          }
        ],
        "responses": {
          "200": {
            "description": "List of instruments",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstrumentListResponse"
                },
                "example": {
                  "data": [
                    {
                      "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                      "symbol": "text-prime",
                      "name": "Text Prime",
                      "description": "High-quality AI inference capacity",
                      "instrument_type": "ai_commodity",
                      "status": "active",
                      "basic_info": {
                        "service_type": "text_generation",
                        "model_category": "language_model"
                      },
                      "trading_params": {
                        "min_quantity": 1,
                        "max_quantity": 1000,
                        "quantity_increment": 1,
                        "fee": "0.025"
                      },
                      "ai_specs": {
                        "context_window": "200000",
                        "token_throughput": "50",
                        "tokens_per_unit": 1000000,
                        "unit_definition": "per_1000_input_tokens",
                        "qualifying_models": [
                          "gpt-5",
                          "gpt-5-mini"
                        ],
                        "max_output_length": 4096,
                        "model_id": "gpt-5",
                        "model_version": "1.0"
                      }
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/instruments/{instrument_id}": {
      "get": {
        "tags": [
          "Trading: Instruments"
        ],
        "summary": "Get instrument details",
        "description": "Gets a specific instrument by its ID. Returns full instrument details including\ntrading parameters and AI specifications.",
        "operationId": "getInstrument",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/instruments/instrument_c18a986c-522b-475a-b319-f2d0ba04a64d' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\ninstrument_id = 'instrument_c18a986c-522b-475a-b319-f2d0ba04a64d'\npath = f'/v1/instruments/{instrument_id}'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\ninstrument = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst instrumentId = 'instrument_c18a986c-522b-475a-b319-f2d0ba04a64d';\nconst path = `/v1/instruments/${instrumentId}`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst instrument = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\ninstrumentID := \"instrument_c18a986c-522b-475a-b319-f2d0ba04a64d\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/instruments/%s\", instrumentID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData InstrumentDetail `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "instrument_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the instrument (e.g., \"instrument_c18a986c-522b-475a-b319-f2d0ba04a64d\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Instrument details",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/InstrumentDetailResponse"
                },
                "example": {
                  "data": {
                    "instrument_id": "instrument_c18a986c-522b-475a-b319-f2d0ba04a64d",
                    "symbol": "text-prime",
                    "name": "Text Prime Instrument",
                    "description": "High-quality AI inference capacity",
                    "instrument_type": "ai_commodity",
                    "status": "active",
                    "basic_info": {
                      "service_type": "text_generation",
                      "model_category": "language_model"
                    },
                    "trading_params": {
                      "min_quantity": 1,
                      "max_quantity": 1000,
                      "quantity_increment": 1,
                      "fee": "0.025"
                    },
                    "ai_specs": {
                      "context_window": "200000",
                      "token_throughput": "50",
                      "tokens_per_unit": 1000000,
                      "unit_definition": "per_1000_input_tokens",
                      "qualifying_models": [
                        "gpt-5",
                        "gpt-5-mini"
                      ],
                      "max_output_length": 4096,
                      "model_id": "gpt-5",
                      "model_version": "1.0"
                    },
                    "last_trade_price": null,
                    "last_trade_at": null,
                    "last_quote_at": null,
                    "total_volume": "0",
                    "volume_24h": "0",
                    "total_trades": 0,
                    "total_quotes": 0,
                    "price_range_24h_high": null,
                    "price_range_24h_low": null
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/markets": {
      "get": {
        "tags": [
          "Trading: Markets"
        ],
        "summary": "List markets",
        "description": "Returns markets with instrument details.",
        "operationId": "tradingListMarkets",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/markets' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/markets'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\nmarkets = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/markets';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst markets = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/markets\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []MarketWithInstruments `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "responses": {
          "200": {
            "description": "List of markets",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/MarketWithInstruments"
                      }
                    },
                    "paging": {
                      "$ref": "#/components/schemas/CursorPaging"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "name": "Alpha Market",
                      "description": "Primary market for AI inference trading",
                      "market_type": "spot",
                      "status": "active",
                      "associated_instruments": [
                        "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                        "instrument_b237c3b4-e623-48ba-bddd-a8ee5230973e"
                      ],
                      "instruments": [
                        {
                          "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                          "instrument_type": "ai_commodity",
                          "symbol": "text-prime",
                          "name": "Text Prime",
                          "description": "High-quality AI inference capacity"
                        },
                        {
                          "instrument_id": "instrument_b237c3b4-e623-48ba-bddd-a8ee5230973e",
                          "instrument_type": "ai_commodity",
                          "symbol": "text-standard",
                          "name": "Text Standard",
                          "description": "Fast chat inference capacity"
                        }
                      ],
                      "created_at": "2025-12-15T11:29:53Z",
                      "updated_at": "2025-12-15T11:29:53Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/markets/{market_id}/ticker": {
      "get": {
        "tags": [
          "Trading: Markets"
        ],
        "summary": "Get market ticker",
        "description": "Get current ticker data including best bid/ask, last price, and 24h volume.",
        "operationId": "tradingGetTicker",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/markets/market_b310e860-97cd-45eb-bdc3-5be0b79295d0/ticker' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\nmarket_id = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0'\npath = f'/v1/markets/{market_id}/ticker'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\nticker = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst marketId = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0';\nconst path = `/v1/markets/${marketId}/ticker`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst ticker = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nmarketID := \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/markets/%s/ticker\", marketID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData Ticker `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the market (e.g., \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Ticker data including last trade, bid/ask, and 24h volume",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Ticker"
                    }
                  }
                },
                "example": {
                  "data": {
                    "last_price": "45.50",
                    "last_trade_quantity": 100,
                    "last_trade_timestamp": "2026-02-12T07:42:45Z",
                    "lowest_ask": "45.75",
                    "highest_bid": "45.25",
                    "volume_24h": 15000
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/markets/{market_id}/orderbook": {
      "get": {
        "tags": [
          "Trading: Markets"
        ],
        "summary": "Get order book",
        "description": "Get the order book (depth of market) for a specific market.",
        "operationId": "tradingGetOrderbook",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/markets/market_b310e860-97cd-45eb-bdc3-5be0b79295d0/orderbook' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\nmarket_id = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0'\npath = f'/v1/markets/{market_id}/orderbook'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\nbook = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst marketId = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0';\nconst path = `/v1/markets/${marketId}/orderbook`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst book = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nmarketID := \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/markets/%s/orderbook\", marketID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData Orderbook `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the market (e.g., \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\")"
          },
          {
            "name": "depth",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 10,
              "minimum": 1,
              "maximum": 100
            },
            "description": "Maximum number of price levels to return per side (bids and asks). Default: 10. Use lower values for quick price checks, higher values for detailed market depth analysis."
          }
        ],
        "responses": {
          "200": {
            "description": "Order book data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OrderbookResponse"
                },
                "example": {
                  "data": {
                    "buy": [
                      {
                        "price": "144.50",
                        "quantity": 100,
                        "total": 100,
                        "order_count": 1
                      },
                      {
                        "price": "144.00",
                        "quantity": 200,
                        "total": 300,
                        "order_count": 1
                      }
                    ],
                    "sell": [
                      {
                        "price": "145.50",
                        "quantity": 150,
                        "total": 150,
                        "order_count": 1
                      },
                      {
                        "price": "146.00",
                        "quantity": 250,
                        "total": 400,
                        "order_count": 1
                      }
                    ],
                    "highest_bid": "144.50000000",
                    "lowest_ask": "145.50000000",
                    "updated_at": "2025-12-15T11:29:53.531908Z"
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/markets/{market_id}/trades": {
      "get": {
        "tags": [
          "Trading: Markets"
        ],
        "summary": "Get market trades",
        "description": "Returns public trades for a specific market (not scoped to authenticated user).",
        "operationId": "tradingGetMarketTrades",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/markets/market_b310e860-97cd-45eb-bdc3-5be0b79295d0/trades' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\nmarket_id = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0'\npath = f'/v1/markets/{market_id}/trades'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\ntrades = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst marketId = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0';\nconst path = `/v1/markets/${marketId}/trades`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst trades = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nmarketID := \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/markets/%s/trades\", marketID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []PublicTrade `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the market (e.g., \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\")"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by trade status"
          },
          {
            "name": "side",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "buy",
                "sell"
              ]
            },
            "description": "Filter by taker side"
          },
          {
            "name": "min_quantity",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Filter trades with quantity >= this value"
          },
          {
            "name": "max_quantity",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Filter trades with quantity <= this value"
          },
          {
            "name": "min_price",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter trades with price >= this value"
          },
          {
            "name": "max_price",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter trades with price <= this value"
          },
          {
            "name": "start_date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter trades executed at or after this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "end_date",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter trades executed at or before this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "execution_timestamp",
                "quantity",
                "price"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "default": 50,
              "maximum": 100
            },
            "description": "Number of trades to return (max: 100)"
          }
        ],
        "responses": {
          "200": {
            "description": "Recent trades",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/PublicTrade"
                      }
                    },
                    "paging": {
                      "$ref": "#/components/schemas/CursorPaging"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "trade_id": "trade_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_name": null,
                      "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                      "instrument_symbol": "text-prime",
                      "instrument_name": "Text Prime",
                      "price": "45.50000000",
                      "quantity": 3,
                      "side": "buy",
                      "total_value": "45500.00000000",
                      "status": "executed",
                      "execution_timestamp": "2025-12-05T17:29:29.944711Z",
                      "settlement_timestamp": "2025-12-05T17:29:29.944712Z"
                    },
                    {
                      "trade_id": "trade_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_name": null,
                      "instrument_id": "instrument_b237c3b4-e623-48ba-bddd-a8ee5230973e",
                      "instrument_symbol": "text-standard",
                      "instrument_name": "Text Standard",
                      "price": "45.50000000",
                      "quantity": 11,
                      "side": "buy",
                      "total_value": "45500.00000000",
                      "status": "executed",
                      "execution_timestamp": "2025-12-05T17:29:29.944180Z",
                      "settlement_timestamp": "2025-12-05T17:29:29.944181Z"
                    },
                    {
                      "trade_id": "trade_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_name": null,
                      "instrument_id": "instrument_c18a986c-522b-475a-b319-f2d0ba04a64d",
                      "instrument_symbol": "text-standard",
                      "instrument_name": "Text Standard",
                      "price": "45.50000000",
                      "quantity": 1,
                      "side": "buy",
                      "total_value": "45500.00000000",
                      "status": "executed",
                      "execution_timestamp": "2025-12-05T17:29:29.942332Z",
                      "settlement_timestamp": "2025-12-05T17:29:29.942334Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/markets/{market_id}": {
      "get": {
        "tags": [
          "Trading: Markets"
        ],
        "summary": "Get market details",
        "description": "Returns market details with instruments.",
        "operationId": "tradingGetMarket",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/markets/market_b310e860-97cd-45eb-bdc3-5be0b79295d0' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\nmarket_id = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0'\npath = f'/v1/markets/{market_id}'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\nmarket = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst marketId = 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0';\nconst path = `/v1/markets/${marketId}`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst market = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nmarketID := \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/markets/%s\", marketID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData MarketWithInstruments `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the market (e.g., \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Market details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/MarketWithInstruments"
                    }
                  }
                },
                "example": {
                  "data": {
                    "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                    "name": "Detail Market",
                    "description": "Primary market for AI inference trading",
                    "market_type": "spot",
                    "status": "active",
                    "associated_instruments": [
                      "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                      "instrument_b237c3b4-e623-48ba-bddd-a8ee5230973e"
                    ],
                    "instruments": [
                      {
                        "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                        "instrument_type": "ai_commodity",
                        "symbol": "text-prime",
                        "name": "Text Prime",
                        "description": "High-quality AI inference capacity"
                      },
                      {
                        "instrument_id": "instrument_b237c3b4-e623-48ba-bddd-a8ee5230973e",
                        "instrument_type": "ai_commodity",
                        "symbol": "text-standard",
                        "name": "Text Standard",
                        "description": "Fast chat inference capacity"
                      }
                    ],
                    "created_at": "2025-12-15T11:29:53Z",
                    "updated_at": "2025-12-15T11:29:53Z"
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/orders": {
      "get": {
        "tags": [
          "Trading: Orders"
        ],
        "summary": "List trader's orders",
        "description": "Returns the authenticated trader's orders using Ed25519 signature authentication.",
        "operationId": "tradingListOrders",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/orders' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/orders'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\norders = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/orders';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst orders = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/orders\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []Order `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by market ID"
          },
          {
            "name": "trader_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by trader ID"
          },
          {
            "name": "instrument_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by instrument ID"
          },
          {
            "name": "side",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "buy",
                "sell"
              ]
            },
            "description": "Filter by order side"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "closed",
                "cancelled"
              ]
            },
            "description": "Filter by order status"
          },
          {
            "name": "start_datetime",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter orders submitted at or after this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "end_datetime",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter orders submitted at or before this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "submitted_at",
                "filled_at",
                "price",
                "original_quantity",
                "quantity",
                "order_id"
              ]
            },
            "description": "Field to sort by (`quantity` is alias for original_quantity)"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "List of orders",
            "headers": {
              "x-request-id": {
                "$ref": "#/components/headers/x-request-id"
              },
              "x-ratelimit-limit": {
                "$ref": "#/components/headers/x-ratelimit-limit"
              },
              "x-ratelimit-remaining": {
                "$ref": "#/components/headers/x-ratelimit-remaining"
              },
              "x-ratelimit-reset": {
                "$ref": "#/components/headers/x-ratelimit-reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradingOrderListResponse"
                },
                "example": {
                  "data": [
                    {
                      "order_id": "order_ZVFOAGG4JWRNXMCK",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_name": "Text Prime",
                      "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                      "instrument_name": "Text Prime",
                      "instrument_symbol": "text-prime",
                      "trader_id": "user_1b8dafe4-cea0-415a-8e4c-089c5af0168f",
                      "type": "limit",
                      "side": "buy",
                      "price": "45.50000000",
                      "quantity": 100,
                      "filled_quantity": 0,
                      "filled_at": null,
                      "average_price": "45.50000000",
                      "fee": "1137.50000000000",
                      "status": "active",
                      "closure_reason": null,
                      "time_in_force": "gtc",
                      "stop_price": null,
                      "client_order_id": "my-order-123",
                      "triggered_by_auto_top_up": false,
                      "submitted_at": "2025-12-23T15:15:16Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/RateLimitExceeded"
          }
        }
      },
      "post": {
        "tags": [
          "Trading: Orders"
        ],
        "summary": "Place order",
        "description": "Create a new order using Ed25519 signature authentication.",
        "operationId": "tradingCreateOrder",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X POST 'https://trading.api.thegrid.ai/v1/orders' \\\n  -H 'Content-Type: application/json' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT' \\\n  -d '{\n    \"market_id\": \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\",\n    \"side\": \"buy\",\n    \"type\": \"limit\",\n    \"quantity\": 1,\n    \"price\": \"1.19\"\n  }'"
          },
          {
            "lang": "Python",
            "source": "import json\nimport requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/orders'\norder_params = {\n    'market_id': 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0',\n    'side': 'buy',\n    'type': 'limit',\n    'quantity': 1,\n    'price': '1.19'\n}\nbody = json.dumps(order_params)\nheaders = auth.get_headers('POST', path, body)\nresponse = requests.post(\n    f'https://trading.api.thegrid.ai{path}',\n    json=order_params,\n    headers={\n        'Content-Type': 'application/json',\n        **headers\n    }\n)\ndata = response.json()['data']  # { order_id }\norder_id = data['order_id']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/orders';\nconst orderParams = {\n  market_id: 'market_b310e860-97cd-45eb-bdc3-5be0b79295d0',\n  side: 'buy',\n  type: 'limit',\n  quantity: 1,\n  price: '1.19'\n};\nconst body = JSON.stringify(orderParams);\nconst headers = auth.getHeaders('POST', path, body);\nconst response = await axios.post(\n  `https://trading.api.thegrid.ai${path}`,\n  orderParams,\n  {\n    headers: {\n      'Content-Type': 'application/json',\n      ...headers\n    }\n  }\n);\nconst data = response.data.data;  // { order_id }\nconst orderId = data.order_id;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/orders\"\norderParams := map[string]interface{}{\n\t\"market_id\": \"market_b310e860-97cd-45eb-bdc3-5be0b79295d0\",\n\t\"side\":      \"buy\",\n\t\"type\":      \"limit\",\n\t\"quantity\":  1,\n\t\"price\":     \"1.19\",\n}\nbodyBytes, _ := json.Marshal(orderParams)\nbodyStr := string(bodyBytes)\nheaders, _ := auth.GetHeaders(\"POST\", path, bodyStr)\nreq, _ := http.NewRequest(\"POST\", baseURL+path, bytes.NewBuffer(bodyBytes))\nreq.Header.Set(\"Content-Type\", \"application/json\")\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData struct {\n\t\tOrderID       string `json:\"order_id\"`\n\t} `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TradingCreateOrderRequest"
              },
              "example": {
                "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                "side": "buy",
                "type": "limit",
                "quantity": 1,
                "price": "1.19"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Order created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "order_id": {
                          "type": "string",
                          "example": "order_TT64AI5BZNLKUFTL"
                        },
                        "client_order_id": {
                          "type": "string",
                          "example": "my-order-123",
                          "nullable": true
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid order parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradingErrorResponse"
                },
                "example": {
                  "data": null,
                  "error": "Validation failed",
                  "errors": {
                    "detail": "invalid_order_params"
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/orders/{order_id}": {
      "delete": {
        "tags": [
          "Trading: Orders"
        ],
        "summary": "Cancel order",
        "description": "Cancel an order using Ed25519 signature authentication.",
        "operationId": "tradingCancelOrder",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X DELETE 'https://trading.api.thegrid.ai/v1/orders/order_ZVFOAGG4JWRNXMCK' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\norder_id = 'order_ZVFOAGG4JWRNXMCK'\npath = f'/v1/orders/{order_id}'\nheaders = auth.get_headers('DELETE', path, '')\nresponse = requests.delete(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst orderId = 'order_ZVFOAGG4JWRNXMCK';\nconst path = `/v1/orders/${orderId}`;\nconst headers = auth.getHeaders('DELETE', path, '');\nconst response = await axios.delete(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"fmt\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\norderID := \"order_ZVFOAGG4JWRNXMCK\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/orders/%s\", orderID)\nheaders, _ := auth.GetHeaders(\"DELETE\", path, \"\")\nreq, _ := http.NewRequest(\"DELETE\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the order (e.g., \"order_TT64AI5BZNLKUFTL\")"
          }
        ],
        "responses": {
          "204": {
            "description": "Order cancelled successfully"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "409": {
            "description": "Order already cancelled",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradingErrorResponse"
                },
                "example": {
                  "errors": {
                    "detail": "order_already_cancelled"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "tags": [
          "Trading: Orders"
        ],
        "summary": "Get order details",
        "description": "Returns details of a specific order.",
        "operationId": "tradingGetOrder",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/orders/order_ZVFOAGG4JWRNXMCK' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\norder_id = 'order_ZVFOAGG4JWRNXMCK'\npath = f'/v1/orders/{order_id}'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\norder = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst orderId = 'order_ZVFOAGG4JWRNXMCK';\nconst path = `/v1/orders/${orderId}`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst order = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\norderID := \"order_ZVFOAGG4JWRNXMCK\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/orders/%s\", orderID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData Order `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "order_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the order (e.g., \"order_TT64AI5BZNLKUFTL\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Order details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/Order"
                    }
                  }
                },
                "example": {
                  "data": {
                    "order_id": "order_ZVFOAGG4JWRNXMCK",
                    "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                    "market_name": "Text Prime",
                    "instrument_id": "instrument_c18a986c-522b-475a-b319-f2d0ba04a64d",
                    "instrument_name": "Text Prime",
                    "instrument_symbol": "text-prime",
                    "trader_id": "user_0e393ba0-84a3-49e2-9795-59174ddb29a4",
                    "type": "limit",
                    "side": "buy",
                    "price": "45.50000000",
                    "quantity": 1000,
                    "filled_quantity": 0,
                    "filled_at": null,
                    "average_price": "45.50000000",
                    "fee": "1137.50000000000",
                    "status": "active",
                    "closure_reason": null,
                    "time_in_force": "gtc",
                    "stop_price": null,
                    "client_order_id": null,
                    "triggered_by_auto_top_up": false,
                    "submitted_at": "2025-12-23T15:15:16Z"
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/trades": {
      "get": {
        "tags": [
          "Trading: Trades"
        ],
        "summary": "Get user's trade history",
        "description": "Get your trade history (fills). Results are always the authenticated user's trades.\nUse the `order_id` filter to limit results to trades for a specific order (the user's order\nassociated with each trade, as returned in the response `order_id` field).",
        "operationId": "tradingListTrades",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/trades' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/trades'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\ntrades = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/trades';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst trades = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/trades\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []Trade `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by market ID"
          },
          {
            "name": "instrument_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by instrument ID"
          },
          {
            "name": "trade_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by trade ID"
          },
          {
            "name": "order_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by the user's order ID associated with the trade (canonical filter for \"my\" trades).\nMatches the `order_id` field returned on each trade."
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by trade status"
          },
          {
            "name": "buyer_order_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by buyer's order ID (legacy; prefer `order_id` for user's trades)"
          },
          {
            "name": "seller_order_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by seller's order ID (legacy; prefer `order_id` for user's trades)"
          },
          {
            "name": "triggering_order_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by the order that triggered the trade (legacy; prefer `order_id` for user's trades)"
          },
          {
            "name": "start_datetime",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter trades executed at or after this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "end_datetime",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter trades executed at or before this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "execution_timestamp",
                "trade_id",
                "price",
                "quantity",
                "total_value"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "List of trades",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TradeListResponse"
                },
                "example": {
                  "data": [
                    {
                      "trade_id": "trade_d7b40819-0ea6-428b-b00c-deb559206cb7",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_name": "Text Prime",
                      "instrument_id": "instrument_c18a986c-522b-475a-b319-f2d0ba04a64d",
                      "instrument_name": "Text Prime",
                      "instrument_symbol": "text-prime",
                      "order_id": "order_ZVFOAGG4JWRNXMCK",
                      "trading_account_id": "trading_account_6e6ad9d28eaae559",
                      "price": "99.99000000",
                      "quantity": 500,
                      "side": "buy",
                      "total_value": "45500.00000000",
                      "fee": "0.025",
                      "status": "executed",
                      "execution_timestamp": "2025-12-05T17:29:29.887434Z",
                      "settlement_timestamp": "2025-12-05T17:29:29.887436Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/trades/{trade_id}": {
      "get": {
        "tags": [
          "Trading: Trades"
        ],
        "summary": "Get single trade",
        "description": "Returns a single trade with metadata.",
        "operationId": "tradingGetTrade",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/trades/trade_d7b40819-0ea6-428b-b00c-deb559206cb7' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\ntrade_id = 'trade_d7b40819-0ea6-428b-b00c-deb559206cb7'\npath = f'/v1/trades/{trade_id}'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\ntrade = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst tradeId = 'trade_d7b40819-0ea6-428b-b00c-deb559206cb7';\nconst path = `/v1/trades/${tradeId}`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst trade = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\ntradeID := \"trade_d7b40819-0ea6-428b-b00c-deb559206cb7\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/trades/%s\", tradeID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData Trade `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "trade_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the trade (e.g., \"trade_d7b40819-0ea6-428b-b00c-deb559206cb7\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Trade details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/UserTrade"
                    }
                  }
                },
                "example": {
                  "data": {
                    "trade_id": "trade_d7b40819-0ea6-428b-b00c-deb559206cb7",
                    "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                    "market_name": "Text Prime",
                    "instrument_id": "instrument_c18a986c-522b-475a-b319-f2d0ba04a64d",
                    "instrument_name": "Text Prime",
                    "instrument_symbol": "text-prime",
                    "order_id": "order_ZVFOAGG4JWRNXMCK",
                    "trading_account_id": "trading_account_6e6ad9d28eaae559",
                    "price": "99.99000000",
                    "quantity": 500,
                    "side": "buy",
                    "total_value": "45500.00000000",
                    "fee": "0.025",
                    "status": "executed",
                    "execution_timestamp": "2025-12-05T17:29:29.887434Z",
                    "settlement_timestamp": "2025-12-05T17:29:29.887436Z"
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/trading-accounts": {
      "get": {
        "tags": [
          "Trading: Accounts"
        ],
        "summary": "List trading account balances",
        "description": "List all trading account balances across instruments.",
        "operationId": "tradingListTradingAccounts",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/trading-accounts' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/trading-accounts'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\nbalances = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/trading-accounts';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst balances = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/trading-accounts\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []TradingAccount `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by account ID"
          },
          {
            "name": "market_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by market ID"
          },
          {
            "name": "instrument_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by instrument ID"
          },
          {
            "name": "status",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "active",
                "inactive"
              ]
            },
            "description": "Filter by account status"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "account_id",
                "total_balance",
                "available_balance",
                "status",
                "created_at",
                "updated_at"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "List of trading accounts",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/TradingAccount"
                      }
                    },
                    "paging": {
                      "$ref": "#/components/schemas/CursorPaging"
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "account_id": "trading_account_6e6ad9d28eaae559",
                      "user_id": "user_7225b557-5e6d-4faa-a0d7-4ca6fe261165",
                      "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                      "instrument_name": "Text Prime",
                      "instrument_symbol": "text-prime",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "market_name": "Text Prime",
                      "total_balance": "150",
                      "available_balance": "100",
                      "locked_balance": "50",
                      "last_trade_price": "45.50",
                      "status": "active",
                      "last_deposit_at": null,
                      "last_trading_activity_at": null,
                      "last_withdrawal_at": null,
                      "created_at": "2025-12-02T11:51:37Z",
                      "updated_at": "2025-12-02T11:51:37Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/trading-accounts/{account_id}": {
      "get": {
        "tags": [
          "Trading: Accounts"
        ],
        "summary": "Get trading account details",
        "description": "Get detailed information about a specific trading account.",
        "operationId": "tradingGetTradingAccount",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/trading-accounts/trading_account_6e6ad9d28eaae559' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\naccount_id = 'trading_account_6e6ad9d28eaae559'\npath = f'/v1/trading-accounts/{account_id}'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\naccount = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst accountId = 'trading_account_6e6ad9d28eaae559';\nconst path = `/v1/trading-accounts/${accountId}`;\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst account = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\naccountID := \"trading_account_6e6ad9d28eaae559\"\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := fmt.Sprintf(\"/v1/trading-accounts/%s\", accountID)\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData TradingAccount `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "account_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Unique identifier for the trading account (e.g., \"trading_account_6e6ad9d28eaae559\")"
          }
        ],
        "responses": {
          "200": {
            "description": "Trading account details",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "$ref": "#/components/schemas/TradingAccount"
                    }
                  }
                },
                "example": {
                  "data": {
                    "account_id": "trading_account_6e6ad9d28eaae559",
                    "user_id": "user_2e73aeab-3f3e-401f-9976-c78b9d326961",
                    "instrument_id": "instrument_c18a986c-522b-475a-b319-f2d0ba04a64d",
                    "instrument_name": "Text Prime",
                    "instrument_symbol": "text-prime",
                    "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                    "market_name": "Text Prime",
                    "total_balance": "250",
                    "available_balance": "200",
                    "locked_balance": "50",
                    "last_trade_price": "45.50",
                    "status": "active",
                    "last_deposit_at": null,
                    "last_trading_activity_at": null,
                    "last_withdrawal_at": null,
                    "created_at": "2025-12-02T11:51:37Z",
                    "updated_at": "2025-12-02T11:51:37Z"
                  }
                }
              }
            }
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/transfers/trading-to-consumption": {
      "post": {
        "tags": [
          "Trading: Transfers"
        ],
        "summary": "Transfer to consumption",
        "description": "Transfers a specified quantity of an instrument from trading account to consumption account.",
        "operationId": "transferToConsumption",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X POST 'https://trading.api.thegrid.ai/v1/transfers/trading-to-consumption' \\\n  -H 'Content-Type: application/json' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT' \\\n  -d '{\n    \"instrument_id\": \"instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0\",\n    \"quantity\": 100\n  }'"
          },
          {
            "lang": "Python",
            "source": "import json\nimport requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/transfers/trading-to-consumption'\npayload = {'instrument_id': 'instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0', 'quantity': 100}\nbody = json.dumps(payload)\nheaders = auth.get_headers('POST', path, body)\nresponse = requests.post(\n    f'https://trading.api.thegrid.ai{path}',\n    json=payload,\n    headers={\n        'Content-Type': 'application/json',\n        **headers\n    }\n)\ntransfer = response.json()"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/transfers/trading-to-consumption';\nconst payload = { instrument_id: 'instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0', quantity: 100 };\nconst body = JSON.stringify(payload);\nconst headers = auth.getHeaders('POST', path, body);\nconst response = await axios.post(\n  `https://trading.api.thegrid.ai${path}`,\n  payload,\n  {\n    headers: {\n      'Content-Type': 'application/json',\n      ...headers\n    }\n  }\n);\nconst transfer = response.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/transfers/trading-to-consumption\"\npayload := map[string]interface{}{\n\t\"instrument_id\": \"instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0\",\n\t\"quantity\":      100,\n}\nbodyBytes, _ := json.Marshal(payload)\nbodyStr := string(bodyBytes)\nheaders, _ := auth.GetHeaders(\"POST\", path, bodyStr)\nreq, _ := http.NewRequest(\"POST\", baseURL+path, bytes.NewBuffer(bodyBytes))\nreq.Header.Set(\"Content-Type\", \"application/json\")\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tTransferID string `json:\"transfer_id\"`\n\tStatus     string `json:\"status\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferRequest"
              },
              "example": {
                "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                "quantity": 100
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Transfer initiated (processed asynchronously)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferResponse"
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/transfer-histories": {
      "get": {
        "tags": [
          "Trading: Transfers"
        ],
        "summary": "List transfer history",
        "description": "Returns transfer histories for authenticated user.",
        "operationId": "listTransferHistory",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/transfer-histories' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/transfer-histories'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\nhistory = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/transfer-histories';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst history = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/transfer-histories\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []TransferHistory `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by market ID"
          },
          {
            "name": "instrument_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by instrument ID"
          },
          {
            "name": "start_datetime",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter transfers at or after this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "end_datetime",
            "in": "query",
            "schema": {
              "type": "string",
              "format": "date-time"
            },
            "description": "Filter transfers at or before this time (ISO8601 or Unix timestamp)"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "transferred_at",
                "quantity"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "Transfer history",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TransferHistoryResponse"
                },
                "example": {
                  "data": [
                    {
                      "transfer_id": "transfer_3f0f4bda-def0-4db9-bd64-a6a37d39535e",
                      "account_id": "consumption_account_cbf73393ef9e2ed0",
                      "sender_account_id": "trading_account_6e6ad9d28eaae559",
                      "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                      "instrument_name": "Text Prime",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "quantity": 200,
                      "transferred_at": "2026-01-09T17:32:59Z",
                      "inserted_at": "2026-01-09T17:32:59Z",
                      "updated_at": "2026-01-09T17:32:59Z"
                    },
                    {
                      "transfer_id": "transfer_3f0f4bda-def0-4db9-bd64-a6a37d39535e",
                      "account_id": "consumption_account_2e3ed8507574eec9",
                      "sender_account_id": "trading_account_6e6ad9d28eaae559",
                      "instrument_id": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0",
                      "instrument_name": "Text Prime",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "quantity": 100,
                      "transferred_at": "2026-01-09T17:31:59Z",
                      "inserted_at": "2026-01-09T17:32:59Z",
                      "updated_at": "2026-01-09T17:32:59Z"
                    }
                  ],
                  "paging": {
                    "has_more": false,
                    "next_cursor": null,
                    "prev_cursor": null
                  }
                }
              }
            }
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/price-histories": {
      "get": {
        "tags": [
          "Trading: Markets"
        ],
        "summary": "Get price history (OHLCV)",
        "description": "Returns OHLCV (Open, High, Low, Close, Volume) candle data for charting. \nUse this endpoint to build price charts and analyze historical market data.",
        "operationId": "tradingGetPriceHistories",
        "x-hideTryItPanel": true,
        "x-codeSamples": [
          {
            "lang": "bash",
            "label": "cURL",
            "source": "curl -X GET 'https://trading.api.thegrid.ai/v1/price-histories' \\\n  -H 'x-thegrid-signature: YOUR_SIGNATURE' \\\n  -H 'x-thegrid-timestamp: YOUR_TIMESTAMP' \\\n  -H 'x-thegrid-fingerprint: YOUR_FINGERPRINT'"
          },
          {
            "lang": "Python",
            "source": "import requests\n\nauth = SignatureAuth(private_key, public_key)  # See auth docs for setup\npath = '/v1/price-histories'\nheaders = auth.get_headers('GET', path, '')\nresponse = requests.get(\n    f'https://trading.api.thegrid.ai{path}',\n    headers=headers\n)\ncandles = response.json()['data']"
          },
          {
            "lang": "JavaScript",
            "source": "import axios from 'axios';\n\nconst auth = new SignatureAuth(privateKey, publicKey);  // See auth docs for setup\nconst path = '/v1/price-histories';\nconst headers = auth.getHeaders('GET', path, '');\nconst response = await axios.get(\n  `https://trading.api.thegrid.ai${path}`,\n  { headers }\n);\nconst candles = response.data.data;"
          },
          {
            "lang": "Go",
            "source": "import (\n\t\"encoding/json\"\n\t\"io\"\n\t\"net/http\"\n\t\"time\"\n)\n\nauth, _ := NewSignatureAuth(privateKey, publicKey)  // See auth docs for setup\nconst baseURL = \"https://trading.api.thegrid.ai\"\npath := \"/v1/price-histories\"\nheaders, _ := auth.GetHeaders(\"GET\", path, \"\")\nreq, _ := http.NewRequest(\"GET\", baseURL+path, nil)\nfor k, v := range headers {\n\treq.Header.Set(k, v)\n}\nclient := &http.Client{Timeout: 10 * time.Second}\nresp, _ := client.Do(req)\ndefer resp.Body.Close()\nbody, _ := io.ReadAll(resp.Body)\nvar result struct {\n\tData []PriceHistory `json:\"data\"`\n}\njson.Unmarshal(body, &result)"
          }
        ],
        "security": [
          {
            "signatureAuth": []
          }
        ],
        "parameters": [
          {
            "name": "market_id",
            "in": "query",
            "schema": {
              "type": "string"
            },
            "description": "Filter by market ID"
          },
          {
            "name": "resolution",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "1m",
                "5m",
                "15m",
                "30m",
                "1h",
                "4h",
                "1d",
                "1w",
                "1M"
              ]
            },
            "description": "Candle resolution/timeframe. Determines the time period each candle represents."
          },
          {
            "name": "from",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "Start of time range (Unix timestamp in seconds)"
          },
          {
            "name": "to",
            "in": "query",
            "schema": {
              "type": "integer"
            },
            "description": "End of time range (Unix timestamp in seconds)"
          },
          {
            "name": "order_by",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "period_start"
              ]
            },
            "description": "Field to sort by"
          },
          {
            "name": "order_direction",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "asc",
                "desc"
              ],
              "default": "asc"
            },
            "description": "Sort direction"
          },
          {
            "$ref": "#/components/parameters/next"
          },
          {
            "$ref": "#/components/parameters/prev"
          },
          {
            "$ref": "#/components/parameters/limit"
          }
        ],
        "responses": {
          "200": {
            "description": "OHLCV candle data",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PriceHistoryResponse"
                },
                "example": {
                  "data": [
                    {
                      "time": "2026-02-12T07:00:00Z",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "resolution": "1h",
                      "open": "45.00",
                      "high": "45.75",
                      "low": "44.80",
                      "close": "45.50",
                      "volume": 1200,
                      "trade_count": 48
                    },
                    {
                      "time": "2026-02-12T08:00:00Z",
                      "market_id": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0",
                      "resolution": "1h",
                      "open": "45.50",
                      "high": "46.25",
                      "low": "45.25",
                      "close": "46.00",
                      "volume": 1500,
                      "trade_count": 62
                    }
                  ],
                  "paging": {
                    "has_more": true,
                    "next_cursor": "eyJpZCI6InByaWNlXzEyMyJ9",
                    "prev_cursor": null
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      },
      "servers": [
        {
          "url": "https://trading.api.thegrid.ai/v1",
          "description": "Trading API -- order book, accounts, market data (Ed25519 auth)"
        }
      ]
    },
    "/oauth/device/code": {
      "servers": [
        {
          "url": "https://platform.api.thegrid.ai/v1",
          "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
        }
      ],
      "post": {
        "tags": [
          "Platform: OAuth"
        ],
        "summary": "Request a device code",
        "operationId": "oauthDeviceCode",
        "description": "Start the OAuth 2.0 device authorization grant ([RFC 8628](https://www.rfc-editor.org/rfc/rfc8628)). Returns a `user_code` for a person to approve at `verification_uri`, and a `device_code` to poll `POST /oauth/token` with. Accepts JSON or `application/x-www-form-urlencoded`. No authentication: public clients such as `grid-cli-public` have no secret.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "client_id"
                ],
                "properties": {
                  "client_id": {
                    "type": "string",
                    "description": "OAuth client id. Use `grid-cli-public` for CLI and personal agent flows.",
                    "example": "grid-cli-public"
                  },
                  "scope": {
                    "type": "string",
                    "description": "Space-separated scopes. Request the narrowest set the integration needs.",
                    "example": "account:read keys:manage"
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "client_id"
                ],
                "properties": {
                  "client_id": {
                    "type": "string",
                    "example": "grid-cli-public"
                  },
                  "scope": {
                    "type": "string",
                    "example": "account:read keys:manage"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Device authorization started.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "device_code": {
                      "type": "string",
                      "description": "Poll POST /oauth/token with this value."
                    },
                    "user_code": {
                      "type": "string",
                      "description": "Code the person enters at verification_uri."
                    },
                    "verification_uri": {
                      "type": "string",
                      "format": "uri"
                    },
                    "expires_in": {
                      "type": "integer",
                      "description": "Seconds until the device code expires."
                    },
                    "interval": {
                      "type": "integer",
                      "description": "Minimum seconds between polls of the token endpoint."
                    }
                  }
                },
                "example": {
                  "device_code": "3pjJoMUBEaq2lQPlO7cqqShGXCwLFT3uzOVvO_-W76w",
                  "user_code": "9C79-6JFR",
                  "verification_uri": "https://app.thegrid.ai/activate",
                  "expires_in": 899,
                  "interval": 5
                }
              }
            }
          },
          "400": {
            "description": "Invalid client or scope.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "RFC 6749 / RFC 8628 error code."
                    },
                    "error_description": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "error": "invalid_request"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/token": {
      "servers": [
        {
          "url": "https://platform.api.thegrid.ai/v1",
          "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
        }
      ],
      "post": {
        "tags": [
          "Platform: OAuth"
        ],
        "summary": "Exchange a device code or refresh token for an access token",
        "operationId": "oauthToken",
        "description": "Poll with `grant_type=urn:ietf:params:oauth:grant-type:device_code` until the person approves the grant, then keep the access token fresh with `grant_type=refresh_token`. Access tokens are prefixed `grid_at_` and last about an hour; refresh tokens are prefixed `grid_rt_`. While the grant is still pending the endpoint answers `400` with `error: authorization_pending`; respect the `interval` from the device code response.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type",
                  "client_id"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": [
                      "urn:ietf:params:oauth:grant-type:device_code",
                      "refresh_token"
                    ]
                  },
                  "client_id": {
                    "type": "string",
                    "example": "grid-cli-public"
                  },
                  "device_code": {
                    "type": "string",
                    "description": "Required for the device_code grant."
                  },
                  "refresh_token": {
                    "type": "string",
                    "description": "Required for the refresh_token grant."
                  }
                }
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type",
                  "client_id"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "device_code": {
                    "type": "string"
                  },
                  "refresh_token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token issued.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string",
                      "description": "Bearer token for the Platform API. Prefixed `grid_at_`."
                    },
                    "refresh_token": {
                      "type": "string",
                      "description": "Prefixed `grid_rt_`."
                    },
                    "token_type": {
                      "type": "string",
                      "example": "Bearer"
                    },
                    "expires_in": {
                      "type": "integer",
                      "description": "Seconds until the access token expires."
                    },
                    "scope": {
                      "type": "string",
                      "description": "Space-separated scopes actually granted."
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Grant not ready, expired, denied, or malformed. `authorization_pending` means keep polling.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "string",
                      "description": "RFC 6749 / RFC 8628 error code."
                    },
                    "error_description": {
                      "type": "string"
                    }
                  }
                },
                "example": {
                  "error": "authorization_pending"
                }
              }
            }
          }
        }
      }
    },
    "/oauth/revoke": {
      "servers": [
        {
          "url": "https://platform.api.thegrid.ai/v1",
          "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
        }
      ],
      "post": {
        "tags": [
          "Platform: OAuth"
        ],
        "summary": "Revoke an access or refresh token",
        "operationId": "oauthRevoke",
        "description": "Token revocation ([RFC 7009](https://www.rfc-editor.org/rfc/rfc7009)). Accepts either an access token (`grid_at_*`) or a refresh token (`grid_rt_*`). `token_type_hint` is accepted but not required, and `client_id` is not required. Per the RFC the endpoint always answers `200` with an empty object, including for unknown or already-revoked tokens, so a `200` is not proof the token existed.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "token"
                ],
                "properties": {
                  "token": {
                    "type": "string"
                  },
                  "token_type_hint": {
                    "type": "string",
                    "enum": [
                      "access_token",
                      "refresh_token"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Revocation accepted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                },
                "example": {}
              }
            }
          }
        }
      }
    },
    "/oauth/scopes": {
      "servers": [
        {
          "url": "https://platform.api.thegrid.ai/v1",
          "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
        }
      ],
      "get": {
        "tags": [
          "Platform: OAuth"
        ],
        "summary": "List the OAuth scopes a client may request",
        "operationId": "oauthScopes",
        "description": "The machine-readable permission catalog. Call it with no parameters for every scope The Grid defines, or with `client_id` for the subset that client is allowed to request. Use it to build a least-privilege scope string instead of asking for everything.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [],
        "parameters": [
          {
            "name": "client_id",
            "in": "query",
            "required": false,
            "description": "Restrict the result to the scopes this OAuth client may request.",
            "schema": {
              "type": "string",
              "example": "grid-cli-public"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Scope catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "description": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                },
                "example": {
                  "data": [
                    {
                      "name": "account:read",
                      "description": "Read account profile, balances, and related account data."
                    },
                    {
                      "name": "account:write",
                      "description": "Update account settings and perform account mutations."
                    },
                    {
                      "name": "trade:read",
                      "description": "Read orders, trades, positions, and trading history."
                    },
                    {
                      "name": "trade:write",
                      "description": "Place, amend, and cancel orders and perform trading mutations."
                    },
                    {
                      "name": "supply:read",
                      "description": "Read supply issuance, balances, and supply account data."
                    },
                    {
                      "name": "supply:write",
                      "description": "Issue supply, transfer supply, and perform supply mutations."
                    },
                    {
                      "name": "keys:manage",
                      "description": "Create, list, and revoke consumption API keys and trading signing keys via the Exchange API."
                    }
                  ]
                }
              }
            }
          }
        }
      }
    },
    "/api-keys": {
      "servers": [
        {
          "url": "https://platform.api.thegrid.ai/v1",
          "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
        }
      ],
      "get": {
        "tags": [
          "Platform: Credentials"
        ],
        "summary": "List consumption API keys",
        "operationId": "listApiKeys",
        "description": "Lists the consumption API keys on the account. Secrets are never returned here: each entry carries `key: null` and only a `key_prefix`. There is no read-only key scope, so listing requires `keys:manage`.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [
          {
            "oauth2": [
              "keys:manage"
            ]
          }
        ],
        "responses": {
          "401": {
            "description": "Missing, expired, or revoked access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The access token does not carry the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "2XX": {
            "description": "Key list. Secrets are redacted.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "description": "See the Platform API reference for the full shape."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Platform: Credentials"
        ],
        "summary": "Create a consumption API key",
        "operationId": "createApiKey",
        "description": "Mints a consumption API key for the Consumption API. The raw secret is returned once, in `data.key`; afterwards list and show return `key: null`. This is the endpoint that lets an agent finish onboarding without a human visiting the dashboard.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [
          {
            "oauth2": [
              "keys:manage"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "api_key": {
                    "type": "object",
                    "properties": {
                      "name": {
                        "type": "string",
                        "description": "Label shown in the dashboard."
                      }
                    }
                  }
                }
              },
              "example": {
                "api_key": {
                  "name": "my-agent"
                }
              }
            }
          }
        },
        "responses": {
          "401": {
            "description": "Missing, expired, or revoked access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The access token does not carry the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "2XX": {
            "description": "Key created. `data.key` holds the secret and is shown only in this response.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "description": "See the Platform API reference for the full shape."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/signing-keys": {
      "servers": [
        {
          "url": "https://platform.api.thegrid.ai/v1",
          "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
        }
      ],
      "get": {
        "tags": [
          "Platform: Credentials"
        ],
        "summary": "List trading signing keys",
        "operationId": "listSigningKeys",
        "description": "Lists the registered Ed25519 public keys used to sign Trading API requests.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [
          {
            "oauth2": [
              "keys:manage"
            ]
          }
        ],
        "responses": {
          "401": {
            "description": "Missing, expired, or revoked access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The access token does not carry the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "2XX": {
            "description": "Registered signing keys.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "description": "See the Platform API reference for the full shape."
                    }
                  }
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Platform: Credentials"
        ],
        "summary": "Register a trading signing key",
        "operationId": "createSigningKey",
        "description": "Registers an Ed25519 public key for Trading API request signing. Generate the keypair locally; the private key never leaves your machine. See the authentication docs for the signing scheme.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [
          {
            "oauth2": [
              "keys:manage"
            ]
          }
        ],
        "responses": {
          "401": {
            "description": "Missing, expired, or revoked access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The access token does not carry the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "2XX": {
            "description": "Signing key registered.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "description": "See the Platform API reference for the full shape."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/self/system-settings": {
      "servers": [
        {
          "url": "https://platform.api.thegrid.ai/v1",
          "description": "Platform API -- OAuth login, API key creation, signing keys, account settings"
        }
      ],
      "get": {
        "tags": [
          "Platform: Credentials"
        ],
        "summary": "Read account mode and funding settings",
        "operationId": "getSystemSettings",
        "description": "Returns the account mode (Auto or Advanced) and the funding automation settings. Fields listed in `mode_managed_fields` are dictated by the account mode and are read-only; change the account mode instead. Reads need `account:read`; the corresponding mutations need `account:write`.",
        "externalDocs": {
          "description": "Platform API reference",
          "url": "https://thegrid.ai/docs/api-reference/platform-api"
        },
        "security": [
          {
            "oauth2": [
              "account:read"
            ]
          }
        ],
        "responses": {
          "401": {
            "description": "Missing, expired, or revoked access token.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "403": {
            "description": "The access token does not carry the required scope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "2XX": {
            "description": "Current account settings.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "description": "See the Platform API reference for the full shape."
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/responses": {
      "post": {
        "description": "Performs a pre-flight balance check for an OpenAI Responses request and issues a 307 redirect to LLM Gateway.",
        "operationId": "createResponse",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/OpenAIResponsesRequest"
              }
            }
          },
          "description": "OpenAIResponsesRequest",
          "required": false
        },
        "responses": {
          "307": {
            "content": {
              "text/plain": {}
            },
            "description": "Temporary Redirect"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          }
        },
        "summary": "Routes OpenAI Responses API requests",
        "tags": [
          "Consumption: Responses"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/messages": {
      "post": {
        "description": "Performs a pre-flight balance check for an Anthropic Messages request and issues a 307 redirect to LLM Gateway.",
        "operationId": "createAnthropicMessage",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicMessagesRequest"
              }
            }
          },
          "description": "AnthropicMessagesRequest",
          "required": false
        },
        "responses": {
          "307": {
            "content": {
              "text/plain": {}
            },
            "description": "Temporary Redirect"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "422": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "429": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          },
          "500": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          }
        },
        "summary": "Routes Anthropic Messages API requests",
        "tags": [
          "Consumption: Messages"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/usage": {
      "get": {
        "description": "Lists the caller's inference requests with cursor pagination following the Trading API conventions: `next`/`prev` opaque cursors, `order_by`/`order_direction` (fields: inserted_at, total_tokens; default inserted_at desc), `limit` up to 100. Entries use the same shape as the single-receipt lookup, minus the per-lot cost breakdown (fetch `GET /v1/usage/:request_id` for the audit trail). Settled cost lands asynchronously at reconciliation, so very recent requests may report `cost.status: \"pending\"`.",
        "operationId": "listUsage",
        "parameters": [
          {
            "description": "",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "status",
            "required": false,
            "schema": {
              "enum": [
                "pending",
                "reconciled",
                "error"
              ],
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "cost_status",
            "required": false,
            "schema": {
              "enum": [
                "pending",
                "reconciled",
                "unpriced",
                "cancelled"
              ],
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "model",
            "required": false,
            "schema": {
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "api_key_id",
            "required": false,
            "schema": {
              "format": "uuid",
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "order_by",
            "required": false,
            "schema": {
              "enum": [
                "inserted_at",
                "total_tokens"
              ],
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "order_direction",
            "required": false,
            "schema": {
              "enum": [
                "asc",
                "desc"
              ],
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "limit",
            "required": false,
            "schema": {
              "default": 50,
              "maximum": 100,
              "minimum": 1,
              "type": "integer",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "next",
            "required": false,
            "schema": {
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "prev",
            "required": false,
            "schema": {
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageListResponse"
                }
              }
            },
            "description": "UsageListResponse"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          }
        },
        "summary": "List usage receipts (paginated)",
        "tags": [
          "Consumption: Usage"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/usage/summary": {
      "get": {
        "description": "Returns totals (request count, token sums, settled cost, per-cost-status counts) for the caller over a bounded time window, plus optional buckets via `group_by=day|model|api_key`. The window defaults to the last 30 days and may span at most 31 days (`window_too_large` otherwise); the applied `from`/`to` are echoed in the response. At most 100 buckets are returned (day buckets newest-first; model and API-key buckets most-used first). `cost.reconciled_amount` sums the priced portion of every request; consumption without a known cost basis is reported as `unpriced_tokens`, never a fabricated dollar amount. Very recent requests may still be settling (`pending_requests`).",
        "operationId": "getUsageSummary",
        "parameters": [
          {
            "description": "",
            "in": "query",
            "name": "from",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "to",
            "required": false,
            "schema": {
              "format": "date-time",
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "group_by",
            "required": false,
            "schema": {
              "enum": [
                "day",
                "model",
                "api_key"
              ],
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          },
          {
            "description": "",
            "in": "query",
            "name": "api_key_id",
            "required": false,
            "schema": {
              "format": "uuid",
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageSummaryResponse"
                }
              }
            },
            "description": "UsageSummaryResponse"
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          }
        },
        "summary": "Aggregated usage and spend",
        "tags": [
          "Consumption: Usage"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    },
    "/usage/{request_id}": {
      "get": {
        "description": "Returns tokens, model, timing, status, api key attribution and cost information for one request. The request id is issued on dispatch via the `x-grid-request-id` response header. Callers can only read their own requests. `cost.status` is `pending` while settlement is in flight, and `unpriced` when a settled request has no known cost basis.",
        "operationId": "getUsageRecord",
        "parameters": [
          {
            "description": "Server-issued request id",
            "in": "path",
            "name": "request_id",
            "required": true,
            "schema": {
              "format": "uuid",
              "type": "string",
              "x-struct": null,
              "x-validate": null
            }
          }
        ],
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageResponse"
                }
              }
            },
            "description": "UsageResponse"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConsumptionErrorResponse"
                }
              }
            },
            "description": "ErrorResponse"
          }
        },
        "summary": "Look up a single inference request (usage receipt)",
        "tags": [
          "Consumption: Usage"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Bearer token authentication using your API key.\n\nInclude your API key in the Authorization header:\n```\nAuthorization: Bearer YOUR_API_KEY\n```\n\nGenerate API keys from your [Grid Dashboard](https://app.thegrid.ai/profile/api-keys)."
      },
      "signatureAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-thegrid-signature",
        "description": "Ed25519 signature authentication. **All three headers are required** for every request:\n\n| Header | Description |\n|--------|-------------|\n| `x-thegrid-signature` | Base64-encoded Ed25519 signature of `{timestamp}{METHOD}{path}{body}`\n| `x-thegrid-timestamp` | Unix timestamp in seconds (must be within 30 seconds of server time) |\n| `x-thegrid-fingerprint` | SHA256 hash of your public key (Base64-encoded, padding stripped) |\n\n[See full authentication docs](./overview-trading-api/authentication)"
      },
      "oauth2": {
        "type": "oauth2",
        "description": "OAuth 2.0 access token for the Platform API, obtained with the device authorization grant ([RFC 8628](https://www.rfc-editor.org/rfc/rfc8628)).\n\nSend it as `Authorization: Bearer grid_at_...`. Access tokens last about an hour; refresh with `grant_type=refresh_token`. Revoke either token type at `POST /oauth/revoke` ([RFC 7009](https://www.rfc-editor.org/rfc/rfc7009)).\n\nScopes are named and least-privilege: request only the ones an integration needs. Each operation below lists the scope it requires. The live catalog of scopes a given client may request is `GET /oauth/scopes?client_id=...`.\n\nDiscovery: [authorization server metadata](https://thegrid.ai/.well-known/oauth-authorization-server) (RFC 8414) and [protected resource metadata](https://thegrid.ai/.well-known/oauth-protected-resource) (RFC 9728).\n\nThe Consumption API does **not** accept OAuth access tokens. Use one to mint a consumption API key at `POST /api-keys`, then send that key as the bearer token for inference.",
        "flows": {
          "x-deviceAuthorization": {
            "deviceAuthorizationUrl": "https://platform.api.thegrid.ai/v1/oauth/device/code",
            "tokenUrl": "https://platform.api.thegrid.ai/v1/oauth/token",
            "refreshUrl": "https://platform.api.thegrid.ai/v1/oauth/token",
            "scopes": {
              "account:read": "Read account profile, balances, and related account data.",
              "account:write": "Update account settings and perform account mutations.",
              "trade:read": "Read orders, trades, positions, and trading history.",
              "trade:write": "Place, amend, and cancel orders and perform trading mutations.",
              "supply:read": "Read supply issuance, balances, and supply account data.",
              "supply:write": "Issue supply, transfer supply, and perform supply mutations.",
              "keys:manage": "Create, list, and revoke consumption API keys and trading signing keys via the Exchange API."
            }
          }
        },
        "x-scopes": {
          "account:read": "Read account profile, balances, and related account data.",
          "account:write": "Update account settings and perform account mutations.",
          "trade:read": "Read orders, trades, positions, and trading history.",
          "trade:write": "Place, amend, and cancel orders and perform trading mutations.",
          "supply:read": "Read supply issuance, balances, and supply account data.",
          "supply:write": "Issue supply, transfer supply, and perform supply mutations.",
          "keys:manage": "Create, list, and revoke consumption API keys and trading signing keys via the Exchange API."
        },
        "x-oauth2MetadataUrl": "https://thegrid.ai/.well-known/oauth-authorization-server",
        "x-public-client-id": "grid-cli-public"
      }
    },
    "schemas": {
      "ChatCompletionsRequest": {
        "title": "ChatCompletionsRequest",
        "type": "object",
        "required": [
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "example": "text-prime"
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "oneOf": [
                {
                  "$ref": "#/components/schemas/ChatCompletionSystemMessageParam"
                },
                {
                  "$ref": "#/components/schemas/ChatCompletionDeveloperMessageParam"
                },
                {
                  "$ref": "#/components/schemas/ChatCompletionUserMessageParam"
                },
                {
                  "$ref": "#/components/schemas/ChatCompletionAssistantMessageParam"
                },
                {
                  "$ref": "#/components/schemas/ChatCompletionToolMessageParam"
                }
              ]
            }
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "nullable": true,
            "deprecated": true
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1,
            "nullable": true
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2,
            "default": 1,
            "nullable": true
          },
          "top_p": {
            "type": "number",
            "minimum": 0,
            "maximum": 1,
            "default": 1,
            "nullable": true
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 128,
            "default": 1,
            "nullable": true
          },
          "stream": {
            "type": "boolean",
            "default": false,
            "nullable": true
          },
          "stream_options": {
            "type": "object",
            "nullable": true,
            "properties": {
              "include_usage": {
                "type": "boolean"
              },
              "include_obfuscation": {
                "type": "boolean"
              }
            }
          },
          "stop": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "maxItems": 4
              }
            ]
          },
          "logprobs": {
            "type": "boolean",
            "default": false,
            "nullable": true
          },
          "top_logprobs": {
            "type": "integer",
            "minimum": 0,
            "maximum": 20,
            "nullable": true
          },
          "response_format": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/ResponseFormatText"
              },
              {
                "$ref": "#/components/schemas/ResponseFormatJSONObject"
              },
              {
                "$ref": "#/components/schemas/ResponseFormatJSONSchema"
              }
            ]
          },
          "tools": {
            "type": "array",
            "nullable": true,
            "items": {
              "$ref": "#/components/schemas/ChatCompletionTool"
            }
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "none",
                  "auto",
                  "required"
                ]
              },
              {
                "$ref": "#/components/schemas/ChatCompletionNamedToolChoice"
              }
            ]
          },
          "parallel_tool_calls": {
            "type": "boolean",
            "default": true
          },
          "frequency_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2,
            "default": 0,
            "nullable": true
          },
          "presence_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2,
            "default": 0,
            "nullable": true
          },
          "logit_bias": {
            "type": "object",
            "additionalProperties": {
              "type": "integer",
              "minimum": -100,
              "maximum": 100
            },
            "nullable": true
          },
          "seed": {
            "type": "integer",
            "nullable": true
          },
          "service_tier": {
            "type": "string",
            "enum": [
              "auto",
              "default",
              "flex",
              "scale",
              "priority"
            ],
            "nullable": true
          },
          "reasoning_effort": {
            "type": "string",
            "enum": [
              "none",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh"
            ],
            "nullable": true
          },
          "modalities": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "string",
              "enum": [
                "text",
                "audio"
              ]
            }
          },
          "audio": {
            "type": "object",
            "nullable": true,
            "properties": {
              "voice": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "string",
                    "enum": [
                      "alloy",
                      "ash",
                      "ballad",
                      "coral",
                      "echo",
                      "sage",
                      "shimmer",
                      "verse",
                      "marin",
                      "cedar"
                    ]
                  },
                  {
                    "type": "object",
                    "properties": {
                      "id": {
                        "type": "string"
                      }
                    }
                  }
                ]
              },
              "format": {
                "type": "string",
                "enum": [
                  "wav",
                  "aac",
                  "mp3",
                  "flac",
                  "opus",
                  "pcm16"
                ]
              }
            }
          },
          "prediction": {
            "type": "object",
            "nullable": true,
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "content"
                ]
              },
              "content": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "$ref": "#/components/schemas/ChatCompletionContentPartText"
                    }
                  }
                ]
              }
            }
          },
          "metadata": {
            "type": "object",
            "additionalProperties": {
              "type": "string",
              "maxLength": 512
            },
            "nullable": true
          },
          "store": {
            "type": "boolean",
            "nullable": true
          },
          "verbosity": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high"
            ],
            "nullable": true
          },
          "web_search_options": {
            "type": "object",
            "nullable": true,
            "properties": {
              "search_context_size": {
                "type": "string",
                "enum": [
                  "low",
                  "medium",
                  "high"
                ],
                "default": "medium"
              },
              "user_location": {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "approximate"
                    ]
                  },
                  "approximate": {
                    "type": "object",
                    "properties": {
                      "city": {
                        "type": "string"
                      },
                      "country": {
                        "type": "string"
                      },
                      "region": {
                        "type": "string"
                      },
                      "timezone": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "prompt_cache_key": {
            "type": "string",
            "nullable": true
          },
          "prompt_cache_retention": {
            "type": "string",
            "enum": [
              "in-memory",
              "24h"
            ],
            "nullable": true
          },
          "safety_identifier": {
            "type": "string",
            "nullable": true
          },
          "route": {
            "type": "string",
            "enum": [
              "fallback"
            ]
          },
          "provider": {
            "type": "object"
          },
          "user": {
            "type": "string",
            "deprecated": true
          }
        },
        "example": {
          "model": "text-prime",
          "messages": [
            {
              "role": "system",
              "content": "Be concise and to the point."
            },
            {
              "role": "user",
              "content": "Write one paragraph on why inference needs a market."
            }
          ],
          "max_completion_tokens": 500,
          "temperature": 0.7
        }
      },
      "ChatCompletionSystemMessageParam": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ChatCompletionContentPartText"
                }
              }
            ]
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ChatCompletionDeveloperMessageParam": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "developer"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ChatCompletionContentPartText"
                }
              }
            ]
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ChatCompletionUserMessageParam": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ChatCompletionContentPartText"
                    },
                    {
                      "$ref": "#/components/schemas/ChatCompletionContentPartImage"
                    },
                    {
                      "$ref": "#/components/schemas/ChatCompletionContentPartInputAudio"
                    }
                  ]
                }
              }
            ]
          },
          "name": {
            "type": "string"
          }
        }
      },
      "ChatCompletionAssistantMessageParam": {
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "assistant"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/ChatCompletionContentPartText"
                    },
                    {
                      "$ref": "#/components/schemas/ChatCompletionContentPartRefusal"
                    }
                  ]
                }
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatCompletionMessageToolCall"
            }
          },
          "audio": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string"
              }
            }
          }
        }
      },
      "ChatCompletionToolMessageParam": {
        "type": "object",
        "required": [
          "role",
          "content",
          "tool_call_id"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "tool"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ChatCompletionContentPartText"
                }
              }
            ]
          },
          "tool_call_id": {
            "type": "string"
          }
        }
      },
      "ChatCompletionContentPartText": {
        "type": "object",
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "text"
            ]
          },
          "text": {
            "type": "string"
          }
        }
      },
      "ChatCompletionContentPartImage": {
        "type": "object",
        "required": [
          "type",
          "image_url"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "image_url"
            ]
          },
          "image_url": {
            "type": "object",
            "required": [
              "url"
            ],
            "properties": {
              "url": {
                "type": "string"
              },
              "detail": {
                "type": "string",
                "enum": [
                  "auto",
                  "low",
                  "high"
                ],
                "default": "auto"
              }
            }
          }
        }
      },
      "ChatCompletionContentPartInputAudio": {
        "type": "object",
        "required": [
          "type",
          "input_audio"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "input_audio"
            ]
          },
          "input_audio": {
            "type": "object",
            "required": [
              "data",
              "format"
            ],
            "properties": {
              "data": {
                "type": "string"
              },
              "format": {
                "type": "string",
                "enum": [
                  "wav",
                  "mp3"
                ]
              }
            }
          }
        }
      },
      "ChatCompletionContentPartRefusal": {
        "type": "object",
        "required": [
          "type",
          "refusal"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "refusal"
            ]
          },
          "refusal": {
            "type": "string"
          }
        }
      },
      "ChatCompletionMessageToolCall": {
        "type": "object",
        "required": [
          "id",
          "type",
          "function"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "function"
            ]
          },
          "function": {
            "type": "object",
            "required": [
              "name",
              "arguments"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "arguments": {
                "type": "string"
              }
            }
          }
        }
      },
      "ChatCompletionTool": {
        "type": "object",
        "required": [
          "type",
          "function"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "function"
            ]
          },
          "function": {
            "$ref": "#/components/schemas/FunctionDefinition"
          }
        }
      },
      "FunctionDefinition": {
        "type": "object",
        "required": [
          "name"
        ],
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 64
          },
          "description": {
            "type": "string"
          },
          "parameters": {
            "type": "object"
          },
          "strict": {
            "type": "boolean",
            "nullable": true
          }
        }
      },
      "ChatCompletionNamedToolChoice": {
        "type": "object",
        "required": [
          "type",
          "function"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "function"
            ]
          },
          "function": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string"
              }
            }
          }
        }
      },
      "ResponseFormatText": {
        "type": "object",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "text"
            ]
          }
        }
      },
      "ResponseFormatJSONObject": {
        "type": "object",
        "required": [
          "type"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "json_object"
            ]
          }
        }
      },
      "ResponseFormatJSONSchema": {
        "type": "object",
        "required": [
          "type",
          "json_schema"
        ],
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "json_schema"
            ]
          },
          "json_schema": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string",
                "maxLength": 64
              },
              "description": {
                "type": "string"
              },
              "schema": {
                "type": "object"
              },
              "strict": {
                "type": "boolean",
                "nullable": true
              }
            }
          }
        }
      },
      "ChatCompletionResponse": {
        "title": "ChatCompletionResponse",
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "properties": {
          "id": {
            "type": "string",
            "example": "chatcmpl-abc123"
          },
          "object": {
            "type": "string",
            "enum": [
              "chat.completion"
            ]
          },
          "created": {
            "type": "integer",
            "example": 1677858242
          },
          "model": {
            "type": "string",
            "example": "text-prime"
          },
          "system_fingerprint": {
            "type": "string",
            "nullable": true
          },
          "service_tier": {
            "type": "string",
            "enum": [
              "auto",
              "default",
              "flex",
              "scale",
              "priority"
            ],
            "nullable": true
          },
          "choices": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatCompletionChoice"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/CompletionUsage"
          }
        },
        "example": {
          "id": "chatcmpl-abc123",
          "object": "chat.completion",
          "created": 1677858242,
          "model": "text-prime",
          "choices": [
            {
              "index": 0,
              "message": {
                "role": "assistant",
                "content": "The capital of France is Paris."
              },
              "finish_reason": "stop"
            }
          ],
          "usage": {
            "prompt_tokens": 25,
            "completion_tokens": 8,
            "total_tokens": 33
          }
        }
      },
      "ChatCompletionChoice": {
        "type": "object",
        "required": [
          "index",
          "message",
          "finish_reason"
        ],
        "properties": {
          "index": {
            "type": "integer"
          },
          "message": {
            "$ref": "#/components/schemas/ChatCompletionResponseMessage"
          },
          "logprobs": {
            "type": "object",
            "nullable": true,
            "properties": {
              "content": {
                "type": "array",
                "nullable": true,
                "items": {
                  "$ref": "#/components/schemas/ChatCompletionTokenLogprob"
                }
              },
              "refusal": {
                "type": "array",
                "nullable": true,
                "items": {
                  "$ref": "#/components/schemas/ChatCompletionTokenLogprob"
                }
              }
            }
          },
          "finish_reason": {
            "type": "string",
            "enum": [
              "stop",
              "length",
              "tool_calls",
              "content_filter",
              "function_call"
            ],
            "nullable": true
          }
        }
      },
      "ChatCompletionResponseMessage": {
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "assistant"
            ]
          },
          "content": {
            "type": "string",
            "nullable": true
          },
          "refusal": {
            "type": "string",
            "nullable": true
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatCompletionMessageToolCall"
            }
          },
          "audio": {
            "type": "object",
            "nullable": true,
            "properties": {
              "id": {
                "type": "string"
              },
              "expires_at": {
                "type": "integer"
              },
              "data": {
                "type": "string"
              },
              "transcript": {
                "type": "string"
              }
            }
          }
        }
      },
      "ChatCompletionTokenLogprob": {
        "type": "object",
        "required": [
          "token",
          "logprob",
          "bytes",
          "top_logprobs"
        ],
        "properties": {
          "token": {
            "type": "string"
          },
          "logprob": {
            "type": "number"
          },
          "bytes": {
            "type": "array",
            "nullable": true,
            "items": {
              "type": "integer"
            }
          },
          "top_logprobs": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "token",
                "logprob",
                "bytes"
              ],
              "properties": {
                "token": {
                  "type": "string"
                },
                "logprob": {
                  "type": "number"
                },
                "bytes": {
                  "type": "array",
                  "nullable": true,
                  "items": {
                    "type": "integer"
                  }
                }
              }
            }
          }
        }
      },
      "CompletionUsage": {
        "type": "object",
        "required": [
          "prompt_tokens",
          "completion_tokens",
          "total_tokens"
        ],
        "properties": {
          "prompt_tokens": {
            "type": "integer"
          },
          "completion_tokens": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          },
          "prompt_tokens_details": {
            "type": "object",
            "nullable": true,
            "properties": {
              "cached_tokens": {
                "type": "integer"
              },
              "audio_tokens": {
                "type": "integer"
              }
            }
          },
          "completion_tokens_details": {
            "type": "object",
            "nullable": true,
            "properties": {
              "reasoning_tokens": {
                "type": "integer"
              },
              "audio_tokens": {
                "type": "integer"
              },
              "accepted_prediction_tokens": {
                "type": "integer"
              },
              "rejected_prediction_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "title": "ErrorResponse",
        "description": "Error response returned when a request fails",
        "type": "object",
        "required": [
          "errors"
        ],
        "properties": {
          "errors": {
            "description": "Error details. Can be either:\n- An object with a `detail` field for general errors\n- An array of validation errors with `path`, `message`, and `value` fields",
            "oneOf": [
              {
                "type": "object",
                "required": [
                  "detail"
                ],
                "properties": {
                  "detail": {
                    "type": "string",
                    "description": "Human-readable error message"
                  }
                }
              },
              {
                "type": "array",
                "description": "List of validation errors",
                "items": {
                  "type": "object",
                  "required": [
                    "path",
                    "message"
                  ],
                  "properties": {
                    "path": {
                      "type": "string",
                      "description": "The field path that caused the error"
                    },
                    "message": {
                      "type": "string",
                      "description": "Description of the validation error"
                    },
                    "value": {
                      "type": "string",
                      "description": "The invalid value that was provided"
                    }
                  }
                }
              }
            ]
          }
        },
        "example": {
          "errors": {
            "detail": "Invalid API key provided"
          }
        }
      },
      "BalanceError": {
        "title": "BalanceError",
        "description": "Error response for balance-related issues (e.g., replenishment in progress)",
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message",
              "type"
            ],
            "properties": {
              "code": {
                "type": "string",
                "description": "Error code identifier",
                "example": "balance_replenishing"
              },
              "message": {
                "type": "string",
                "description": "Human-readable error message",
                "example": "Balance replenishment in progress. Please retry shortly."
              },
              "type": {
                "type": "string",
                "description": "Error type classification",
                "example": "balance_replenishing"
              },
              "param": {
                "type": "string",
                "nullable": true,
                "description": "The parameter that caused the error, if applicable",
                "example": null
              }
            }
          }
        },
        "example": {
          "error": {
            "code": "balance_replenishing",
            "message": "Balance replenishment in progress. Please retry shortly.",
            "type": "balance_replenishing",
            "param": null
          }
        }
      },
      "ModelsResponse": {
        "title": "ModelsResponse",
        "description": "List of available models",
        "type": "object",
        "required": [
          "object",
          "data"
        ],
        "properties": {
          "object": {
            "type": "string",
            "description": "The object type, always \"list\"",
            "enum": [
              "list"
            ]
          },
          "data": {
            "type": "array",
            "description": "List of model objects",
            "items": {
              "$ref": "#/components/schemas/Model"
            }
          }
        },
        "example": {
          "object": "list",
          "data": [
            {
              "id": "text-standard",
              "object": "model",
              "display_name": "Text Standard",
              "created": 1709251200,
              "owned_by": "The Grid"
            },
            {
              "id": "text-prime",
              "object": "model",
              "display_name": "Text Prime",
              "created": 1709251201,
              "owned_by": "The Grid"
            },
            {
              "id": "text-max",
              "object": "model",
              "display_name": "Text Max",
              "created": 1709251202,
              "owned_by": "The Grid"
            },
            {
              "id": "code-standard",
              "object": "model",
              "display_name": "Code Standard",
              "created": 1709251203,
              "owned_by": "The Grid"
            },
            {
              "id": "code-prime",
              "object": "model",
              "display_name": "Code Prime",
              "created": 1709251204,
              "owned_by": "The Grid"
            },
            {
              "id": "code-max",
              "object": "model",
              "display_name": "Code Max",
              "created": 1709251205,
              "owned_by": "The Grid"
            },
            {
              "id": "agent-standard",
              "object": "model",
              "display_name": "Agent Standard",
              "created": 1709251206,
              "owned_by": "The Grid"
            },
            {
              "id": "agent-prime",
              "object": "model",
              "display_name": "Agent Prime",
              "created": 1709251207,
              "owned_by": "The Grid"
            },
            {
              "id": "agent-max",
              "object": "model",
              "display_name": "Agent Max",
              "created": 1709251208,
              "owned_by": "The Grid"
            }
          ]
        }
      },
      "Model": {
        "title": "Model",
        "description": "An LLM model available for use",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The Grid instrument identifier to use as the model in API requests, for example text-prime, code-prime, or agent-standard.",
            "example": "text-prime"
          },
          "object": {
            "type": "string",
            "description": "The object type, always \"model\"",
            "enum": [
              "model"
            ]
          },
          "display_name": {
            "type": "string",
            "description": "Human-readable instrument name.",
            "example": "Text Prime"
          },
          "created": {
            "type": "integer",
            "description": "Unix timestamp when the model was created",
            "example": 1687882411
          },
          "owned_by": {
            "type": "string",
            "description": "The organization that owns the model",
            "example": "The Grid"
          }
        }
      },
      "CursorPaging": {
        "type": "object",
        "description": "Cursor-based pagination",
        "properties": {
          "has_more": {
            "type": "boolean"
          },
          "next_cursor": {
            "type": "string",
            "nullable": true
          },
          "prev_cursor": {
            "type": "string",
            "nullable": true
          }
        }
      },
      "MarketWithInstruments": {
        "type": "object",
        "properties": {
          "market_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string",
            "nullable": true
          },
          "market_type": {
            "type": "string",
            "enum": [
              "spot"
            ]
          },
          "status": {
            "type": "string",
            "description": "Market status. Known values include active, inactive, suspended; API may return other values."
          },
          "associated_instruments": {
            "type": "array",
            "description": "List of instrument IDs (was `allowed_instruments` in legacy API)",
            "items": {
              "type": "string"
            }
          },
          "instruments": {
            "type": "array",
            "description": "AI-commodity instruments only, in the order of `associated_instruments`.\nFor full details use GET /v1/instruments/{instrument_id}.",
            "items": {
              "type": "object",
              "required": [
                "instrument_id",
                "instrument_type",
                "symbol"
              ],
              "properties": {
                "instrument_id": {
                  "type": "string"
                },
                "instrument_type": {
                  "type": "string",
                  "description": "Legacy `commodity` normalized to `ai_commodity`",
                  "enum": [
                    "ai_commodity",
                    "currency",
                    "commodity"
                  ]
                },
                "symbol": {
                  "type": "string"
                },
                "name": {
                  "type": "string",
                  "nullable": true,
                  "description": "May be null if not set on the instrument"
                },
                "description": {
                  "type": "string",
                  "nullable": true,
                  "description": "May be null if not set on the instrument"
                }
              }
            }
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "Ticker": {
        "type": "object",
        "description": "Market ticker data including last trade, best bid/ask prices, and 24-hour volume.",
        "properties": {
          "last_price": {
            "type": "string",
            "nullable": true,
            "description": "Last trade price (decimal string)"
          },
          "last_trade_quantity": {
            "type": "integer",
            "nullable": true,
            "description": "Last trade quantity (was `last_trade_size` in legacy API)"
          },
          "last_trade_timestamp": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of the most recent trade (ISO8601)"
          },
          "lowest_ask": {
            "type": "string",
            "nullable": true,
            "description": "Best ask (decimal string)"
          },
          "highest_bid": {
            "type": "string",
            "nullable": true,
            "description": "Best bid (decimal string)"
          },
          "volume_24h": {
            "type": "integer",
            "nullable": true,
            "description": "24h volume"
          }
        }
      },
      "OrderbookLevel": {
        "type": "object",
        "description": "Single price level in the order book (buy or sell side).",
        "properties": {
          "price": {
            "type": "string"
          },
          "quantity": {
            "type": "integer",
            "description": "Size at this level (was `size` in legacy API)"
          },
          "total": {
            "type": "integer"
          },
          "order_count": {
            "type": "integer"
          }
        }
      },
      "OrderbookResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "object",
            "properties": {
              "buy": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/OrderbookLevel"
                }
              },
              "sell": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/OrderbookLevel"
                }
              },
              "highest_bid": {
                "type": "string",
                "nullable": true
              },
              "lowest_ask": {
                "type": "string",
                "nullable": true
              },
              "highest_bid_price": {
                "type": "string",
                "nullable": true
              },
              "lowest_ask_price": {
                "type": "string",
                "nullable": true
              },
              "updated_at": {
                "type": "string",
                "format": "date-time"
              }
            }
          }
        }
      },
      "PublicTrade": {
        "type": "object",
        "description": "Public trade for a market (not scoped to the authenticated user; no order_id or trading_account_id).",
        "properties": {
          "trade_id": {
            "type": "string",
            "description": "Public trade ID"
          },
          "market_id": {
            "type": "string"
          },
          "market_name": {
            "type": "string",
            "nullable": true
          },
          "instrument_id": {
            "type": "string"
          },
          "instrument_symbol": {
            "type": "string",
            "nullable": true
          },
          "instrument_name": {
            "type": "string",
            "nullable": true
          },
          "price": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "total_value": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "execution_timestamp": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "settlement_timestamp": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          }
        }
      },
      "InstrumentSummary": {
        "type": "object",
        "properties": {
          "instrument_id": {
            "type": "string",
            "example": "instrument_e0b04b8a-ce1f-4ccc-a4ca-2a47825d69b0"
          },
          "symbol": {
            "type": "string",
            "example": "text-standard"
          },
          "name": {
            "type": "string",
            "example": "Text Standard"
          },
          "description": {
            "type": "string",
            "example": "Fast chat inference capacity"
          },
          "instrument_type": {
            "type": "string",
            "description": "Category of instrument (was `type` in legacy API). Legacy `commodity` normalized to `ai_commodity`.\n- `ai_commodity`: Tradeable AI inference capacity (e.g., tokens for LLM usage)\n- `currency`: Fiat currency used for settlement (e.g., USD)",
            "enum": [
              "ai_commodity",
              "currency",
              "commodity"
            ],
            "example": "ai_commodity"
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "inactive",
              "suspended",
              "deleted"
            ],
            "example": "active"
          },
          "basic_info": {
            "type": "object",
            "nullable": true,
            "properties": {
              "service_type": {
                "type": "string",
                "example": "text_generation"
              },
              "model_category": {
                "type": "string",
                "description": "Model category classification",
                "nullable": true
              },
              "currency_code": {
                "type": "string",
                "example": "USD"
              },
              "precision": {
                "type": "integer",
                "example": 2
              }
            }
          },
          "trading_params": {
            "type": "object",
            "nullable": true,
            "properties": {
              "min_quantity": {
                "type": "integer",
                "example": 1
              },
              "max_quantity": {
                "type": "integer",
                "example": 10000
              },
              "quantity_increment": {
                "type": "integer",
                "example": 1
              },
              "fee": {
                "type": "string",
                "description": "Fee rate (decimal string)"
              }
            }
          },
          "ai_specs": {
            "type": "object",
            "nullable": true,
            "properties": {
              "context_window": {
                "type": "string",
                "description": "Maximum context window size in tokens",
                "example": "8000"
              },
              "token_throughput": {
                "type": "string",
                "description": "Minimum token throughput rate in tokens per second",
                "example": "100"
              },
              "tokens_per_unit": {
                "type": "integer",
                "description": "Number of tokens per tradeable unit",
                "example": 1000000
              },
              "unit_definition": {
                "type": "string",
                "example": "1M tokens"
              },
              "qualifying_models": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "List of AI models that qualify for this instrument",
                "example": [
                  "gpt-5",
                  "gpt-5-mini"
                ]
              },
              "max_output_length": {
                "type": "integer",
                "description": "Maximum output length in tokens"
              },
              "min_performance_benchmark": {
                "type": "number",
                "description": "Minimum performance benchmark score"
              },
              "min_time_to_first_token_ms": {
                "type": "integer",
                "description": "Maximum time to first token in milliseconds"
              },
              "model_id": {
                "type": "string",
                "description": "Model identifier",
                "nullable": true
              },
              "model_version": {
                "type": "string",
                "description": "Model version",
                "nullable": true
              },
              "usage": {
                "type": "string",
                "description": "Usage type or category"
              }
            }
          }
        }
      },
      "InstrumentListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/InstrumentSummary"
            }
          },
          "paging": {
            "$ref": "#/components/schemas/CursorPaging"
          }
        }
      },
      "InstrumentDetail": {
        "type": "object",
        "properties": {
          "instrument_id": {
            "type": "string"
          },
          "symbol": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "instrument_type": {
            "type": "string",
            "description": "Legacy `commodity` normalized to `ai_commodity`",
            "enum": [
              "ai_commodity",
              "currency",
              "commodity"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "draft",
              "active",
              "inactive",
              "suspended",
              "deleted"
            ]
          },
          "ai_specs": {
            "type": "object",
            "nullable": true,
            "properties": {
              "context_window": {
                "type": "string",
                "description": "Maximum context window size in tokens"
              },
              "token_throughput": {
                "type": "string",
                "description": "Minimum token throughput rate in tokens per second"
              },
              "tokens_per_unit": {
                "type": "integer",
                "description": "Number of tokens per tradeable unit",
                "example": 1000000
              },
              "unit_definition": {
                "type": "string"
              },
              "qualifying_models": {
                "type": "array",
                "items": {
                  "type": "string"
                },
                "description": "List of AI models that qualify for this instrument"
              },
              "max_output_length": {
                "type": "integer",
                "description": "Maximum output length in tokens"
              },
              "min_performance_benchmark": {
                "type": "number",
                "description": "Minimum performance benchmark score"
              },
              "min_time_to_first_token_ms": {
                "type": "integer",
                "description": "Maximum time to first token in milliseconds"
              },
              "model_id": {
                "type": "string",
                "description": "Model identifier",
                "nullable": true
              },
              "model_version": {
                "type": "string",
                "description": "Model version",
                "nullable": true
              },
              "usage": {
                "type": "string",
                "description": "Usage type or category"
              }
            }
          },
          "basic_info": {
            "type": "object",
            "nullable": true,
            "properties": {
              "service_type": {
                "type": "string"
              },
              "model_category": {
                "type": "string",
                "description": "Model category classification",
                "nullable": true
              },
              "currency_code": {
                "type": "string"
              },
              "precision": {
                "type": "integer"
              }
            }
          },
          "sla_requirements": {
            "type": "object",
            "properties": {
              "availability_target": {
                "type": "number",
                "description": "Target uptime as a percentage (e.g., 99.95 means 99.95% availability)"
              },
              "availability_sla": {
                "type": "number",
                "description": "Availability SLA (percentage). May be present in API responses.",
                "nullable": true
              },
              "max_latency_ms": {
                "type": "integer",
                "description": "Maximum acceptable response latency in milliseconds"
              },
              "min_latency_ms": {
                "type": "integer",
                "description": "Minimum latency in milliseconds. May be present in API responses.",
                "nullable": true
              },
              "quality_score_min": {
                "type": "number",
                "description": "Minimum quality score threshold (0-100)"
              }
            }
          },
          "trading_params": {
            "type": "object",
            "properties": {
              "min_quantity": {
                "type": "integer"
              },
              "max_quantity": {
                "type": "integer"
              },
              "quantity_increment": {
                "type": "integer"
              },
              "fee": {
                "type": "string",
                "description": "Fee rate (decimal string)"
              }
            }
          },
          "last_trade_price": {
            "type": "string",
            "nullable": true
          },
          "last_trade_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "last_quote_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of most recent quote"
          },
          "total_volume": {
            "type": "string"
          },
          "volume_24h": {
            "type": "string"
          },
          "total_trades": {
            "type": "integer"
          },
          "total_quotes": {
            "type": "integer"
          },
          "price_range_24h_high": {
            "type": "string",
            "nullable": true,
            "description": "Highest price in last 24 hours"
          },
          "price_range_24h_low": {
            "type": "string",
            "nullable": true,
            "description": "Lowest price in last 24 hours"
          }
        }
      },
      "InstrumentDetailResponse": {
        "type": "object",
        "properties": {
          "data": {
            "$ref": "#/components/schemas/InstrumentDetail"
          }
        }
      },
      "Order": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string",
            "description": "Unique identifier for the order (was `id` in legacy API)"
          },
          "market_id": {
            "type": "string"
          },
          "market_name": {
            "type": "string",
            "nullable": true
          },
          "instrument_id": {
            "type": "string"
          },
          "instrument_name": {
            "type": "string",
            "nullable": true
          },
          "instrument_symbol": {
            "type": "string",
            "nullable": true
          },
          "trader_id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "limit",
              "market",
              "stop",
              "stop_limit"
            ]
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "price": {
            "type": "string",
            "nullable": true,
            "description": "Limit price per unit in quote currency (USD). Null for market orders."
          },
          "quantity": {
            "type": "integer",
            "description": "Total order quantity in units (was `size` in legacy API)"
          },
          "filled_quantity": {
            "type": "integer",
            "description": "Number of units that have been filled so far"
          },
          "filled_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp when the order was completely filled. Null if the order has not been fully filled yet.",
            "example": "2025-12-23T15:16:42Z"
          },
          "average_price": {
            "type": "string",
            "nullable": true,
            "description": "Volume-weighted average fill price across all fills for this order"
          },
          "fee": {
            "type": "string",
            "description": "Trading fee charged for this order in quote currency (USD)"
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "pending",
              "partially_filled",
              "filled",
              "closed",
              "cancellation_pending"
            ]
          },
          "closure_reason": {
            "type": "string",
            "nullable": true,
            "description": "Reason the order was closed. Only present when status is \"closed\" or \"filled\".\n- `filled`: Order was completely filled\n- `cancelled`: Order was manually cancelled by the user\n- `cancel_and_replace`: Order was cancelled as part of a cancel-and-replace operation\n- `expired`: Order expired (e.g., day orders at end of trading day)\n- `rejected`: Order was rejected by the matching engine\n- `partially_filled_no_liquidity`: Order was partially filled then closed because no remaining liquidity was available\n- `partially_filled_max_slippage`: Order was partially filled then closed because price moved beyond acceptable slippage\n- `partially_filled_insufficient_balance`: Order was partially filled then closed due to insufficient balance\n- `no_fill_no_liquidity`: Market order could not fill due to no available liquidity\n- `no_fill_max_slippage`: Market order could not fill within the acceptable slippage tolerance\n- `no_fill_insufficient_balance`: Order could not fill due to insufficient balance",
            "enum": [
              "filled",
              "cancelled",
              "cancel_and_replace",
              "expired",
              "rejected",
              "partially_filled_no_liquidity",
              "partially_filled_max_slippage",
              "partially_filled_insufficient_balance",
              "no_fill_no_liquidity",
              "no_fill_max_slippage",
              "no_fill_insufficient_balance",
              null
            ]
          },
          "time_in_force": {
            "type": "string",
            "enum": [
              "gtc",
              "ioc",
              "fok",
              "day"
            ],
            "description": "Order duration policy.\n- `gtc` (Good Till Cancelled): Order remains active until completely filled or manually cancelled\n- `ioc` (Immediate Or Cancel): Order executes immediately for available quantity, remainder is cancelled\n- `fok` (Fill Or Kill): Order must be completely filled immediately or entirely cancelled\n- `day`: Order expires at the end of the trading day if not filled"
          },
          "stop_price": {
            "type": "string",
            "nullable": true
          },
          "client_order_id": {
            "type": "string",
            "nullable": true
          },
          "submitted_at": {
            "type": "string",
            "format": "date-time"
          },
          "closed_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "triggered_by_auto_top_up": {
            "type": "boolean",
            "description": "Whether this order was automatically triggered by the auto top-up feature"
          }
        }
      },
      "TradingOrderListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Order"
            }
          },
          "paging": {
            "$ref": "#/components/schemas/CursorPaging"
          }
        }
      },
      "TradingCreateOrderRequest": {
        "type": "object",
        "required": [
          "market_id",
          "side",
          "type",
          "quantity"
        ],
        "properties": {
          "market_id": {
            "type": "string",
            "description": "Market identifier where the order will be placed",
            "example": "market_b310e860-97cd-45eb-bdc3-5be0b79295d0"
          },
          "client_order_id": {
            "type": "string",
            "description": "Optional client-provided order ID for idempotency. Must be unique per account. Duplicate IDs will return a 422 error with message \"client_order_id already exists\".",
            "example": "order_ZVFOAGG4JWRNXMCK",
            "nullable": true
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ],
            "description": "Order side: \"buy\" to purchase the instrument, \"sell\" to sell. Value is normalized to lowercase.",
            "example": "buy"
          },
          "type": {
            "type": "string",
            "enum": [
              "limit",
              "market"
            ],
            "description": "Order type: \"limit\" executes at specified price or better, \"market\" executes immediately at best available price. Value is normalized to lowercase.",
            "example": "limit"
          },
          "price": {
            "type": "string",
            "description": "Price per unit in quote currency (USD). **Required for limit orders, must be omitted for market orders.** Must be a positive number >= 0.0001 with at most 4 decimal places (tick size).",
            "example": "45.50"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "maximum": 100,
            "description": "Number of units to buy or sell. Must be a positive integer, maximum 100 per order.",
            "example": 100
          },
          "time_in_force": {
            "type": "string",
            "enum": [
              "gtc",
              "ioc",
              "fok",
              "day"
            ],
            "description": "Order duration policy. Value is normalized to lowercase.\n- `gtc` (Good Till Cancelled): Order remains active until completely filled or manually cancelled\n- `ioc` (Immediate Or Cancel): Order executes immediately for available quantity, remainder is cancelled\n- `fok` (Fill Or Kill): Order must be completely filled immediately or entirely cancelled\n- `day`: Order expires at the end of the trading day if not filled",
            "default": "gtc",
            "example": "gtc"
          }
        }
      },
      "TradeListResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/UserTrade"
            }
          },
          "paging": {
            "$ref": "#/components/schemas/CursorPaging"
          }
        }
      },
      "UserTrade": {
        "type": "object",
        "description": "Trade details from the user's perspective",
        "properties": {
          "trade_id": {
            "type": "string",
            "description": "Trade identifier"
          },
          "market_id": {
            "type": "string"
          },
          "market_name": {
            "type": "string"
          },
          "instrument_id": {
            "type": "string"
          },
          "instrument_name": {
            "type": "string"
          },
          "instrument_symbol": {
            "type": "string"
          },
          "order_id": {
            "type": "string",
            "description": "The user's order ID associated with this trade"
          },
          "trading_account_id": {
            "type": "string",
            "description": "The user's trading account ID"
          },
          "price": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "total_value": {
            "type": "string"
          },
          "fee": {
            "type": "string"
          },
          "side": {
            "type": "string",
            "enum": [
              "buy",
              "sell"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "executed",
              "settled"
            ]
          },
          "execution_timestamp": {
            "type": "string",
            "format": "date-time"
          },
          "settlement_timestamp": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TradingAccount": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string"
          },
          "user_id": {
            "type": "string"
          },
          "instrument_id": {
            "type": "string"
          },
          "instrument_name": {
            "type": "string"
          },
          "instrument_symbol": {
            "type": "string"
          },
          "market_id": {
            "type": "string"
          },
          "market_name": {
            "type": "string"
          },
          "total_balance": {
            "type": "string",
            "description": "Sum of available and locked balances (decimal string)"
          },
          "available_balance": {
            "type": "string",
            "description": "Balance available for placing new orders (decimal string)"
          },
          "locked_balance": {
            "type": "string",
            "description": "Balance currently locked in open orders (decimal string)"
          },
          "last_trade_price": {
            "type": "string",
            "nullable": true
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ]
          },
          "last_deposit_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "last_trading_activity_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "last_withdrawal_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "CurrencyTradingAccount": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string"
          },
          "user_id": {
            "type": "string"
          },
          "currency": {
            "type": "string"
          },
          "total_balance": {
            "type": "string"
          },
          "available_balance": {
            "type": "string"
          },
          "locked_balance": {
            "type": "string"
          },
          "status": {
            "type": "string"
          },
          "last_deposit_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of last deposit (null if none)"
          },
          "last_trading_activity_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of last trading activity (null if none)"
          },
          "last_withdrawal_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of last withdrawal (null if none)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "ConsumptionAccountsResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ConsumptionAccount"
            }
          },
          "paging": {
            "$ref": "#/components/schemas/CursorPaging"
          }
        }
      },
      "ConsumptionAccount": {
        "type": "object",
        "properties": {
          "account_id": {
            "type": "string"
          },
          "user_id": {
            "type": "string"
          },
          "instrument_id": {
            "type": "string"
          },
          "total_balance": {
            "type": "integer",
            "description": "Total token balance in the account."
          },
          "committed_balance": {
            "type": "integer",
            "description": "Tokens currently reserved for a consumption request. Unused tokens will be returned after the request is fulfilled."
          },
          "uncommitted_balance": {
            "type": "integer",
            "description": "Tokens currently uncommitted (available for new requests)."
          },
          "tokens_allocated": {
            "type": "integer",
            "description": "Total tokens allocated to this consumption account across all time."
          },
          "tokens_available": {
            "type": "integer",
            "description": "Tokens currently available for consumption after commitments."
          },
          "status": {
            "type": "string",
            "enum": [
              "active",
              "inactive"
            ]
          },
          "total_commitments": {
            "type": "integer",
            "description": "Total number of commitments made from this account."
          },
          "total_deposits": {
            "type": "integer",
            "description": "Total number of deposits into this account."
          },
          "total_transfers_in": {
            "type": "integer",
            "description": "Total number of transfers into the account."
          },
          "total_transfers_out": {
            "type": "integer",
            "description": "Total number of transfers out of the account."
          },
          "total_withdrawals": {
            "type": "integer",
            "description": "Total number of withdrawals from the account."
          },
          "last_commitment_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of last commitment (null if none)"
          },
          "last_deposit_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of last deposit (null if none)"
          },
          "last_transfer_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of last transfer (null if none)"
          },
          "last_withdrawal_at": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "Timestamp of last withdrawal (null if none)"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TransferRequest": {
        "type": "object",
        "required": [
          "instrument_id",
          "quantity"
        ],
        "properties": {
          "instrument_id": {
            "type": "string",
            "description": "The instrument to transfer from your trading account to your consumption account",
            "example": "instrument_c18a986c-522b-475a-b319-f2d0ba04a64d"
          },
          "quantity": {
            "type": "integer",
            "minimum": 1,
            "description": "Number of units to transfer. Must have sufficient available balance in your trading account.",
            "example": 100
          }
        }
      },
      "TransferResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "enum": [
              "success"
            ]
          },
          "transfer_id": {
            "type": "string"
          }
        }
      },
      "TransferHistory": {
        "type": "object",
        "properties": {
          "transfer_id": {
            "type": "string"
          },
          "account_id": {
            "type": "string"
          },
          "sender_account_id": {
            "type": "string"
          },
          "instrument_id": {
            "type": "string"
          },
          "instrument_name": {
            "type": "string"
          },
          "market_id": {
            "type": "string"
          },
          "quantity": {
            "type": "integer"
          },
          "transferred_at": {
            "type": "string",
            "format": "date-time"
          },
          "inserted_at": {
            "type": "string",
            "format": "date-time"
          },
          "updated_at": {
            "type": "string",
            "format": "date-time"
          }
        }
      },
      "TransferHistoryResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/TransferHistory"
            }
          },
          "paging": {
            "$ref": "#/components/schemas/CursorPaging"
          }
        }
      },
      "PriceHistory": {
        "type": "object",
        "description": "OHLCV candle data for a specific time period",
        "properties": {
          "time": {
            "type": "string",
            "format": "date-time",
            "description": "Period start time (ISO8601)"
          },
          "market_id": {
            "type": "string",
            "description": "Market identifier"
          },
          "resolution": {
            "type": "string",
            "enum": [
              "1m",
              "5m",
              "15m",
              "30m",
              "1h",
              "4h",
              "1d",
              "1w",
              "1M"
            ],
            "description": "Candle resolution/timeframe"
          },
          "open": {
            "type": "string",
            "description": "Opening price for the period (decimal string)"
          },
          "high": {
            "type": "string",
            "description": "Highest price during the period (decimal string)"
          },
          "low": {
            "type": "string",
            "description": "Lowest price during the period (decimal string)"
          },
          "close": {
            "type": "string",
            "description": "Closing price for the period (decimal string)"
          },
          "volume": {
            "type": "integer",
            "description": "Total trading volume during the period"
          },
          "trade_count": {
            "type": "integer",
            "description": "Number of trades during the period"
          }
        }
      },
      "PriceHistoryResponse": {
        "type": "object",
        "properties": {
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PriceHistory"
            }
          },
          "paging": {
            "$ref": "#/components/schemas/CursorPaging"
          }
        }
      },
      "TradingErrorResponse": {
        "type": "object",
        "properties": {
          "data": {
            "description": "Optional payload for non-error responses (typically null on errors)",
            "type": "object",
            "nullable": true
          },
          "error": {
            "type": "string",
            "nullable": true,
            "description": "Short, human-readable error summary"
          },
          "errors": {
            "type": "object",
            "description": "Machine-readable error details",
            "properties": {
              "detail": {
                "type": "string",
                "description": "High-level error detail message"
              },
              "fields": {
                "type": "object",
                "description": "Per-field validation errors when applicable"
              },
              "retry_after": {
                "type": "integer",
                "description": "Seconds to wait before retrying (for rate limit errors)"
              }
            }
          },
          "meta": {
            "type": "object",
            "description": "Optional metadata about the error (e.g., request_id, timestamp)"
          }
        }
      },
      "AnthropicMessagesRequest": {
        "properties": {
          "max_tokens": {
            "description": "Maximum tokens to generate",
            "minimum": 1,
            "type": "integer",
            "x-struct": null,
            "x-validate": null
          },
          "messages": {
            "description": "Array of message objects",
            "items": {
              "properties": {
                "content": {
                  "description": "Message content",
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "role": {
                  "description": "Message role",
                  "enum": [
                    "user",
                    "assistant",
                    "tool"
                  ],
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                }
              },
              "required": [
                "role",
                "content"
              ],
              "type": "object",
              "x-struct": null,
              "x-validate": null
            },
            "minItems": 1,
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "model": {
            "description": "Model name (e.g., claude-opus-4-5)",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "stream": {
            "description": "Enable streaming responses",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "system": {
            "description": "System prompt",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "temperature": {
            "description": "Sampling temperature",
            "maximum": 1,
            "minimum": 0,
            "type": "number",
            "x-struct": null,
            "x-validate": null
          },
          "tools": {
            "description": "Tools available to the model",
            "items": {
              "type": "object",
              "x-struct": null,
              "x-validate": null
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "top_k": {
            "description": "Top-k sampling parameter",
            "minimum": 1,
            "type": "integer",
            "x-struct": null,
            "x-validate": null
          },
          "top_p": {
            "description": "Nucleus sampling parameter",
            "maximum": 1,
            "minimum": 0,
            "type": "number",
            "x-struct": null,
            "x-validate": null
          }
        },
        "required": [
          "model",
          "messages",
          "max_tokens"
        ],
        "title": "AnthropicMessagesRequest",
        "type": "object",
        "x-struct": "Elixir.CortexWeb.Consumption.Schemas.AnthropicMessagesRequest",
        "x-validate": null
      },
      "OpenAIResponsesRequest": {
        "properties": {
          "input": {
            "description": "Text input string for the Responses API",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "max_output_tokens": {
            "description": "Maximum output tokens (OpenAI Responses API)",
            "minimum": 1,
            "type": "integer",
            "x-struct": null,
            "x-validate": null
          },
          "max_tokens": {
            "description": "Maximum tokens to generate",
            "minimum": 1,
            "type": "integer",
            "x-struct": null,
            "x-validate": null
          },
          "metadata": {
            "description": "Custom metadata for the request",
            "type": "object",
            "x-struct": null,
            "x-validate": null
          },
          "model": {
            "description": "Model name",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "stream": {
            "description": "Enable streaming responses",
            "type": "boolean",
            "x-struct": null,
            "x-validate": null
          },
          "temperature": {
            "description": "Sampling temperature",
            "maximum": 2,
            "minimum": 0,
            "type": "number",
            "x-struct": null,
            "x-validate": null
          },
          "tools": {
            "description": "Tools/functions available to the model",
            "items": {
              "type": "object",
              "x-struct": null,
              "x-validate": null
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "top_p": {
            "description": "Nucleus sampling parameter",
            "maximum": 1,
            "minimum": 0,
            "type": "number",
            "x-struct": null,
            "x-validate": null
          },
          "user": {
            "description": "User identifier",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          }
        },
        "required": [
          "model",
          "input"
        ],
        "title": "OpenAIResponsesRequest",
        "type": "object",
        "x-struct": "Elixir.CortexWeb.Consumption.Schemas.OpenAIResponsesRequest",
        "x-validate": null
      },
      "UsageListResponse": {
        "example": {
          "data": [
            {
              "api_key_id": "0d4cbd91-3bfb-4a3e-a586-1c5522b6f4a2",
              "cost": {
                "amount": "0.004123",
                "currency": "USD",
                "effective_price_per_token": "0.000001915427",
                "metering_policy_version": "tokens_v1_identity",
                "reconciled_at": "2026-07-10T04:12:03Z",
                "status": "reconciled"
              },
              "created_at": "2026-07-10T04:12:00Z",
              "endpoint": "chat_completions",
              "request_id": "550e8400-e29b-41d4-a716-446655440000",
              "requested_model": "text-prime",
              "serving_model": "the-grid-ai/text-prime",
              "status": "reconciled",
              "timing": {
                "duration_ms": 28500,
                "tokens_per_second": 47.1,
                "ttft_ms": 320
              },
              "usage": {
                "input_tokens": 812,
                "output_tokens": 1340,
                "total_tokens": 2152
              }
            }
          ],
          "paging": {
            "has_more": false,
            "next_cursor": null,
            "prev_cursor": null
          }
        },
        "properties": {
          "data": {
            "items": {
              "properties": {
                "api_key_id": {
                  "format": "uuid",
                  "nullable": true,
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "cost": {
                  "properties": {
                    "amount": {
                      "description": "Decimal string, never a float.",
                      "nullable": true,
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "currency": {
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "effective_price_per_token": {
                      "nullable": true,
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "metering_policy_version": {
                      "nullable": true,
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "reconciled_at": {
                      "format": "date-time",
                      "nullable": true,
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "status": {
                      "enum": [
                        "pending",
                        "reconciled",
                        "unpriced",
                        "cancelled"
                      ],
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    }
                  },
                  "required": [
                    "currency",
                    "status"
                  ],
                  "type": "object",
                  "x-struct": null,
                  "x-validate": null
                },
                "created_at": {
                  "format": "date-time",
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "endpoint": {
                  "nullable": true,
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "request_id": {
                  "format": "uuid",
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "requested_model": {
                  "nullable": true,
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "serving_model": {
                  "nullable": true,
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "status": {
                  "enum": [
                    "pending",
                    "reconciled",
                    "error"
                  ],
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "timing": {
                  "properties": {
                    "duration_ms": {
                      "nullable": true,
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "tokens_per_second": {
                      "nullable": true,
                      "type": "number",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "ttft_ms": {
                      "nullable": true,
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    }
                  },
                  "type": "object",
                  "x-struct": null,
                  "x-validate": null
                },
                "usage": {
                  "properties": {
                    "input_tokens": {
                      "nullable": true,
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "output_tokens": {
                      "nullable": true,
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "total_tokens": {
                      "nullable": true,
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    }
                  },
                  "type": "object",
                  "x-struct": null,
                  "x-validate": null
                }
              },
              "required": [
                "request_id",
                "status",
                "created_at",
                "usage",
                "cost"
              ],
              "type": "object",
              "x-struct": null,
              "x-validate": null
            },
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "paging": {
            "properties": {
              "has_more": {
                "description": "True when a next page exists.",
                "type": "boolean",
                "x-struct": null,
                "x-validate": null
              },
              "next_cursor": {
                "description": "Opaque cursor for the next page (pass as `?next=`); null on the last page.",
                "nullable": true,
                "type": "string",
                "x-struct": null,
                "x-validate": null
              },
              "prev_cursor": {
                "description": "Opaque cursor for the previous page (pass as `?prev=`); null on the first page.",
                "nullable": true,
                "type": "string",
                "x-struct": null,
                "x-validate": null
              }
            },
            "required": [
              "next_cursor",
              "prev_cursor",
              "has_more"
            ],
            "type": "object",
            "x-struct": null,
            "x-validate": null
          }
        },
        "required": [
          "data",
          "paging"
        ],
        "title": "UsageListResponse",
        "type": "object",
        "x-struct": "Elixir.CortexWeb.Consumption.Schemas.UsageListResponse",
        "x-validate": null
      },
      "UsageResponse": {
        "example": {
          "api_key_id": "0d4cbd91-3bfb-4a3e-a586-1c5522b6f4a2",
          "cost": {
            "amount": "0.00412300",
            "breakdown": [
              {
                "acquisition_price_per_token": "0.0000019",
                "subtotal": "0.00408880",
                "tokens": 2152
              }
            ],
            "currency": "USD",
            "effective_price_per_token": "0.000001915427",
            "metering_policy_version": "tokens_v1_identity",
            "reconciled_at": "2026-07-10T04:12:03Z",
            "status": "reconciled"
          },
          "created_at": "2026-07-10T04:12:00Z",
          "endpoint": "chat_completions",
          "request_id": "550e8400-e29b-41d4-a716-446655440000",
          "requested_model": "text-prime",
          "serving_model": "the-grid-ai/text-prime",
          "status": "reconciled",
          "timing": {
            "duration_ms": 28500,
            "tokens_per_second": 47.1,
            "ttft_ms": 320
          },
          "usage": {
            "input_tokens": 812,
            "output_tokens": 1340,
            "total_tokens": 2152
          }
        },
        "properties": {
          "api_key_id": {
            "description": "API key that made the request; null on rows that predate attribution.",
            "format": "uuid",
            "nullable": true,
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "cost": {
            "properties": {
              "amount": {
                "description": "Decimal string, never a float. Null until reconciled; when status is `unpriced` this is the priced portion only (or null).",
                "nullable": true,
                "type": "string",
                "x-struct": null,
                "x-validate": null
              },
              "breakdown": {
                "description": "Per-acquisition-lot draw audit; cost == sum of subtotals.",
                "items": {
                  "properties": {
                    "acquisition_price_per_token": {
                      "nullable": true,
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "subtotal": {
                      "nullable": true,
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "tokens": {
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    }
                  },
                  "type": "object",
                  "x-struct": null,
                  "x-validate": null
                },
                "type": "array",
                "x-struct": null,
                "x-validate": null
              },
              "currency": {
                "type": "string",
                "x-struct": null,
                "x-validate": null
              },
              "effective_price_per_token": {
                "nullable": true,
                "type": "string",
                "x-struct": null,
                "x-validate": null
              },
              "metering_policy_version": {
                "nullable": true,
                "type": "string",
                "x-struct": null,
                "x-validate": null
              },
              "reconciled_at": {
                "format": "date-time",
                "nullable": true,
                "type": "string",
                "x-struct": null,
                "x-validate": null
              },
              "status": {
                "enum": [
                  "pending",
                  "reconciled",
                  "unpriced",
                  "cancelled"
                ],
                "type": "string",
                "x-struct": null,
                "x-validate": null
              }
            },
            "required": [
              "currency",
              "status"
            ],
            "type": "object",
            "x-struct": null,
            "x-validate": null
          },
          "created_at": {
            "format": "date-time",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "endpoint": {
            "nullable": true,
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "request_id": {
            "format": "uuid",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "requested_model": {
            "nullable": true,
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "serving_model": {
            "nullable": true,
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "status": {
            "description": "Lifecycle of the request record; cost settles at reconciliation.",
            "enum": [
              "pending",
              "reconciled",
              "error"
            ],
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "timing": {
            "properties": {
              "duration_ms": {
                "nullable": true,
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              },
              "tokens_per_second": {
                "nullable": true,
                "type": "number",
                "x-struct": null,
                "x-validate": null
              },
              "ttft_ms": {
                "nullable": true,
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              }
            },
            "type": "object",
            "x-struct": null,
            "x-validate": null
          },
          "usage": {
            "properties": {
              "input_tokens": {
                "nullable": true,
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              },
              "output_tokens": {
                "nullable": true,
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              },
              "total_tokens": {
                "nullable": true,
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              }
            },
            "type": "object",
            "x-struct": null,
            "x-validate": null
          }
        },
        "required": [
          "request_id",
          "status",
          "created_at",
          "usage",
          "cost"
        ],
        "title": "UsageResponse",
        "type": "object",
        "x-struct": "Elixir.CortexWeb.Consumption.Schemas.UsageResponse",
        "x-validate": null
      },
      "UsageSummaryResponse": {
        "example": {
          "buckets": [
            {
              "cost": {
                "cancelled_requests": 0,
                "currency": "USD",
                "pending_requests": 1,
                "reconciled_amount": "0.286432",
                "reconciled_requests": 40,
                "unpriced_requests": 1,
                "unpriced_tokens": 2152
              },
              "input_tokens": 61204,
              "key": "text-prime",
              "output_tokens": 88310,
              "request_count": 42,
              "total_tokens": 149514
            }
          ],
          "from": "2026-07-01T00:00:00Z",
          "group_by": "model",
          "to": "2026-07-11T00:00:00Z",
          "totals": {
            "cost": {
              "cancelled_requests": 0,
              "currency": "USD",
              "pending_requests": 1,
              "reconciled_amount": "0.286432",
              "reconciled_requests": 40,
              "unpriced_requests": 1,
              "unpriced_tokens": 2152
            },
            "input_tokens": 61204,
            "output_tokens": 88310,
            "request_count": 42,
            "total_tokens": 149514
          }
        },
        "properties": {
          "buckets": {
            "description": "One entry per group, at most 100 (day newest-first; model/API key most-used first); omitted when no group_by was requested.",
            "items": {
              "properties": {
                "cost": {
                  "properties": {
                    "cancelled_requests": {
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "currency": {
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "pending_requests": {
                      "description": "Requests not yet cost-settled.",
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "reconciled_amount": {
                      "description": "Decimal string; sum of the priced portion of every request in scope. Null when nothing priced.",
                      "nullable": true,
                      "type": "string",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "reconciled_requests": {
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "unpriced_requests": {
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "unpriced_tokens": {
                      "description": "Tokens consumed without a known cost basis; never converted to dollars.",
                      "type": "integer",
                      "x-struct": null,
                      "x-validate": null
                    }
                  },
                  "required": [
                    "currency",
                    "reconciled_requests",
                    "pending_requests",
                    "unpriced_requests",
                    "unpriced_tokens"
                  ],
                  "type": "object",
                  "x-struct": null,
                  "x-validate": null
                },
                "input_tokens": {
                  "type": "integer",
                  "x-struct": null,
                  "x-validate": null
                },
                "key": {
                  "description": "Bucket key: ISO date for day, model name for model, api key id for api_key.",
                  "nullable": true,
                  "type": "string",
                  "x-struct": null,
                  "x-validate": null
                },
                "output_tokens": {
                  "type": "integer",
                  "x-struct": null,
                  "x-validate": null
                },
                "request_count": {
                  "type": "integer",
                  "x-struct": null,
                  "x-validate": null
                },
                "total_tokens": {
                  "type": "integer",
                  "x-struct": null,
                  "x-validate": null
                }
              },
              "required": [
                "key",
                "request_count",
                "total_tokens",
                "cost"
              ],
              "type": "object",
              "x-struct": null,
              "x-validate": null
            },
            "nullable": true,
            "type": "array",
            "x-struct": null,
            "x-validate": null
          },
          "from": {
            "description": "Start of the applied window (defaults to 30 days before `to`).",
            "format": "date-time",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "group_by": {
            "enum": [
              "day",
              "model",
              "api_key"
            ],
            "nullable": true,
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "to": {
            "description": "End of the applied window (defaults to now).",
            "format": "date-time",
            "type": "string",
            "x-struct": null,
            "x-validate": null
          },
          "totals": {
            "properties": {
              "cost": {
                "properties": {
                  "cancelled_requests": {
                    "type": "integer",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "currency": {
                    "type": "string",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "pending_requests": {
                    "description": "Requests not yet cost-settled.",
                    "type": "integer",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "reconciled_amount": {
                    "description": "Decimal string; sum of the priced portion of every request in scope. Null when nothing priced.",
                    "nullable": true,
                    "type": "string",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "reconciled_requests": {
                    "type": "integer",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "unpriced_requests": {
                    "type": "integer",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "unpriced_tokens": {
                    "description": "Tokens consumed without a known cost basis; never converted to dollars.",
                    "type": "integer",
                    "x-struct": null,
                    "x-validate": null
                  }
                },
                "required": [
                  "currency",
                  "reconciled_requests",
                  "pending_requests",
                  "unpriced_requests",
                  "unpriced_tokens"
                ],
                "type": "object",
                "x-struct": null,
                "x-validate": null
              },
              "input_tokens": {
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              },
              "output_tokens": {
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              },
              "request_count": {
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              },
              "total_tokens": {
                "type": "integer",
                "x-struct": null,
                "x-validate": null
              }
            },
            "required": [
              "request_count",
              "total_tokens",
              "cost"
            ],
            "type": "object",
            "x-struct": null,
            "x-validate": null
          }
        },
        "required": [
          "totals",
          "from",
          "to"
        ],
        "title": "UsageSummaryResponse",
        "type": "object",
        "x-struct": "Elixir.CortexWeb.Consumption.Schemas.UsageSummaryResponse",
        "x-validate": null
      },
      "ConsumptionErrorResponse": {
        "description": "Error envelope. Validation failures and metering errors use the OpenAI-compatible `error` object; lower-level routing failures use the legacy `errors` object.",
        "example": {
          "error": {
            "code": "required",
            "details": [
              {
                "code": "required",
                "message": "is required",
                "param": "model"
              }
            ],
            "message": "is required, at model",
            "param": "model",
            "type": "invalid_request_error"
          }
        },
        "oneOf": [
          {
            "properties": {
              "error": {
                "properties": {
                  "code": {
                    "nullable": true,
                    "type": "string",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "details": {
                    "description": "Non-standard. One entry per validation failure, preserving the structured Zoi error code and offending path.",
                    "items": {
                      "properties": {
                        "code": {
                          "nullable": true,
                          "type": "string",
                          "x-struct": null,
                          "x-validate": null
                        },
                        "message": {
                          "type": "string",
                          "x-struct": null,
                          "x-validate": null
                        },
                        "param": {
                          "nullable": true,
                          "type": "string",
                          "x-struct": null,
                          "x-validate": null
                        }
                      },
                      "required": [
                        "message"
                      ],
                      "type": "object",
                      "x-struct": null,
                      "x-validate": null
                    },
                    "type": "array",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "message": {
                    "type": "string",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "param": {
                    "nullable": true,
                    "type": "string",
                    "x-struct": null,
                    "x-validate": null
                  },
                  "type": {
                    "type": "string",
                    "x-struct": null,
                    "x-validate": null
                  }
                },
                "required": [
                  "message",
                  "type"
                ],
                "type": "object",
                "x-struct": null,
                "x-validate": null
              }
            },
            "required": [
              "error"
            ],
            "type": "object",
            "x-struct": null,
            "x-validate": null
          },
          {
            "properties": {
              "errors": {
                "properties": {
                  "detail": {
                    "type": "string",
                    "x-struct": null,
                    "x-validate": null
                  }
                },
                "required": [
                  "detail"
                ],
                "type": "object",
                "x-struct": null,
                "x-validate": null
              }
            },
            "required": [
              "errors"
            ],
            "type": "object",
            "x-struct": null,
            "x-validate": null
          }
        ],
        "title": "ErrorResponse",
        "type": "object",
        "x-struct": "Elixir.CortexWeb.Consumption.Schemas.ErrorResponse",
        "x-validate": null
      }
    },
    "responses": {
      "Unauthorized": {
        "description": "Unauthorized - Invalid or missing authentication headers",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/x-request-id"
          },
          "x-ratelimit-limit": {
            "$ref": "#/components/headers/x-ratelimit-limit"
          },
          "x-ratelimit-remaining": {
            "$ref": "#/components/headers/x-ratelimit-remaining"
          },
          "x-ratelimit-reset": {
            "$ref": "#/components/headers/x-ratelimit-reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/TradingErrorResponse"
            },
            "example": {
              "data": null,
              "error": "Invalid signature",
              "errors": {
                "detail": "The provided signature does not match the expected value"
              },
              "meta": {
                "request_id": "GIkgbPVEdBDYQbcAAChF",
                "timestamp": "2026-01-15T10:30:00Z"
              }
            }
          }
        }
      },
      "NotFound": {
        "description": "Not found - The requested resource does not exist",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/x-request-id"
          },
          "x-ratelimit-limit": {
            "$ref": "#/components/headers/x-ratelimit-limit"
          },
          "x-ratelimit-remaining": {
            "$ref": "#/components/headers/x-ratelimit-remaining"
          },
          "x-ratelimit-reset": {
            "$ref": "#/components/headers/x-ratelimit-reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/TradingErrorResponse"
            },
            "example": {
              "data": null,
              "error": "Resource not found",
              "errors": {
                "detail": "The requested resource could not be found"
              },
              "meta": {
                "request_id": "GIkgbPVEdBDYQbcAAChF",
                "timestamp": "2026-01-15T10:30:00Z"
              }
            }
          }
        }
      },
      "ValidationError": {
        "description": "Validation error - Request parameters failed validation",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/x-request-id"
          },
          "x-ratelimit-limit": {
            "$ref": "#/components/headers/x-ratelimit-limit"
          },
          "x-ratelimit-remaining": {
            "$ref": "#/components/headers/x-ratelimit-remaining"
          },
          "x-ratelimit-reset": {
            "$ref": "#/components/headers/x-ratelimit-reset"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/TradingErrorResponse"
            },
            "example": {
              "data": null,
              "error": "Validation failed",
              "errors": {
                "detail": "One or more fields failed validation",
                "fields": {
                  "price": "must be a positive number",
                  "quantity": "must be at least 1"
                }
              },
              "meta": {
                "request_id": "GIkgbPVEdBDYQbcAAChF",
                "timestamp": "2026-01-15T10:30:00Z"
              }
            }
          }
        }
      },
      "RateLimitExceeded": {
        "description": "Rate limit exceeded - Too many requests in the current time window",
        "headers": {
          "x-request-id": {
            "$ref": "#/components/headers/x-request-id"
          },
          "x-ratelimit-limit": {
            "$ref": "#/components/headers/x-ratelimit-limit"
          },
          "x-ratelimit-remaining": {
            "description": "Will be 0 when rate limited",
            "schema": {
              "type": "integer",
              "example": 0
            }
          },
          "x-ratelimit-reset": {
            "$ref": "#/components/headers/x-ratelimit-reset"
          },
          "x-ratelimit-retry-after": {
            "$ref": "#/components/headers/x-ratelimit-retry-after"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/TradingErrorResponse"
            },
            "example": {
              "data": null,
              "error": "Rate limit exceeded",
              "errors": {
                "detail": "You have exceeded the rate limit. Please wait before making more requests.",
                "retry_after": 30
              },
              "meta": {
                "request_id": "GIkgbPVEdBDYQbcAAChF",
                "timestamp": "2026-01-15T10:30:00Z"
              }
            }
          }
        }
      }
    },
    "headers": {
      "x-request-id": {
        "description": "Unique identifier for the request. Use this value when contacting support \nto help diagnose issues. This header is returned on every response.",
        "schema": {
          "type": "string",
          "example": "GIkgbPVEdBDYQbcAAChF"
        }
      },
      "x-ratelimit-limit": {
        "description": "The maximum number of requests allowed in the current time window",
        "schema": {
          "type": "integer",
          "example": 100
        }
      },
      "x-ratelimit-remaining": {
        "description": "The number of requests remaining in the current time window",
        "schema": {
          "type": "integer",
          "example": 95
        }
      },
      "x-ratelimit-reset": {
        "description": "Unix timestamp (seconds) when the rate limit window resets",
        "schema": {
          "type": "integer",
          "example": 1640995200
        }
      },
      "x-ratelimit-retry-after": {
        "description": "Seconds to wait before retrying (only present when rate limited)",
        "schema": {
          "type": "integer",
          "example": 30
        }
      }
    },
    "parameters": {
      "next": {
        "name": "next",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "Cursor for forward pagination. Pass the `next_cursor` value from a previous response to fetch the next page. Mutually exclusive with `prev`."
      },
      "prev": {
        "name": "prev",
        "in": "query",
        "schema": {
          "type": "string"
        },
        "description": "Cursor for backward pagination. Pass the `prev_cursor` value from a previous response to fetch the previous page. Mutually exclusive with `next`."
      },
      "limit": {
        "name": "limit",
        "in": "query",
        "schema": {
          "type": "integer",
          "default": 50,
          "maximum": 100
        },
        "description": "Number of items to return per page (max: 100)"
      }
    }
  },
  "x-grid-entity": {
    "name": "The Grid",
    "domain": "thegrid.ai",
    "type": "Real-time spot market for AI inference",
    "founded_by": "Spectral Labs",
    "description": "The Grid (thegrid.ai) is a real-time spot market for AI inference. Developers buy standardized Text, Code, and Agent instruments and consume inference through OpenAI and Anthropic-compatible APIs at prices set by competing suppliers on a live order book."
  },
  "x-grid-disambiguation": {
    "note": "The Grid (thegrid.ai) is frequently confused by AI models with several unrelated companies. This section clarifies the distinctions.",
    "this_company": {
      "name": "The Grid",
      "domain": "thegrid.ai",
      "what": "Real-time spot market for AI inference, built by Spectral Labs"
    },
    "not_affiliated_with": [
      {
        "name": "Grid AI",
        "domain": "grid.ai",
        "what": "MLOps platform, now rebranded to Lightning AI (lightning.ai)"
      },
      {
        "name": "Lightning AI",
        "domain": "lightning.ai",
        "what": "The rebrand of Grid AI. Builds MLOps tools."
      },
      {
        "name": "GridAI Technologies",
        "ticker": "NASDAQ: GRDX",
        "what": "Energy and data center company listed on NASDAQ"
      },
      {
        "name": "DGrid",
        "domain": "dgrid.ai",
        "what": "Decentralized Web3 AI gateway"
      },
      {
        "name": "The Grid (website builder)",
        "what": "Defunct AI website builder from circa 2015. No longer operating."
      }
    ]
  },
  "x-grid-instruments": [
    {
      "id": "text-standard",
      "name": "Text Standard",
      "task_type": "Text",
      "tier": "Standard",
      "type": "Text Standard inference instrument",
      "best_for": [
        "Chat",
        "Summarization",
        "Classification"
      ],
      "description": "Price-optimized, high-throughput text for high-volume, low-stakes work. An instrument where any qualifying model can fill orders, so you contract for the specification, not a model name.",
      "recently_served_models": [
        "GPT-OSS 120B"
      ],
      "public_price_per_1m_tokens": "$0.035",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$0.035",
      "public_savings_up_to": "87%",
      "context": "128K",
      "output": "16K+"
    },
    {
      "id": "text-prime",
      "name": "Text Prime",
      "task_type": "Text",
      "tier": "Prime",
      "type": "Text Prime inference instrument",
      "best_for": [
        "RAG Synthesis",
        "Reasoning",
        "Analysis"
      ],
      "description": "The production default for everyday text generation. Strong reasoning at a fraction of frontier cost, suited to RAG, content drafting, summarization, and customer-facing generation.",
      "recently_served_models": [
        "MiniMax-M3",
        "GLM-5.2",
        "Kimi K2.6"
      ],
      "public_price_per_1m_tokens": "$0.120",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$0.120",
      "public_savings_up_to": "78%",
      "context": "196K",
      "output": "30K+"
    },
    {
      "id": "text-max",
      "name": "Text Max",
      "task_type": "Text",
      "tier": "Max",
      "type": "Text Max inference instrument",
      "best_for": [
        "Frontier Reasoning",
        "Legal Review",
        "Financial Analysis"
      ],
      "description": "Frontier-tier text for high-stakes, long-context work. The 1M-token context window handles synthesis across many documents.",
      "recently_served_models": [
        "Claude Opus 5"
      ],
      "public_price_per_1m_tokens": "$1.709",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$1.709",
      "public_savings_up_to": "16%",
      "context": "1M",
      "output": "128K"
    },
    {
      "id": "code-standard",
      "name": "Code Standard",
      "task_type": "Code",
      "tier": "Standard",
      "type": "Code Standard inference instrument",
      "best_for": [
        "Snippets",
        "Tests",
        "Lint Fixes"
      ],
      "description": "Price-optimized, high-throughput code for autocomplete, linting, and batch edits where latency and throughput dominate over reasoning depth.",
      "recently_served_models": [
        "GPT-OSS 120B"
      ],
      "public_price_per_1m_tokens": "$0.035",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$0.035",
      "public_savings_up_to": "79%",
      "context": "128K",
      "output": "16K+"
    },
    {
      "id": "code-prime",
      "name": "Code Prime",
      "task_type": "Code",
      "tier": "Prime",
      "type": "Code Prime inference instrument",
      "best_for": [
        "Feature Work",
        "Debugging",
        "Review"
      ],
      "description": "The production default for daily coding work. Fast enough for interactive use and capable on non-trivial tasks.",
      "recently_served_models": [
        "MiniMax-M3",
        "Kimi K2.6"
      ],
      "public_price_per_1m_tokens": "$0.120",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$0.120",
      "public_savings_up_to": "78%",
      "context": "196K",
      "output": "30K+"
    },
    {
      "id": "code-max",
      "name": "Code Max",
      "task_type": "Code",
      "tier": "Max",
      "type": "Code Max inference instrument",
      "best_for": [
        "Architecture",
        "Migrations",
        "Critical Fixes"
      ],
      "description": "Frontier-tier code for changes that span a whole codebase. The 1M-token context window handles full-repo analysis and large multi-file refactors.",
      "recently_served_models": [
        "Claude Opus 5"
      ],
      "public_price_per_1m_tokens": "$1.709",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$1.709",
      "public_savings_up_to": "50%",
      "context": "1M",
      "output": "128K"
    },
    {
      "id": "agent-standard",
      "name": "Agent Standard",
      "task_type": "Agent",
      "tier": "Standard",
      "type": "Agent Standard inference instrument",
      "best_for": [
        "Tool Routing",
        "Data Entry",
        "Batch Tasks"
      ],
      "description": "Price-optimized, high-throughput agents for orchestration glue, routing, tool selection, and high-volume single-purpose agents.",
      "recently_served_models": [
        "GPT-OSS 120B"
      ],
      "public_price_per_1m_tokens": "$0.035",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$0.035",
      "public_savings_up_to": "79%",
      "context": "128K",
      "output": "16K+"
    },
    {
      "id": "agent-prime",
      "name": "Agent Prime",
      "task_type": "Agent",
      "tier": "Prime",
      "type": "Agent Prime inference instrument",
      "best_for": [
        "Research",
        "Workflows",
        "Operations"
      ],
      "description": "The production default for daily agent work, production agent loops, multi-step tool chains, and planning.",
      "recently_served_models": [
        "MiniMax-M3",
        "GLM-5.2"
      ],
      "public_price_per_1m_tokens": "$0.120",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$0.120",
      "public_savings_up_to": "82%",
      "context": "196K",
      "output": "30K+"
    },
    {
      "id": "agent-max",
      "name": "Agent Max",
      "task_type": "Agent",
      "tier": "Max",
      "type": "Agent Max inference instrument",
      "best_for": [
        "Long Horizon",
        "High Stakes",
        "Complex Ops"
      ],
      "description": "Frontier-tier agents for autonomous work, deep tool chains, long-horizon research, and high-stakes automation.",
      "recently_served_models": [
        "Claude Opus 5",
        "Claude Opus 4.8"
      ],
      "public_price_per_1m_tokens": "$1.709",
      "public_pricing_basis": "Trailing 30-day blended average",
      "public_price_per_1m_tokens_trailing_30_day_average": "$1.709",
      "public_savings_up_to": "16%",
      "context": "1M",
      "output": "128K"
    },
    {
      "id": "gpt-sol-latest",
      "name": "GPT Sol Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for GPT frontier supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "gpt-5.6-sol"
      ],
      "public_price_per_1m_tokens": "$1.821",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "1M",
      "output": "128K"
    },
    {
      "id": "claude-opus-latest",
      "name": "Claude Opus Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for Claude Opus frontier supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "Claude Opus 5",
        "Claude Opus 4.8"
      ],
      "public_price_per_1m_tokens": "$1.709",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "1M",
      "output": "128K"
    },
    {
      "id": "gemini-pro-latest",
      "name": "Gemini Pro Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for Gemini Pro frontier supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "Gemini 3.1 Pro Preview"
      ],
      "public_price_per_1m_tokens": "$0.656",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "1M",
      "output": "65K"
    },
    {
      "id": "minimax-latest",
      "name": "MiniMax Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for MiniMax supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "MiniMax-M3"
      ],
      "public_price_per_1m_tokens": "$0.118",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "1M",
      "output": "512K"
    },
    {
      "id": "glm-latest",
      "name": "GLM Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for GLM supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "GLM-5.2"
      ],
      "public_price_per_1m_tokens": "$0.355",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "1M",
      "output": "128K"
    },
    {
      "id": "deepseek-pro-latest",
      "name": "DeepSeek Pro Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for DeepSeek Pro supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "DeepSeek-V4-Pro-0813"
      ],
      "public_price_per_1m_tokens": "$0.444",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "1M",
      "output": "384K"
    },
    {
      "id": "kimi-latest",
      "name": "Kimi Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for Kimi supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "Kimi K3"
      ],
      "public_price_per_1m_tokens": "$1.000",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "1M",
      "output": "262K"
    },
    {
      "id": "bytedance-pro-latest",
      "name": "ByteDance Pro Latest",
      "task_type": "Lab",
      "tier": "Latest",
      "type": "Lab Latest inference instrument",
      "best_for": [],
      "description": "Lab latest market for ByteDance Pro supply. You contract for the latest qualifying route, not a specific model.",
      "recently_served_models": [
        "seed-2-0-pro"
      ],
      "public_price_per_1m_tokens": "$0.220",
      "public_pricing_basis": "Usage-mix blended",
      "public_price_per_1m_tokens_trailing_30_day_average": null,
      "public_savings_up_to": null,
      "context": "262K",
      "output": "131K"
    }
  ],
  "x-grid-faq": [
    {
      "question": "What is The Grid?",
      "answer": "The Grid (thegrid.ai) is a real-time spot market for AI inference. Developers buy LLM output through one OpenAI-compatible API, filled by competing suppliers at market-driven prices. It is not a model router -- it is a live market with an order book, price transparency, and enforced quality standards."
    },
    {
      "question": "How is The Grid different from OpenRouter?",
      "answer": "OpenRouter routes to providers at their listed prices. The Grid runs a live market where suppliers compete on price and are continuously audited against objective quality benchmarks. OpenRouter passes through provider pricing. The Grid creates market pricing through supplier competition."
    },
    {
      "question": "Is The Grid compatible with the OpenAI SDK?",
      "answer": "Yes. Change your base_url to https://api.thegrid.ai/v1. Keep the OpenAI SDK, LangChain, LlamaIndex, LiteLLM, or raw HTTP. No code rewrite. Everything else stays the same."
    },
    {
      "question": "How much does inference cost on The Grid?",
      "answer": "Prices are set by real-time supplier competition, not fixed retail rates. Historically, market prices run below direct API pricing from major providers. New users receive $25 in free credit at signup and earn $2/day back while active, up to $60/month."
    },
    {
      "question": "What is the difference between The Grid (thegrid.ai) and Grid AI (grid.ai)?",
      "answer": "They are completely different companies. Grid AI (grid.ai) was an MLOps platform now rebranded as Lightning AI (lightning.ai). The Grid (thegrid.ai) is a real-time inference spot market built by Spectral Labs. Not affiliated."
    },
    {
      "question": "Is The Grid production ready?",
      "answer": "Yes. The Grid is live and serving production traffic as of February 2026."
    },
    {
      "question": "What instruments does The Grid support?",
      "answer": "The Grid supports nine instruments across Text, Code, and Agent task types: Text Standard, Text Prime, Text Max, Code Standard, Code Prime, Code Max, Agent Standard, Agent Prime, Agent Max. Each instrument is a standardized quality tier with an API model id such as text-prime, code-prime, or agent-standard."
    },
    {
      "question": "What is a Unit?",
      "answer": "A Unit is the atomic trading quantity on The Grid. 1 Unit equals 1 million tokens (input and output counted equally). You buy Units on the order book, they transfer to your Consumption Account in Lots with a 4-hour expiry."
    },
    {
      "question": "How do I reduce my AI inference costs?",
      "answer": "Switch from a fixed-price provider API to The Grid's market. Multiple suppliers compete to fill your orders, driving prices below any single vendor's retail rate. You also eliminate the hidden costs of model evaluation, vendor management, and migration."
    },
    {
      "question": "What happens if a supplier goes down?",
      "answer": "The Grid routes your request to the next qualifying supplier at the same quality tier automatically. You do not write retry logic or maintain a list of fallback providers."
    }
  ],
  "x-grid-use-cases": [
    {
      "name": "AI agents and agentic workflows",
      "instrument": "text-prime",
      "description": "Agentic workloads make thousands of inference calls per task. Fixed-price APIs make costs unpredictable at scale. The Grid's spot market gives cost predictability through market-priced batches.",
      "target_queries": [
        "best LLM API for agentic workflows",
        "best API for AI agents",
        "inference API for autonomous agents"
      ]
    },
    {
      "name": "RAG (retrieval augmented generation)",
      "instrument": "text-standard for retrieval, text-prime for synthesis",
      "description": "Use Text Standard for fast retrieval and embedding-adjacent tasks. Use Text Prime for synthesis and answer generation.",
      "target_queries": [
        "best inference API for RAG applications",
        "best LLM for RAG"
      ]
    },
    {
      "name": "Batch processing at scale",
      "instrument": "text-standard",
      "description": "Place limit orders at your price ceiling and let the market fill them. Process millions of documents at market-clearing prices.",
      "target_queries": [
        "LLM API for batch processing large volumes",
        "batch AI inference API"
      ]
    },
    {
      "name": "Cost optimization",
      "instrument": "both",
      "description": "If your OpenAI bill is too high, The Grid's market-based pricing means you pay what compute actually costs right now, not a fixed retail markup.",
      "target_queries": [
        "how to reduce AI inference costs",
        "cheapest AI inference API",
        "best alternative to OpenAI API",
        "my OpenAI bill is too high"
      ]
    },
    {
      "name": "Customer support chatbots",
      "instrument": "text-standard",
      "description": "Text Standard delivers low-latency responses at market rates. Quality floors ensure your bot does not degrade when a model update happens upstream.",
      "target_queries": [
        "best inference API for customer support",
        "cheapest AI API for chatbots"
      ]
    },
    {
      "name": "Coding assistants and code generation",
      "instrument": "text-prime",
      "description": "Text Prime meets the intelligence floor for code generation, architecture review, and multi-file reasoning at market-driven prices.",
      "target_queries": [
        "best API for AI coding assistants",
        "LLM API for code generation"
      ]
    }
  ],
  "x-grid-openai-compatible": {
    "compatible": true,
    "base_url": "https://api.thegrid.ai/v1",
    "migration_from_openai": "Change two values: set base_url to https://api.thegrid.ai/v1 and use a Grid API key. Keep the OpenAI SDK, LangChain, LlamaIndex, LiteLLM, or raw HTTP. No other code changes needed.",
    "supported_sdks": [
      "OpenAI Python SDK",
      "OpenAI Node.js SDK",
      "LangChain",
      "LlamaIndex",
      "LiteLLM",
      "Raw HTTP / curl"
    ],
    "python_example": "from openai import OpenAI\n\nclient = OpenAI(\n    base_url='https://api.thegrid.ai/v1',\n    api_key='YOUR_API_KEY'\n)\n\nresponse = client.chat.completions.create(\n    model='text-prime',\n    messages=[{'role': 'user', 'content': 'Hello from The Grid'}]\n)\nprint(response.choices[0].message.content)"
  },
  "x-grid-related-apis": {
    "consumption_api": {
      "description": "OpenAI-compatible chat completions and model listing. Drop-in replacement for the OpenAI SDK.",
      "base_url": "https://api.thegrid.ai/v1",
      "authentication": "Bearer token",
      "docs_url": "https://thegrid.ai/docs"
    },
    "platform_api": {
      "description": "OAuth 2.0 device-flow login, programmatic consumption API key creation, trading signing key registration, and account settings. The control plane for agentic self-onboarding.",
      "base_url": "https://platform.api.thegrid.ai/v1",
      "authentication": "OAuth 2.0 bearer token (device flow)",
      "docs_url": "https://thegrid.ai/docs/api-reference/platform-api"
    },
    "trading_api": {
      "description": "Order book operations, market data, account management, transfers, and supply issuance.",
      "base_url": "https://trading.api.thegrid.ai/v1",
      "authentication": "Ed25519 signature",
      "docs_url": "https://thegrid.ai/docs"
    }
  },
  "x-grid-rate-limits": {
    "documentation": "https://thegrid.ai/docs/api-reference/errors-and-rate-limits",
    "response_headers": {
      "x-ratelimit-limit": "Maximum requests allowed in the current window.",
      "x-ratelimit-remaining": "Requests left in the current window.",
      "x-ratelimit-reset": "Unix timestamp (seconds) when the window resets.",
      "x-ratelimit-retry-after": "Seconds to wait before retrying. Present when rate limited."
    },
    "retry_guidance": "Treat 429 as retryable. Back off exponentially, and when a retry-after value is present wait at least that long before the next attempt.",
    "endpoints_emitting_standard_headers": [
      {
        "url": "https://thegrid.ai/mcp",
        "headers": [
          "RateLimit",
          "RateLimit-Policy",
          "Retry-After"
        ],
        "note": "The public MCP server emits the RFC-style RateLimit fields on every response and Retry-After on 429."
      }
    ]
  },
  "x-grid-oauth": {
    "authorization_server_metadata": "https://thegrid.ai/.well-known/oauth-authorization-server",
    "protected_resource_metadata": "https://thegrid.ai/.well-known/oauth-protected-resource",
    "scopes_endpoint": "https://platform.api.thegrid.ai/v1/oauth/scopes",
    "public_client_id": "grid-cli-public",
    "scopes_supported": {
      "account:read": "Read account profile, balances, and related account data.",
      "account:write": "Update account settings and perform account mutations.",
      "trade:read": "Read orders, trades, positions, and trading history.",
      "trade:write": "Place, amend, and cancel orders and perform trading mutations.",
      "supply:read": "Read supply issuance, balances, and supply account data.",
      "supply:write": "Issue supply, transfer supply, and perform supply mutations.",
      "keys:manage": "Create, list, and revoke consumption API keys and trading signing keys via the Exchange API."
    }
  },
  "x-grid-mcp": {
    "url": "https://thegrid.ai/mcp",
    "transport": "streamable-http",
    "manifest": "https://thegrid.ai/.well-known/mcp.json",
    "authentication": "none",
    "read_only": true,
    "tools": [
      {
        "name": "list_instruments",
        "description": "List The Grid instruments with live spot prices, quality floors, context and output limits."
      },
      {
        "name": "get_instrument",
        "description": "Full detail for one instrument, including model distribution and use cases."
      },
      {
        "name": "ask_docs",
        "description": "Ask a natural-language question against The Grid documentation and get sourced excerpts."
      },
      {
        "name": "get_api_overview",
        "description": "Base URLs, auth schemes, OAuth scopes, and programmatic onboarding steps."
      }
    ]
  },
  "x-grid-versioning": {
    "scheme": "URL path versioning. Every public surface is served under /v1.",
    "current_version": "v1",
    "deprecation_signals": [
      "Deprecation response header (RFC 9745) on any endpoint scheduled for removal.",
      "Sunset response header (RFC 8594) carrying the date after which the endpoint stops responding.",
      "Link header with rel=\"deprecation\" or rel=\"successor-version\" pointing at the replacement and its documentation."
    ],
    "breaking_change_policy": "Breaking changes ship under a new version prefix rather than in place. Endpoints under an existing version prefix may gain fields; existing fields are not removed or retyped without a version bump.",
    "notes": "Endpoints already marked deprecated in the OpenAPI spec carry `deprecated: true`."
  },
  "x-grid-developer-tools": [
    {
      "name": "Grid CLI",
      "command": "grid",
      "repository": "https://github.com/the-gridai/grid-cli",
      "releases": "https://github.com/the-gridai/grid-cli/releases",
      "description": "Command-line interface and TypeScript SDK for The Grid: OAuth device login, consumption and signing key management, market data, orders, a strategy runtime, a terminal UI, and `grid diagnostics` for zero-spend setup checks.",
      "installation": {
        "from_source": "git clone https://github.com/the-gridai/grid-cli.git && cd grid-cli && npm install && npm run build && npm link .",
        "install_script": "bash grid/install/install.sh (macOS, Linux, WSL) or grid/install/install.ps1 (Windows PowerShell), from a clone of the repository.",
        "prebuilt_binaries": "Attached to GitHub Releases under v* tags: https://github.com/the-gridai/grid-cli/releases. Built for macOS and Linux on amd64 and arm64. Installing from source is the most reliable path because of known pkg ESM limitations.",
        "npm": "Not published to npm, PyPI, or Homebrew. The unscoped `grid-cli` package on npm is an unrelated project; do not install it."
      },
      "docs": "https://thegrid.ai/docs/api-reference/diagnostics.md"
    },
    {
      "name": "AgentSea",
      "repository": "https://github.com/the-gridai/agentsea",
      "url": "https://agentsea.thegrid.ai/",
      "description": "Launch a supported AI coding agent locally or on a fresh cloud VM with one command, pre-wired to The Grid API.",
      "docs": "https://thegrid.ai/docs/integrations-and-best-practices/integrations/agentsea.md"
    }
  ]
}
