{
  "openapi": "3.0.3",
  "info": {
    "title": "The Grid API -- AI Inference Spot Market",
    "description": "# 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---\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"
    },
    "x-logo": {
      "url": "https://thegrid.ai/logo.png",
      "altText": "The Grid -- Real-Time AI Inference Spot Market"
    }
  },
  "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://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 specification you selected (text-prime for reasoning depth, text-standard for speed). 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-prime (quality-optimized for agents, RAG, reasoning) and text-standard (speed-optimized for classification, summarization, batch processing). 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 Prime (quality-optimized) and Text Standard (speed-optimized). 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."
    }
  ],
  "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\u2011time 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\u2011per\u2011call, subscription, or platform\u2011as\u2011a\u2011service). Moreover, a market facilitates the aggregation of demand across diverse industries\u2014healthcare, finance, retail, autonomous systems\u2014allowing providers to achieve economies of scale, standardize APIs, and ensure compliance and security standards. Without such a marketplace, inference would remain a fragmented, research\u2011only 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 include text-prime (quality-optimized for deep reasoning, agents, and long-form work) and text-standard (speed-optimized for classification, summarization, and batch processing). 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.\n\nEach instrument includes its ID, display name, and other 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-prime",
                      "object": "model",
                      "display_name": "Text Prime",
                      "created": 1687882411,
                      "owned_by": "The Grid"
                    },
                    {
                      "id": "text-standard",
                      "object": "model",
                      "display_name": "Text Standard",
                      "created": 1706037777,
                      "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)"
        }
      ]
    }
  },
  "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)"
      }
    },
    "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-prime",
              "object": "model",
              "display_name": "Text Prime",
              "created": 1687882411,
              "owned_by": "The Grid"
            },
            {
              "id": "text-standard",
              "object": "model",
              "display_name": "Text Standard",
              "created": 1709251200,
              "owned_by": "The Grid"
            }
          ]
        }
      },
      "Model": {
        "title": "Model",
        "description": "An LLM model available for use",
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "description": "The model identifier to use in API requests.\nFormat is typically `provider/model-name`.",
            "example": "text-prime"
          },
          "object": {
            "type": "string",
            "description": "The object type, always \"model\"",
            "enum": [
              "model"
            ]
          },
          "display_name": {
            "type": "string",
            "description": "Human-readable name for the model",
            "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)"
          }
        }
      }
    },
    "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 quality contracts called Instruments and consume inference through a single OpenAI-compatible API 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-prime",
      "name": "Text Prime",
      "type": "Quality-optimized inference",
      "best_for": [
        "AI agents and agentic workflows",
        "RAG synthesis and answer generation",
        "Multi-step reasoning",
        "Code generation and architecture review",
        "Long-form documents",
        "Financial analysis",
        "Legal document analysis"
      ],
      "specification": {
        "intelligence": "High floor on Artificial Analysis Intelligence Index",
        "context_window": "Large",
        "ttft": "Accepts somewhat slower TTFT for reasoning depth"
      }
    },
    {
      "id": "text-standard",
      "name": "Text Standard",
      "type": "Speed-optimized inference",
      "best_for": [
        "Classification and categorization",
        "Summarization",
        "Data extraction",
        "Customer support chatbots",
        "Inline suggestions and autocomplete",
        "Batch processing at scale",
        "Sentiment analysis",
        "Email automation"
      ],
      "specification": {
        "intelligence": "Strong production floor",
        "context_window": "Standard",
        "ttft": "Very low",
        "throughput": "High tokens per second"
      }
    }
  ],
  "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 are Text Prime and Text Standard?",
      "answer": "Text Prime and Text Standard are The Grid's two Instruments -- standardized quality tiers for inference. Text Prime is quality-optimized for complex reasoning, agents, and long-form work. Text Standard is speed-optimized for low-latency classification, summarization, and high-throughput pipelines."
    },
    {
      "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"
    },
    "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"
    }
  }
}
