{
  "openapi": "3.1.0",
  "info": {
    "title": "Dagon Inference API",
    "version": "2026-11-02.2",
    "summary": "OpenAI and Anthropic compatible API for abliterated LLMs, metered per token and paid in USDC.",
    "description": "A metered gateway in front of abliteration.ai, Refuseless and Experiential Labs. Each request goes to the cheapest healthy provider serving its model id and is charged that provider's token rates plus 10% (15% on private leases), in whole micro-USD, with an Ed25519 signed receipt. Live models and prices: GET /v1/models. Static snapshot: https://inference.dagon.so/models.json. Price version 2026-11-02.2.",
    "termsOfService": "https://inference.dagon.so/terms",
    "contact": {
      "name": "Dagon Inference",
      "url": "https://inference.dagon.so/",
      "email": "security@inkwell.finance"
    }
  },
  "servers": [
    {
      "url": "https://inference.dagon.so",
      "description": "Production. OpenAI SDKs use base URL /v1; Anthropic SDKs use the bare origin."
    }
  ],
  "externalDocs": {
    "description": "llms.txt: models, prices and usage for language models",
    "url": "https://inference.dagon.so/llms.txt"
  },
  "tags": [
    {
      "name": "Models"
    },
    {
      "name": "Inference"
    },
    {
      "name": "Keys and credits"
    },
    {
      "name": "Receipts"
    }
  ],
  "paths": {
    "/v1/models": {
      "get": {
        "summary": "List models and prices",
        "tags": [
          "Models"
        ],
        "security": [],
        "description": "The canonical, live catalog: every public model id served by an enabled provider, priced at its cheapest route plus the markup. No key needed.",
        "responses": {
          "200": {
            "description": "The catalog.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "summary": "Chat Completions (OpenAI)",
        "description": "OpenAI Chat Completions. Streaming supported; set max_tokens or max_completion_tokens to cap the hold. Without a key, or with a key short of funds, the 402 carries x402 payment requirements; retry with X-PAYMENT or PAYMENT-SIGNATURE to pay per request in USDC on Solana (network fee paid by the gateway).",
        "externalDocs": {
          "description": "Pay per request with x402 (USDC on Solana)",
          "url": "https://inference.dagon.so/x402-llm-api"
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "dynamic",
            "currency": "USD",
            "min": "0.5",
            "max": "1000"
          }
        },
        "tags": [
          "Inference"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "description": "x402 v1 PaymentPayload, base64 JSON: { x402Version: 1, scheme: \"exact\", network: \"solana\", payload: { transaction } } with a partially signed USDC TransferChecked to the treasury, fee payer `extra.feePayer`.",
            "schema": {
              "type": "string",
              "contentEncoding": "base64"
            }
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "description": "x402 v2 PaymentPayload, base64 JSON: { x402Version: 2, accepted: <one of accepts>, payload: { transaction } }.",
            "schema": {
              "type": "string",
              "contentEncoding": "base64"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "additionalProperties": true,
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "A model id from GET /v1/models.",
                    "examples": [
                      "abliterated-model-large-v2",
                      "deepseek-v4.1-flash-abliterated",
                      "glm-5.3-flash-abliterated",
                      "abliterated-model-large-flash",
                      "abliterated-model"
                    ]
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "role",
                        "content"
                      ],
                      "properties": {
                        "role": {
                          "type": "string"
                        },
                        "content": {
                          "oneOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "additionalProperties": true
                              }
                            }
                          ]
                        }
                      },
                      "additionalProperties": true
                    }
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "max_tokens": {
                    "type": "integer",
                    "maximum": 65536
                  },
                  "max_completion_tokens": {
                    "type": "integer",
                    "maximum": 65536
                  }
                }
              },
              "example": {
                "model": "abliterated-model-large-v2",
                "messages": [
                  {
                    "role": "user",
                    "content": "Hello"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OpenAI Chat Completions response, or a text/event-stream when `stream` is true. Usage is metered from it; the charge is on the receipt.",
            "headers": {
              "x-gateway-request-id": {
                "description": "The gateway's id for this request.",
                "schema": {
                  "type": "string"
                }
              },
              "x-gateway-receipt-id": {
                "description": "Id of the signed receipt for this request; fetch it at /v1/receipts/{id}.",
                "schema": {
                  "type": "string"
                }
              },
              "x-gateway-receipt": {
                "description": "On non-streamed responses: the signed receipt itself, base64url JSON.",
                "schema": {
                  "type": "string"
                }
              },
              "x-payment-response": {
                "description": "After an x402 payment: base64 JSON SettlementResponse (v1 network name) { success, transaction, network, payer, amount }.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "payment-response": {
                "description": "The same SettlementResponse with the CAIP-2 network id (x402 v2).",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-dagon-transaction": {
                "description": "After an x402 payment: the Solana transaction signature.",
                "schema": {
                  "type": "string"
                }
              },
              "x-dagon-key": {
                "description": "After an x402 payment made without a key: the gk_ prepaid key holding the payment minus this request's cost. Every keyless payment from one wallet funds the same key. Reuse it as the bearer key.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "description": "Payment required: no key (`payment_required`; a keyless request whose body would be refused gets it too, at the minimum price, the refusal named in the message), a key short of funds (`insufficient_credits`), or an x402 payment that was refused (an x402 reason such as `invalid_exact_svm_payload_amount_mismatch`, `duplicate_settlement`, `settlement_pending`, or `paid_daily_cap_exceeded`). Lease keys get the error alone. The PAYMENT-REQUIRED object carries the request and response schemas as the x402 Bazaar extension (`extensions.bazaar`).",
            "headers": {
              "payment-required": {
                "description": "x402 v2 PaymentRequired, base64 JSON (schema PaymentRequiredV2).",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "payment-response": {
                "description": "For a refused payment: x402 v2 SettlementResponse with success false and errorReason.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-payment-response": {
                "description": "For a refused payment: the same SettlementResponse with the v1 network name.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-dagon-transaction": {
                "description": "For a payment that was broadcast: its transaction signature.",
                "schema": {
                  "type": "string"
                }
              },
              "x-dagon-key": {
                "description": "With `settlement_pending` on a keyless payment: the key the payment will fund; retry with it and the same payment header.",
                "schema": {
                  "type": "string"
                }
              },
              "retry-after": {
                "description": "With `settlement_pending`: seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                },
                "example": {
                  "x402Version": 1,
                  "accepts": [
                    {
                      "scheme": "exact",
                      "network": "solana",
                      "maxAmountRequired": "500000",
                      "resource": "https://inference.dagon.so/v1/chat/completions",
                      "description": "One abliterated-model-large-v2 request on Dagon, prepaid at its maximum cost. The unspent rest stays as credit on the key returned once in x-dagon-key and is not refunded; reuse that key. Terms: https://inference.dagon.so/terms",
                      "mimeType": "application/json",
                      "payTo": "9rMdbu4KdLWH2nPXbzhm9HTKaibGZ2ckakQbW1wPh6KK",
                      "maxTimeoutSeconds": 60,
                      "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                      "extra": {
                        "feePayer": "4UZVmNWoetLmDeQnfFFCYrFuN7epN6WgchiDxJ6VVA52"
                      }
                    }
                  ],
                  "error": {
                    "message": "Pay for this request with x402 (USDC on Solana; requirements in `accepts` and the PAYMENT-REQUIRED header), or send an API key as 'Authorization: Bearer <key>'.",
                    "type": "billing_error",
                    "param": null,
                    "code": "payment_required"
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "451": {
            "$ref": "#/components/responses/E451"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "summary": "Responses (OpenAI)",
        "description": "OpenAI Responses API. Served on models whose providers support it (see each model's `endpoints`). Without a key, or with a key short of funds, the 402 carries x402 payment requirements; retry with X-PAYMENT or PAYMENT-SIGNATURE to pay per request in USDC on Solana (network fee paid by the gateway).",
        "externalDocs": {
          "description": "Pay per request with x402 (USDC on Solana)",
          "url": "https://inference.dagon.so/x402-llm-api"
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "dynamic",
            "currency": "USD",
            "min": "0.5",
            "max": "1000"
          }
        },
        "tags": [
          "Inference"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "description": "x402 v1 PaymentPayload, base64 JSON: { x402Version: 1, scheme: \"exact\", network: \"solana\", payload: { transaction } } with a partially signed USDC TransferChecked to the treasury, fee payer `extra.feePayer`.",
            "schema": {
              "type": "string",
              "contentEncoding": "base64"
            }
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "description": "x402 v2 PaymentPayload, base64 JSON: { x402Version: 2, accepted: <one of accepts>, payload: { transaction } }.",
            "schema": {
              "type": "string",
              "contentEncoding": "base64"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "input"
                ],
                "additionalProperties": true,
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "A model id from GET /v1/models.",
                    "examples": [
                      "abliterated-model-large-v2",
                      "deepseek-v4.1-flash-abliterated",
                      "glm-5.3-flash-abliterated",
                      "abliterated-model-large-flash",
                      "abliterated-model"
                    ]
                  },
                  "input": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object",
                          "additionalProperties": true
                        }
                      }
                    ]
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "max_output_tokens": {
                    "type": "integer",
                    "maximum": 65536
                  }
                }
              },
              "example": {
                "model": "abliterated-model-large-v2",
                "input": "Hello"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The OpenAI Responses response, or a text/event-stream when `stream` is true. Usage is metered from it; the charge is on the receipt.",
            "headers": {
              "x-gateway-request-id": {
                "description": "The gateway's id for this request.",
                "schema": {
                  "type": "string"
                }
              },
              "x-gateway-receipt-id": {
                "description": "Id of the signed receipt for this request; fetch it at /v1/receipts/{id}.",
                "schema": {
                  "type": "string"
                }
              },
              "x-gateway-receipt": {
                "description": "On non-streamed responses: the signed receipt itself, base64url JSON.",
                "schema": {
                  "type": "string"
                }
              },
              "x-payment-response": {
                "description": "After an x402 payment: base64 JSON SettlementResponse (v1 network name) { success, transaction, network, payer, amount }.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "payment-response": {
                "description": "The same SettlementResponse with the CAIP-2 network id (x402 v2).",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-dagon-transaction": {
                "description": "After an x402 payment: the Solana transaction signature.",
                "schema": {
                  "type": "string"
                }
              },
              "x-dagon-key": {
                "description": "After an x402 payment made without a key: the gk_ prepaid key holding the payment minus this request's cost. Every keyless payment from one wallet funds the same key. Reuse it as the bearer key.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "description": "Payment required: no key (`payment_required`; a keyless request whose body would be refused gets it too, at the minimum price, the refusal named in the message), a key short of funds (`insufficient_credits`), or an x402 payment that was refused (an x402 reason such as `invalid_exact_svm_payload_amount_mismatch`, `duplicate_settlement`, `settlement_pending`, or `paid_daily_cap_exceeded`). Lease keys get the error alone. The PAYMENT-REQUIRED object carries the request and response schemas as the x402 Bazaar extension (`extensions.bazaar`).",
            "headers": {
              "payment-required": {
                "description": "x402 v2 PaymentRequired, base64 JSON (schema PaymentRequiredV2).",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "payment-response": {
                "description": "For a refused payment: x402 v2 SettlementResponse with success false and errorReason.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-payment-response": {
                "description": "For a refused payment: the same SettlementResponse with the v1 network name.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-dagon-transaction": {
                "description": "For a payment that was broadcast: its transaction signature.",
                "schema": {
                  "type": "string"
                }
              },
              "x-dagon-key": {
                "description": "With `settlement_pending` on a keyless payment: the key the payment will fund; retry with it and the same payment header.",
                "schema": {
                  "type": "string"
                }
              },
              "retry-after": {
                "description": "With `settlement_pending`: seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                },
                "example": {
                  "x402Version": 1,
                  "accepts": [
                    {
                      "scheme": "exact",
                      "network": "solana",
                      "maxAmountRequired": "500000",
                      "resource": "https://inference.dagon.so/v1/responses",
                      "description": "One abliterated-model-large-v2 request on Dagon, prepaid at its maximum cost. The unspent rest stays as credit on the key returned once in x-dagon-key and is not refunded; reuse that key. Terms: https://inference.dagon.so/terms",
                      "mimeType": "application/json",
                      "payTo": "9rMdbu4KdLWH2nPXbzhm9HTKaibGZ2ckakQbW1wPh6KK",
                      "maxTimeoutSeconds": 60,
                      "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                      "extra": {
                        "feePayer": "4UZVmNWoetLmDeQnfFFCYrFuN7epN6WgchiDxJ6VVA52"
                      }
                    }
                  ],
                  "error": {
                    "message": "Pay for this request with x402 (USDC on Solana; requirements in `accepts` and the PAYMENT-REQUIRED header), or send an API key as 'Authorization: Bearer <key>'.",
                    "type": "billing_error",
                    "param": null,
                    "code": "payment_required"
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "451": {
            "$ref": "#/components/responses/E451"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "summary": "Messages (Anthropic)",
        "description": "Anthropic Messages API, for SDKs whose base URL is the bare origin. Served on models whose providers support it (see each model's `endpoints`). Accepts `x-api-key` as well as a bearer token. Without a key, or with a key short of funds, the 402 carries x402 payment requirements; retry with X-PAYMENT or PAYMENT-SIGNATURE to pay per request in USDC on Solana (network fee paid by the gateway).",
        "externalDocs": {
          "description": "Pay per request with x402 (USDC on Solana)",
          "url": "https://inference.dagon.so/x402-llm-api"
        },
        "x-payment-info": {
          "protocols": [
            "x402"
          ],
          "price": {
            "mode": "dynamic",
            "currency": "USD",
            "min": "0.5",
            "max": "1000"
          }
        },
        "tags": [
          "Inference"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          },
          {}
        ],
        "parameters": [
          {
            "name": "X-PAYMENT",
            "in": "header",
            "required": false,
            "description": "x402 v1 PaymentPayload, base64 JSON: { x402Version: 1, scheme: \"exact\", network: \"solana\", payload: { transaction } } with a partially signed USDC TransferChecked to the treasury, fee payer `extra.feePayer`.",
            "schema": {
              "type": "string",
              "contentEncoding": "base64"
            }
          },
          {
            "name": "PAYMENT-SIGNATURE",
            "in": "header",
            "required": false,
            "description": "x402 v2 PaymentPayload, base64 JSON: { x402Version: 2, accepted: <one of accepts>, payload: { transaction } }.",
            "schema": {
              "type": "string",
              "contentEncoding": "base64"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages",
                  "max_tokens"
                ],
                "additionalProperties": true,
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "A model id from GET /v1/models.",
                    "examples": [
                      "abliterated-model-large-v2",
                      "deepseek-v4.1-flash-abliterated",
                      "glm-5.3-flash-abliterated",
                      "abliterated-model-large-flash",
                      "abliterated-model"
                    ]
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "required": [
                        "role",
                        "content"
                      ],
                      "properties": {
                        "role": {
                          "type": "string"
                        },
                        "content": {
                          "oneOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "type": "object",
                                "additionalProperties": true
                              }
                            }
                          ]
                        }
                      },
                      "additionalProperties": true
                    }
                  },
                  "max_tokens": {
                    "type": "integer",
                    "maximum": 65536
                  },
                  "stream": {
                    "type": "boolean"
                  }
                }
              },
              "example": {
                "model": "abliterated-model-large-v2",
                "max_tokens": 1024,
                "messages": [
                  {
                    "role": "user",
                    "content": "Hello"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The Anthropic Messages response, or a text/event-stream when `stream` is true. Usage is metered from it; the charge is on the receipt.",
            "headers": {
              "x-gateway-request-id": {
                "description": "The gateway's id for this request.",
                "schema": {
                  "type": "string"
                }
              },
              "x-gateway-receipt-id": {
                "description": "Id of the signed receipt for this request; fetch it at /v1/receipts/{id}.",
                "schema": {
                  "type": "string"
                }
              },
              "x-gateway-receipt": {
                "description": "On non-streamed responses: the signed receipt itself, base64url JSON.",
                "schema": {
                  "type": "string"
                }
              },
              "x-payment-response": {
                "description": "After an x402 payment: base64 JSON SettlementResponse (v1 network name) { success, transaction, network, payer, amount }.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "payment-response": {
                "description": "The same SettlementResponse with the CAIP-2 network id (x402 v2).",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-dagon-transaction": {
                "description": "After an x402 payment: the Solana transaction signature.",
                "schema": {
                  "type": "string"
                }
              },
              "x-dagon-key": {
                "description": "After an x402 payment made without a key: the gk_ prepaid key holding the payment minus this request's cost. Every keyless payment from one wallet funds the same key. Reuse it as the bearer key.",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "402": {
            "description": "Payment required: no key (`payment_required`; a keyless request whose body would be refused gets it too, at the minimum price, the refusal named in the message), a key short of funds (`insufficient_credits`), or an x402 payment that was refused (an x402 reason such as `invalid_exact_svm_payload_amount_mismatch`, `duplicate_settlement`, `settlement_pending`, or `paid_daily_cap_exceeded`). Lease keys get the error alone. The PAYMENT-REQUIRED object carries the request and response schemas as the x402 Bazaar extension (`extensions.bazaar`).",
            "headers": {
              "payment-required": {
                "description": "x402 v2 PaymentRequired, base64 JSON (schema PaymentRequiredV2).",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "payment-response": {
                "description": "For a refused payment: x402 v2 SettlementResponse with success false and errorReason.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-payment-response": {
                "description": "For a refused payment: the same SettlementResponse with the v1 network name.",
                "schema": {
                  "type": "string",
                  "contentEncoding": "base64"
                }
              },
              "x-dagon-transaction": {
                "description": "For a payment that was broadcast: its transaction signature.",
                "schema": {
                  "type": "string"
                }
              },
              "x-dagon-key": {
                "description": "With `settlement_pending` on a keyless payment: the key the payment will fund; retry with it and the same payment header.",
                "schema": {
                  "type": "string"
                }
              },
              "retry-after": {
                "description": "With `settlement_pending`: seconds to wait before retrying.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PaymentRequired"
                },
                "example": {
                  "x402Version": 1,
                  "accepts": [
                    {
                      "scheme": "exact",
                      "network": "solana",
                      "maxAmountRequired": "500000",
                      "resource": "https://inference.dagon.so/v1/messages",
                      "description": "One abliterated-model-large-v2 request on Dagon, prepaid at its maximum cost. The unspent rest stays as credit on the key returned once in x-dagon-key and is not refunded; reuse that key. Terms: https://inference.dagon.so/terms",
                      "mimeType": "application/json",
                      "payTo": "9rMdbu4KdLWH2nPXbzhm9HTKaibGZ2ckakQbW1wPh6KK",
                      "maxTimeoutSeconds": 60,
                      "asset": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
                      "extra": {
                        "feePayer": "4UZVmNWoetLmDeQnfFFCYrFuN7epN6WgchiDxJ6VVA52"
                      }
                    }
                  ],
                  "type": "error",
                  "error": {
                    "type": "invalid_request_error",
                    "message": "Pay for this request with x402 (USDC on Solana; requirements in `accepts` and the PAYMENT-REQUIRED header), or send an API key as 'Authorization: Bearer <key>'.",
                    "code": "payment_required"
                  }
                }
              }
            }
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "413": {
            "$ref": "#/components/responses/E413"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "451": {
            "$ref": "#/components/responses/E451"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/keys": {
      "post": {
        "summary": "Create a prepaid key",
        "tags": [
          "Keys and credits"
        ],
        "security": [],
        "description": "Creates a gk_ account key with no email or password. The secret is returned once; only its hash is stored, so a lost key cannot be recovered. Rate limited per address.",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string",
                    "maxLength": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The new key.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "key",
                    "data"
                  ],
                  "properties": {
                    "key": {
                      "type": "string",
                      "description": "The secret, shown once.",
                      "examples": [
                        "gk_..."
                      ]
                    },
                    "data": {
                      "$ref": "#/components/schemas/Key"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "451": {
            "$ref": "#/components/responses/E451"
          }
        }
      }
    },
    "/v1/credits": {
      "get": {
        "summary": "Balance of the calling key, in USD",
        "tags": [
          "Keys and credits"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "responses": {
          "200": {
            "description": "Funded, used and available amounts.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "type": "object",
                      "properties": {
                        "total_credits": {
                          "type": "number"
                        },
                        "total_usage": {
                          "type": "number"
                        },
                        "available": {
                          "type": "number"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          }
        }
      }
    },
    "/v1/credits/checkout": {
      "post": {
        "summary": "Start a USDC top up",
        "tags": [
          "Keys and credits"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "description": "Returns a hosted checkout link that takes USDC. The credit posts when the payment settles. $5 to $1000 per top up, in whole cents. Lease keys cannot be topped up.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_usd"
                ],
                "properties": {
                  "amount_usd": {
                    "oneOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      }
                    ],
                    "description": "Dollars in whole cents.",
                    "examples": [
                      20
                    ]
                  }
                }
              },
              "example": {
                "amount_usd": 20
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Checkout session.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "session_id",
                    "url"
                  ],
                  "properties": {
                    "session_id": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string",
                      "format": "uri"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "451": {
            "$ref": "#/components/responses/E451"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/credits/purchase": {
      "post": {
        "summary": "Buy credits from a Solana wallet (no browser)",
        "tags": [
          "Keys and credits"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "description": "For agents: opens a top up of the calling key and returns the unsigned USDC transaction for payer_wallet. Sign it with that wallet, send it to Solana, then call /v1/credits/purchase/confirm. When fee_sponsored is true the transaction already carries the fee payer's signature (keep it) and the wallet needs no SOL; otherwise the wallet pays the network fee. The transaction's blockhash expires about a minute after this call: if it does, call again. $5 to $1000 per top up, in whole cents; no email. Refused from sanctioned wallets (403 payment_refused) and blocked locations (451).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "amount_usd",
                  "payer_wallet"
                ],
                "properties": {
                  "amount_usd": {
                    "oneOf": [
                      {
                        "type": "number"
                      },
                      {
                        "type": "string"
                      }
                    ],
                    "description": "Dollars in whole cents.",
                    "examples": [
                      20
                    ]
                  },
                  "payer_wallet": {
                    "type": "string",
                    "description": "Base58 address of the Solana wallet that pays and signs. It must hold the USDC.",
                    "examples": [
                      "GmaDrppBC7P5ARKV8g3djiwP89vz1jLK23V2GBjuAEGB"
                    ]
                  },
                  "chain": {
                    "const": "solana",
                    "default": "solana"
                  }
                }
              },
              "example": {
                "amount_usd": 20,
                "payer_wallet": "GmaDrppBC7P5ARKV8g3djiwP89vz1jLK23V2GBjuAEGB",
                "chain": "solana"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The transaction to sign.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Purchase"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "451": {
            "$ref": "#/components/responses/E451"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/credits/purchase/confirm": {
      "post": {
        "summary": "Confirm a wallet purchase and credit the key",
        "tags": [
          "Keys and credits"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "description": "Send the signature of the transaction you sent. The payment service verifies it on chain once it is finalized (this call can take up to about 45 seconds) and the key is credited at once. 202 means not finalized yet: call again after Retry-After. Instead of signature, a fee-sponsored purchase may send signed_transaction (base64) for the payment service to broadcast. Idempotent.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "purchase_id"
                ],
                "properties": {
                  "purchase_id": {
                    "type": "string"
                  },
                  "signature": {
                    "type": "string",
                    "description": "Base58 transaction signature."
                  },
                  "signed_transaction": {
                    "type": "string",
                    "description": "Base64 signed transaction (fee-sponsored purchases only)."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Credited.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PurchaseCredited"
                }
              }
            }
          },
          "202": {
            "description": "Not finalized yet; call again.",
            "headers": {
              "retry-after": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "purchase_id",
                    "status"
                  ],
                  "properties": {
                    "purchase_id": {
                      "type": "string"
                    },
                    "status": {
                      "const": "pending"
                    },
                    "detail": {
                      "type": "string"
                    },
                    "retry_after_s": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/E400"
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "403": {
            "$ref": "#/components/responses/E403"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "451": {
            "$ref": "#/components/responses/E451"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          },
          "503": {
            "$ref": "#/components/responses/E503"
          }
        }
      }
    },
    "/v1/credits/purchase/{id}": {
      "get": {
        "summary": "Status of a wallet purchase",
        "tags": [
          "Keys and credits"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "description": "open: awaiting payment; credited; expired; refused: paid from a sanctioned wallet and held; pending: paid, not yet credited. Reading the status also credits a purchase that was paid without a confirm.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The purchase.",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/PurchaseCredited"
                    },
                    {
                      "type": "object",
                      "required": [
                        "purchase_id",
                        "status",
                        "amount_total",
                        "currency",
                        "balance"
                      ],
                      "properties": {
                        "purchase_id": {
                          "type": "string"
                        },
                        "status": {
                          "enum": [
                            "open",
                            "expired",
                            "refused",
                            "pending"
                          ]
                        },
                        "amount_total": {
                          "type": "number"
                        },
                        "currency": {
                          "const": "usdc"
                        },
                        "expires_at": {
                          "type": [
                            "string",
                            "null"
                          ],
                          "format": "date-time"
                        },
                        "balance": {
                          "type": "number"
                        }
                      }
                    }
                  ]
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          },
          "429": {
            "$ref": "#/components/responses/E429"
          },
          "502": {
            "$ref": "#/components/responses/E502"
          }
        }
      }
    },
    "/v1/receipts/{id}": {
      "get": {
        "summary": "Fetch a signed receipt",
        "tags": [
          "Receipts"
        ],
        "security": [
          {
            "bearer": []
          },
          {
            "apiKey": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/E401"
          },
          "404": {
            "$ref": "#/components/responses/E404"
          }
        }
      }
    },
    "/v1/receipts/verify": {
      "post": {
        "summary": "Verify a receipt",
        "tags": [
          "Receipts"
        ],
        "security": [],
        "description": "Checks the Ed25519 signature, the gateway identity and the price arithmetic against the published rates. No key needed.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/Receipt"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Result.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "valid"
                  ],
                  "properties": {
                    "valid": {
                      "type": "boolean"
                    },
                    "reason": {
                      "type": "string"
                    }
                  },
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    },
    "/v1/identity": {
      "get": {
        "summary": "The gateway's receipt signing key",
        "tags": [
          "Receipts"
        ],
        "security": [],
        "responses": {
          "200": {
            "description": "Signing identity.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "gateway_id": {
                      "type": "string"
                    },
                    "algorithm": {
                      "const": "ed25519"
                    },
                    "public_key": {
                      "type": "string"
                    },
                    "price_version": {
                      "type": "string"
                    },
                    "markup_bps": {
                      "type": "integer"
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "A gk_ prepaid key or an lk_ private lease key."
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "The same key, as Anthropic SDKs send it."
      }
    },
    "schemas": {
      "Rates": {
        "type": "object",
        "required": [
          "inputPerMtok",
          "cachedInputPerMtok",
          "outputPerMtok"
        ],
        "description": "Micro-USD per 1,000,000 tokens with the markup included (fractions allowed). Divide by 1,000,000 for USD.",
        "properties": {
          "inputPerMtok": {
            "type": "number"
          },
          "cachedInputPerMtok": {
            "type": "number"
          },
          "outputPerMtok": {
            "type": "number"
          }
        }
      },
      "Model": {
        "type": "object",
        "required": [
          "id",
          "object",
          "owned_by",
          "name",
          "description",
          "deprecated",
          "context_length",
          "max_output_tokens",
          "input_modalities",
          "pricing_per_mtok_micros",
          "providers",
          "routes",
          "endpoints"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "abliterated-model-large-v2",
              "deepseek-v4.1-flash-abliterated",
              "glm-5.3-flash-abliterated",
              "abliterated-model-large-flash",
              "abliterated-model"
            ]
          },
          "object": {
            "const": "model"
          },
          "created": {
            "type": "integer"
          },
          "owned_by": {
            "type": "string",
            "description": "The cheapest provider, whose rates are shown."
          },
          "name": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "deprecated": {
            "type": "boolean"
          },
          "context_length": {
            "type": "integer"
          },
          "max_output_tokens": {
            "type": "integer",
            "description": "The most this gateway accepts for this model."
          },
          "input_modalities": {
            "type": "array",
            "items": {
              "enum": [
                "text",
                "image"
              ]
            }
          },
          "pricing_per_mtok_micros": {
            "$ref": "#/components/schemas/Rates"
          },
          "providers": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "routes": {
            "type": "integer"
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "The inference paths this model is served on."
          }
        }
      },
      "ModelList": {
        "type": "object",
        "required": [
          "object",
          "data",
          "price_version",
          "prices_updated_at",
          "markup_bps"
        ],
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Model"
            }
          },
          "price_version": {
            "type": "string",
            "description": "The active price schedule; new receipts pin it. Changes when a provider changes its prices."
          },
          "prices_updated_at": {
            "type": "integer",
            "description": "When the active price version took effect, in milliseconds since the Unix epoch."
          },
          "markup_bps": {
            "type": "integer"
          }
        }
      },
      "Key": {
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "id": {
            "type": "string"
          },
          "kind": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "created_at": {
            "type": "integer"
          },
          "funded_micros": {
            "type": "integer"
          },
          "spent_micros": {
            "type": "integer"
          },
          "available_micros": {
            "type": "integer"
          }
        }
      },
      "PaymentRequirements": {
        "type": "object",
        "description": "x402 v1 PaymentRequirements for the exact scheme on Solana mainnet. Amounts are USDC base units (micro-USD).",
        "required": [
          "scheme",
          "network",
          "maxAmountRequired",
          "resource",
          "description",
          "mimeType",
          "payTo",
          "maxTimeoutSeconds",
          "asset",
          "extra"
        ],
        "properties": {
          "scheme": {
            "const": "exact"
          },
          "network": {
            "const": "solana"
          },
          "maxAmountRequired": {
            "type": "string",
            "description": "Keyless: this request's maximum cost, at least $0.5. Keyed: the shortfall, at least $1."
          },
          "resource": {
            "type": "string",
            "format": "uri"
          },
          "description": {
            "type": "string"
          },
          "mimeType": {
            "type": "string"
          },
          "payTo": {
            "const": "9rMdbu4KdLWH2nPXbzhm9HTKaibGZ2ckakQbW1wPh6KK"
          },
          "maxTimeoutSeconds": {
            "type": "integer"
          },
          "asset": {
            "const": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
          },
          "extra": {
            "type": "object",
            "properties": {
              "feePayer": {
                "type": "string",
                "description": "The gateway's fee payer; present when it pays network fees. Use it as the transaction's fee payer."
              }
            }
          },
          "outputSchema": {
            "type": "object",
            "description": "For discovery (v1 Bazaar): `input` ({ type: \"http\", method: \"POST\", bodyType: \"json\", bodyFields }) and `output` (the response's JSON Schema).",
            "properties": {
              "input": {
                "type": "object"
              },
              "output": {
                "type": "object"
              }
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "The usual error object (see Error) plus the x402 v1 PaymentRequired fields.",
        "allOf": [
          {
            "$ref": "#/components/schemas/Error"
          },
          {
            "type": "object",
            "required": [
              "x402Version",
              "accepts"
            ],
            "properties": {
              "x402Version": {
                "const": 1
              },
              "accepts": {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/PaymentRequirements"
                }
              }
            }
          }
        ]
      },
      "PaymentRequiredV2": {
        "type": "object",
        "description": "x402 v2 PaymentRequired, sent base64 in the PAYMENT-REQUIRED header of every x402 402.",
        "required": [
          "x402Version",
          "resource",
          "accepts"
        ],
        "properties": {
          "x402Version": {
            "const": 2
          },
          "error": {
            "type": "string"
          },
          "resource": {
            "type": "object",
            "required": [
              "url",
              "description",
              "mimeType"
            ],
            "properties": {
              "url": {
                "type": "string",
                "format": "uri"
              },
              "description": {
                "type": "string"
              },
              "mimeType": {
                "type": "string"
              }
            }
          },
          "accepts": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "scheme",
                "network",
                "amount",
                "asset",
                "payTo",
                "maxTimeoutSeconds",
                "extra"
              ],
              "properties": {
                "scheme": {
                  "const": "exact"
                },
                "network": {
                  "const": "solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp"
                },
                "amount": {
                  "type": "string",
                  "description": "USDC base units (micro-USD)."
                },
                "asset": {
                  "const": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v"
                },
                "payTo": {
                  "const": "9rMdbu4KdLWH2nPXbzhm9HTKaibGZ2ckakQbW1wPh6KK"
                },
                "maxTimeoutSeconds": {
                  "type": "integer"
                },
                "extra": {
                  "type": "object",
                  "properties": {
                    "feePayer": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "extensions": {
            "type": "object",
            "description": "x402 extensions. `bazaar` (x402 Bazaar discovery extension): `info` holds an example request ({ type: \"http\", method: \"POST\", bodyType: \"json\", body }) and response ({ type: \"json\", example }); `schema` is the JSON Schema of `info`, with the body's schema at properties.input.properties.body and the response's at properties.output.properties.example.",
            "properties": {
              "bazaar": {
                "type": "object",
                "required": [
                  "info",
                  "schema"
                ],
                "properties": {
                  "info": {
                    "type": "object"
                  },
                  "schema": {
                    "type": "object"
                  }
                }
              }
            }
          }
        }
      },
      "SettlementResponse": {
        "type": "object",
        "description": "x402 SettlementResponse, base64 in PAYMENT-RESPONSE (CAIP-2 network) and X-PAYMENT-RESPONSE (v1 network name).",
        "required": [
          "success",
          "transaction",
          "network",
          "payer"
        ],
        "properties": {
          "success": {
            "type": "boolean"
          },
          "transaction": {
            "type": "string"
          },
          "network": {
            "type": "string"
          },
          "payer": {
            "type": "string"
          },
          "amount": {
            "type": "string"
          },
          "errorReason": {
            "type": "string"
          },
          "errorMessage": {
            "type": "string"
          }
        }
      },
      "Purchase": {
        "type": "object",
        "required": [
          "purchase_id",
          "amount_total",
          "currency",
          "chain",
          "payer_wallet",
          "unsigned_transaction",
          "blockhash",
          "last_valid_block_height",
          "fee_sponsored",
          "expires_at",
          "confirm_url"
        ],
        "properties": {
          "purchase_id": {
            "type": "string"
          },
          "amount_total": {
            "type": "number",
            "description": "USD (paid as the same amount of USDC)."
          },
          "currency": {
            "const": "usdc"
          },
          "chain": {
            "const": "solana"
          },
          "payer_wallet": {
            "type": "string"
          },
          "unsigned_transaction": {
            "type": "string",
            "description": "Base64 Solana transaction for payer_wallet to sign; deserializes as a VersionedTransaction."
          },
          "blockhash": {
            "type": "string"
          },
          "last_valid_block_height": {
            "type": "integer",
            "description": "The transaction is valid until this block height (about a minute)."
          },
          "fee_sponsored": {
            "type": "boolean",
            "description": "True: the payment service's fee payer has signed and pays the network fee and any account rent; the wallet needs no SOL."
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time",
            "description": "When the purchase itself expires."
          },
          "confirm_url": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "PurchaseCredited": {
        "type": "object",
        "required": [
          "purchase_id",
          "status",
          "amount_total",
          "currency",
          "credited_usd",
          "balance"
        ],
        "properties": {
          "purchase_id": {
            "type": "string"
          },
          "status": {
            "const": "credited"
          },
          "amount_total": {
            "type": "number"
          },
          "currency": {
            "const": "usdc"
          },
          "credited_usd": {
            "type": "number"
          },
          "balance": {
            "type": "number",
            "description": "The key's available balance in USD."
          }
        }
      },
      "Receipt": {
        "type": "object",
        "required": [
          "payload",
          "signature"
        ],
        "properties": {
          "payload": {
            "type": "object",
            "additionalProperties": true,
            "properties": {
              "v": {},
              "id": {},
              "gateway": {},
              "key_id": {},
              "created": {},
              "model": {},
              "provider": {},
              "endpoint": {},
              "usage": {},
              "usage_source": {},
              "price_version": {},
              "markup_bps": {},
              "charged_micros": {},
              "output_sha256": {},
              "upstream_request_id": {}
            }
          },
          "signature": {
            "type": "string"
          }
        }
      },
      "Error": {
        "description": "OpenAI shape on /v1/chat/completions, /v1/responses and the rest of the API; Anthropic shape ({ type: \"error\", error: { type, message } }) on /v1/messages.",
        "type": "object",
        "additionalProperties": true,
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ]
              },
              "code": {
                "type": "string"
              }
            }
          }
        }
      }
    },
    "responses": {
      "E400": {
        "description": "Invalid request: bad JSON, an unsupported parameter (web search is refused), an endpoint the model is not served on, or an output cap over the limit.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E401": {
        "description": "Missing, invalid, disabled or expired key.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E402": {
        "description": "The key's available balance does not cover the hold for this request.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E403": {
        "description": "Payment refused: a wallet that signed the payment is on the OFAC sanctions list (`payment_refused`). Nothing was broadcast.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E404": {
        "description": "Unknown model id or resource.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E413": {
        "description": "Request body too large.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E429": {
        "description": "Rate limited; see Retry-After.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E451": {
        "description": "Not available in the caller's location (`location_blocked`).",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E502": {
        "description": "The upstream provider could not be reached; nothing was charged.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "E503": {
        "description": "Busy or paused, or payments temporarily unavailable (`payment_unavailable`, `sanctions_unavailable`, `geo_unavailable`); see Retry-After.",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    }
  }
}
