{
  "openapi": "3.1.0",
  "jsonSchemaDialect": "https://json-schema.org/draft/2020-12/schema",
  "info": {
    "title": "DeepSeek Text API",
    "version": "1.1.0",
    "description": "OpenAI-compatible text API backed by the deployed OpenCode adapter. Local per-key quotas and real usage metadata. This contract covers only the listed methods; tools, images, audio, Responses API, files and embeddings are not implemented."
  },
  "servers": [
    {
      "url": "https://accs.digital",
      "description": "Production HTTPS endpoint"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/health": {
      "get": {
        "operationId": "getHealth",
        "summary": "Adapter liveness without a model call",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Health"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/capabilities": {
      "get": {
        "operationId": "getCapabilities",
        "summary": "Discover supported features and limits",
        "security": [],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Capabilities"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "operationId": "listModels",
        "summary": "List available models",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Disabled key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models/{model}": {
      "get": {
        "operationId": "getModel",
        "summary": "Retrieve a model",
        "parameters": [
          {
            "name": "model",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "example": "deepseek-v4.1-flash-free"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Model"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Disabled key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "404": {
            "description": "Unknown route or model.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/key": {
      "get": {
        "operationId": "getKey",
        "summary": "Read own key limit and remaining budget",
        "description": "Disabled keys retain read-only access to their own key and usage information.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Key"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "operationId": "getUsage",
        "summary": "Read own balance and accounted usage",
        "description": "Daily rows cover the last 30 days; recent contains up to 20 requests. Unknown usage is not estimated. Disabled keys retain read-only access.",
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageSnapshot"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "operationId": "createChatCompletion",
        "summary": "Create a text chat completion or SSE stream",
        "description": "One generation at a time in production. Timeout 120 seconds plus up to 8 seconds cancellation grace. In-stream errors use data:{error:...} and are not successful completions even if followed by [DONE]. SDK timeout 180 seconds and max_retries=0 are recommended; an explicit retry can spend tokens again. Preserve X-Request-ID for diagnostics.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatRequest"
              },
              "example": {
                "model": "deepseek-v4.1-flash-free",
                "messages": [
                  {
                    "role": "user",
                    "content": "Reply with exactly OK"
                  }
                ],
                "stream": false
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON completion or SSE according to stream. JSON usage is omitted when unknown; a requested final SSE usage chunk has usage:null when unknown. Counts are never estimated.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletion"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                },
                "example": "data: {\"id\":\"chatcmpl-example\",\"object\":\"chat.completion.chunk\",\"created\":1793836800,\"model\":\"deepseek-v4.1-flash-free\",\"request_id\":\"example-request-id\",\"choices\":[{\"index\":0,\"delta\":{\"role\":\"assistant\",\"content\":\"\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-example\",\"object\":\"chat.completion.chunk\",\"created\":1793836800,\"model\":\"deepseek-v4.1-flash-free\",\"request_id\":\"example-request-id\",\"choices\":[{\"index\":0,\"delta\":{\"content\":\"OK\"},\"finish_reason\":null}]}\n\ndata: {\"id\":\"chatcmpl-example\",\"object\":\"chat.completion.chunk\",\"created\":1793836800,\"model\":\"deepseek-v4.1-flash-free\",\"request_id\":\"example-request-id\",\"choices\":[{\"index\":0,\"delta\":{},\"finish_reason\":\"stop\"}]}\n\ndata: [DONE]\n\n"
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsupported request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Disabled key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "Body exceeds 256 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Local budget exhausted, adapter busy, or provider limit. Inspect error.type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Busy-adapter retry delay when supplied; budget exhaustion requires replenishment.",
                "schema": {
                  "type": "string"
                },
                "example": "2"
              },
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Adapter or accounting error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "Upstream failure or invalid completion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "504": {
            "description": "Generation timeout; usage may already have been incurred.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/generate": {
      "post": {
        "operationId": "generateText",
        "summary": "Generate text from a prompt",
        "description": "No streaming. n, user and stream_options are not accepted.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateRequest"
              },
              "example": {
                "prompt": "Reply with exactly OK",
                "max_tokens": 128
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateCompletion"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid or unsupported request.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "401": {
            "description": "Missing or invalid key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "403": {
            "description": "Disabled key.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "413": {
            "description": "Body exceeds 256 KiB.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "description": "Local budget exhausted, adapter busy, or provider limit. Inspect error.type.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "Retry-After": {
                "description": "Busy-adapter retry delay when supplied; budget exhaustion requires replenishment.",
                "schema": {
                  "type": "string"
                },
                "example": "2"
              },
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "500": {
            "description": "Adapter or accounting error.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "502": {
            "description": "Upstream failure or invalid completion.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "503": {
            "description": "Service unavailable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "504": {
            "description": "Generation timeout; usage may already have been incurred.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "headers": {
              "X-Request-ID": {
                "description": "Local request identifier for diagnostics, including errors.",
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/api.md": {
      "get": {
        "operationId": "downloadAgentInstructions",
        "summary": "Download public Markdown instructions",
        "security": [],
        "responses": {
          "200": {
            "description": "Public API integration guide with placeholders only.",
            "headers": {
              "Content-Disposition": {
                "schema": {
                  "type": "string"
                },
                "example": "attachment; filename=\"API.md\""
              }
            },
            "content": {
              "text/markdown": {
                "schema": {
                  "type": "string"
                }
              }
            }
          }
        }
      }
    },
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApi",
        "summary": "Download this OpenAPI contract",
        "security": [],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key supplied by the service owner; never place it in a URL."
      }
    },
    "schemas": {
      "TextPart": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "text"
        ],
        "properties": {
          "type": {
            "const": "text"
          },
          "text": {
            "type": "string"
          }
        }
      },
      "Message": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "minItems": 0,
                "maxItems": 100,
                "items": {
                  "$ref": "#/components/schemas/TextPart"
                }
              }
            ]
          }
        },
        "description": "Exactly role and content. Text parts concatenate without a separator. user/assistant remain conversation roles; system/developer are appended to native OpenCode system instructions, without a separate OpenAI-style priority hierarchy."
      },
      "ChatRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "messages"
        ],
        "description": "UTF-8 JSON body up to 262144 bytes. At least one user or assistant message and some nonblank text are required. Unsupported fields are rejected.",
        "not": {
          "required": [
            "max_tokens",
            "max_completion_tokens"
          ]
        },
        "properties": {
          "model": {
            "type": "string",
            "default": "deepseek-v4.1-flash-free",
            "enum": [
              "deepseek-v4.1-flash-free",
              "deepseek-chat",
              "opencode/deepseek-v4.1-flash-free"
            ]
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "maximum": 32000
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1,
            "maximum": 32000,
            "description": "Alternative to max_tokens; do not send both."
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "top_p": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "frequency_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "presence_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4294967295
          },
          "stop": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              {
                "type": "array",
                "minItems": 1,
                "maxItems": 4,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                }
              }
            ]
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "maxItems": 100,
            "items": {
              "$ref": "#/components/schemas/Message"
            },
            "contains": {
              "type": "object",
              "required": [
                "role"
              ],
              "properties": {
                "role": {
                  "enum": [
                    "user",
                    "assistant"
                  ]
                }
              }
            },
            "minContains": 1
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "stream_options": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "include_usage": {
                "type": "boolean",
                "default": false
              }
            },
            "description": "Requires stream:true. include_usage defaults to false; when true, a final choices:[] chunk carries complete usage or null if unknown."
          },
          "n": {
            "type": "integer",
            "const": 1,
            "default": 1
          },
          "user": {
            "type": "string",
            "maxLength": 128,
            "description": "Optional client identifier, not included in model messages."
          }
        },
        "allOf": [
          {
            "if": {
              "required": [
                "stream_options"
              ]
            },
            "then": {
              "required": [
                "stream"
              ],
              "properties": {
                "stream": {
                  "const": true
                }
              }
            }
          }
        ]
      },
      "GenerateRequest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "prompt"
        ],
        "not": {
          "required": [
            "max_tokens",
            "max_completion_tokens"
          ]
        },
        "properties": {
          "model": {
            "type": "string",
            "default": "deepseek-v4.1-flash-free",
            "enum": [
              "deepseek-v4.1-flash-free",
              "deepseek-chat",
              "opencode/deepseek-v4.1-flash-free"
            ]
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1,
            "maximum": 32000
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1,
            "maximum": 32000,
            "description": "Alternative to max_tokens; do not send both."
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "top_p": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "frequency_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "presence_penalty": {
            "type": "number",
            "minimum": -2,
            "maximum": 2
          },
          "seed": {
            "type": "integer",
            "minimum": 0,
            "maximum": 4294967295
          },
          "stop": {
            "oneOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 256
              },
              {
                "type": "array",
                "minItems": 1,
                "maxItems": 4,
                "items": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 256
                }
              }
            ]
          },
          "prompt": {
            "type": "string",
            "minLength": 1,
            "description": "Nonblank prompt text."
          },
          "stream": {
            "type": "boolean",
            "const": false,
            "default": false
          }
        }
      },
      "Usage": {
        "type": "object",
        "required": [
          "prompt_tokens",
          "completion_tokens",
          "total_tokens"
        ],
        "properties": {
          "prompt_tokens": {
            "type": "integer",
            "minimum": 0,
            "description": "Uncached input plus cache read and write; includes OpenCode system/tool context."
          },
          "completion_tokens": {
            "type": "integer",
            "minimum": 0,
            "description": "Visible output plus reasoning."
          },
          "total_tokens": {
            "type": "integer",
            "minimum": 0,
            "description": "prompt_tokens + completion_tokens."
          },
          "prompt_tokens_details": {
            "type": "object",
            "properties": {
              "cached_tokens": {
                "type": "integer",
                "minimum": 0
              },
              "cache_write_tokens": {
                "type": "integer",
                "minimum": 0
              }
            }
          },
          "completion_tokens_details": {
            "type": "object",
            "properties": {
              "reasoning_tokens": {
                "type": "integer",
                "minimum": 0
              },
              "text_tokens": {
                "type": "integer",
                "minimum": 0
              }
            }
          }
        }
      },
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "message",
              "type",
              "code"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "code": {
                "type": "integer",
                "minimum": 400,
                "maximum": 599
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "Model": {
        "type": "object",
        "required": [
          "id",
          "object",
          "owned_by"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "model"
          },
          "owned_by": {
            "type": "string"
          },
          "created": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "ModelList": {
        "type": "object",
        "required": [
          "object",
          "data"
        ],
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Model"
            }
          }
        }
      },
      "Key": {
        "type": "object",
        "required": [
          "id",
          "name",
          "prefix",
          "active",
          "unlimited",
          "limit_tokens",
          "used_tokens",
          "remaining_tokens",
          "created_at",
          "last_used_at"
        ],
        "properties": {
          "object": {
            "const": "api_key"
          },
          "id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "active": {
            "type": "boolean"
          },
          "unlimited": {
            "type": "boolean"
          },
          "limit_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "null means unlimited."
          },
          "used_tokens": {
            "type": "integer",
            "minimum": 0,
            "description": "Known accounted token usage."
          },
          "remaining_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0,
            "description": "Clamped at zero; null means unlimited."
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "last_used_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          }
        }
      },
      "Summary": {
        "type": "object",
        "required": [
          "requests",
          "success",
          "failed",
          "pending",
          "unknown_usage_requests",
          "prompt_tokens",
          "completion_tokens",
          "total_tokens",
          "cached_tokens",
          "reasoning_tokens"
        ],
        "properties": {
          "requests": {
            "type": "integer",
            "minimum": 0
          },
          "success": {
            "type": "integer",
            "minimum": 0
          },
          "failed": {
            "type": "integer",
            "minimum": 0
          },
          "pending": {
            "type": "integer",
            "minimum": 0
          },
          "unknown_usage_requests": {
            "type": "integer",
            "minimum": 0
          },
          "prompt_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "completion_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "total_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "cached_tokens": {
            "type": "integer",
            "minimum": 0
          },
          "reasoning_tokens": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "DailyUsage": {
        "type": "object",
        "required": [
          "date",
          "requests",
          "tokens"
        ],
        "properties": {
          "date": {
            "type": "string",
            "format": "date",
            "description": "UTC day."
          },
          "requests": {
            "type": "integer",
            "minimum": 0
          },
          "tokens": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "RequestUsage": {
        "type": "object",
        "required": [
          "id",
          "created_at",
          "status",
          "prompt_tokens",
          "completion_tokens",
          "total_tokens",
          "error_code",
          "elapsed_ms"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "status": {
            "enum": [
              "pending",
              "success",
              "error"
            ]
          },
          "prompt_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "completion_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "total_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          },
          "error_code": {
            "type": [
              "integer",
              "null"
            ]
          },
          "elapsed_ms": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 0
          }
        }
      },
      "UsageSnapshot": {
        "type": "object",
        "required": [
          "key",
          "summary",
          "daily",
          "recent"
        ],
        "properties": {
          "key": {
            "$ref": "#/components/schemas/Key"
          },
          "summary": {
            "$ref": "#/components/schemas/Summary"
          },
          "daily": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/DailyUsage"
            }
          },
          "recent": {
            "type": "array",
            "maxItems": 20,
            "items": {
              "$ref": "#/components/schemas/RequestUsage"
            }
          }
        }
      },
      "ChatCompletion": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "model",
          "choices"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "chat.completion"
          },
          "created": {
            "type": "integer",
            "minimum": 0
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "minItems": 1,
            "maxItems": 1,
            "items": {
              "type": "object",
              "required": [
                "index",
                "message",
                "finish_reason"
              ],
              "properties": {
                "index": {
                  "const": 0
                },
                "message": {
                  "type": "object",
                  "required": [
                    "role",
                    "content"
                  ],
                  "properties": {
                    "role": {
                      "const": "assistant"
                    },
                    "content": {
                      "type": "string"
                    }
                  }
                },
                "finish_reason": {
                  "type": "string",
                  "enum": [
                    "stop",
                    "length",
                    "content_filter"
                  ]
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "GenerateCompletion": {
        "type": "object",
        "required": [
          "text",
          "model",
          "finish_reason"
        ],
        "properties": {
          "text": {
            "type": "string"
          },
          "model": {
            "type": "string"
          },
          "finish_reason": {
            "type": "string",
            "enum": [
              "stop",
              "length",
              "content_filter"
            ]
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "request_id": {
            "type": "string"
          }
        }
      },
      "Health": {
        "type": "object",
        "required": [
          "status",
          "uptime_seconds"
        ],
        "properties": {
          "status": {
            "const": "ok"
          },
          "uptime_seconds": {
            "type": "integer",
            "minimum": 0
          }
        }
      },
      "Capabilities": {
        "type": "object",
        "required": [
          "object",
          "api_version",
          "model",
          "model_aliases",
          "streaming",
          "tools",
          "images",
          "audio",
          "supported_chat_parameters",
          "supported_generate_parameters",
          "max_body_bytes",
          "max_messages",
          "max_content_parts",
          "max_output_tokens",
          "max_concurrent_generations",
          "generation_timeout_seconds"
        ],
        "description": "Machine-readable capabilities of this adapter; does not establish provider availability or remaining provider quota. Deployment settings can change the concurrency and timeout values.",
        "properties": {
          "object": {
            "const": "api.capabilities"
          },
          "api_version": {
            "const": "1.1.0"
          },
          "model": {
            "const": "deepseek-v4.1-flash-free"
          },
          "model_aliases": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "streaming": {
            "const": true
          },
          "tools": {
            "const": false
          },
          "images": {
            "const": false
          },
          "audio": {
            "const": false
          },
          "supported_chat_parameters": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "supported_generate_parameters": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "max_body_bytes": {
            "type": "integer",
            "minimum": 1
          },
          "max_messages": {
            "type": "integer",
            "minimum": 1
          },
          "max_content_parts": {
            "type": "integer",
            "minimum": 1
          },
          "max_output_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "max_concurrent_generations": {
            "type": "integer",
            "minimum": 1
          },
          "generation_timeout_seconds": {
            "type": "number",
            "exclusiveMinimum": 0
          }
        }
      }
    }
  }
}
