{
  "openapi": "3.1.0",
  "info": {
    "title": "Divyam Hosted API",
    "version": "0.1.0",
    "description": "OpenAI-compatible inference endpoints for Divyam Hosted API accounts. Copy the exact base URL from the console and authenticate with a Divyam API key."
  },
  "tags": [
    {
      "name": "Inference endpoints",
      "description": "Run chat completions and discover available models."
    }
  ],
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "description": "Serve a completion through the caller's default project.",
        "operationId": "create_chat_completion",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              }
            },
            "description": "Successful Response"
          },
          "402": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Payment Required"
          },
          "404": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Not Found"
          },
          "503": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            },
            "description": "Service Unavailable"
          }
        },
        "security": [
          {
            "DivyamApiKey": []
          }
        ],
        "summary": "Create Chat Completion",
        "tags": [
          "Inference endpoints"
        ]
      }
    },
    "/v1/models": {
      "get": {
        "description": "OpenAI-compatible model listing for the hosted catalog.",
        "operationId": "list_served_models",
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            },
            "description": "Successful Response"
          }
        },
        "security": [
          {
            "DivyamApiKey": []
          }
        ],
        "summary": "List Served Models",
        "tags": [
          "Inference endpoints"
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "DivyamApiKey": {
        "description": "Use a Divyam API key from the console as a Bearer token.",
        "scheme": "bearer",
        "type": "http"
      }
    },
    "schemas": {
      "ChatCompletionRequest": {
        "description": "An OpenAI-shaped chat completion request.",
        "properties": {
          "max_tokens": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Max Tokens"
          },
          "messages": {
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            },
            "title": "Messages",
            "type": "array"
          },
          "model": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "description": "Catalog model id. Omit to use the account's saved default.",
            "title": "Model"
          },
          "stop": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              {
                "type": "null"
              }
            ],
            "title": "Stop"
          },
          "stream": {
            "default": false,
            "title": "Stream",
            "type": "boolean"
          },
          "temperature": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Temperature"
          },
          "top_p": {
            "anyOf": [
              {
                "type": "number"
              },
              {
                "type": "null"
              }
            ],
            "title": "Top P"
          }
        },
        "required": [
          "messages"
        ],
        "title": "ChatCompletionRequest",
        "type": "object"
      },
      "ChatCompletionResponse": {
        "description": "An OpenAI-shaped response, plus a `divyam` block clients may ignore.",
        "properties": {
          "choices": {
            "items": {
              "$ref": "#/components/schemas/Choice"
            },
            "title": "Choices",
            "type": "array"
          },
          "created": {
            "title": "Created",
            "type": "integer"
          },
          "id": {
            "title": "Id",
            "type": "string"
          },
          "model": {
            "title": "Model",
            "type": "string"
          },
          "object": {
            "const": "chat.completion",
            "default": "chat.completion",
            "title": "Object",
            "type": "string"
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        },
        "required": [
          "id",
          "created",
          "model",
          "choices",
          "usage"
        ],
        "title": "ChatCompletionResponse",
        "type": "object"
      },
      "ChatMessage": {
        "description": "One turn in the conversation.",
        "properties": {
          "content": {
            "title": "Content",
            "type": "string"
          },
          "name": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Name"
          },
          "role": {
            "enum": [
              "system",
              "user",
              "assistant",
              "tool"
            ],
            "title": "Role",
            "type": "string"
          }
        },
        "required": [
          "role",
          "content"
        ],
        "title": "ChatMessage",
        "type": "object"
      },
      "Choice": {
        "properties": {
          "finish_reason": {
            "default": "stop",
            "enum": [
              "stop",
              "length",
              "content_filter"
            ],
            "title": "Finish Reason",
            "type": "string"
          },
          "index": {
            "default": 0,
            "title": "Index",
            "type": "integer"
          },
          "message": {
            "$ref": "#/components/schemas/ChoiceMessage"
          }
        },
        "required": [
          "message"
        ],
        "title": "Choice",
        "type": "object"
      },
      "ChoiceMessage": {
        "properties": {
          "content": {
            "title": "Content",
            "type": "string"
          },
          "role": {
            "const": "assistant",
            "default": "assistant",
            "title": "Role",
            "type": "string"
          }
        },
        "required": [
          "content"
        ],
        "title": "ChoiceMessage",
        "type": "object"
      },
      "ErrorResponse": {
        "properties": {
          "error": {
            "$ref": "#/components/schemas/ErrorDetail"
          }
        },
        "required": [
          "error"
        ],
        "title": "ErrorResponse",
        "type": "object"
      },
      "ModelCard": {
        "description": "An entry in the OpenAI-compatible `GET /v1/models` listing.",
        "properties": {
          "created": {
            "title": "Created",
            "type": "integer"
          },
          "id": {
            "title": "Id",
            "type": "string"
          },
          "object": {
            "const": "model",
            "default": "model",
            "title": "Object",
            "type": "string"
          },
          "owned_by": {
            "title": "Owned By",
            "type": "string"
          }
        },
        "required": [
          "id",
          "created",
          "owned_by"
        ],
        "title": "ModelCard",
        "type": "object"
      },
      "ModelList": {
        "properties": {
          "data": {
            "items": {
              "$ref": "#/components/schemas/ModelCard"
            },
            "title": "Data",
            "type": "array"
          },
          "object": {
            "const": "list",
            "default": "list",
            "title": "Object",
            "type": "string"
          }
        },
        "required": [
          "data"
        ],
        "title": "ModelList",
        "type": "object"
      },
      "Usage": {
        "description": "Token accounting for one completion.",
        "properties": {
          "completion_tokens": {
            "title": "Completion Tokens",
            "type": "integer"
          },
          "prompt_tokens": {
            "title": "Prompt Tokens",
            "type": "integer"
          },
          "total_tokens": {
            "title": "Total Tokens",
            "type": "integer"
          }
        },
        "required": [
          "prompt_tokens",
          "completion_tokens",
          "total_tokens"
        ],
        "title": "Usage",
        "type": "object"
      },
      "ErrorDetail": {
        "description": "OpenAI-shaped error body, so existing clients surface it properly.",
        "properties": {
          "code": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Code"
          },
          "message": {
            "title": "Message",
            "type": "string"
          },
          "param": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Param"
          },
          "type": {
            "title": "Type",
            "type": "string"
          }
        },
        "required": [
          "message",
          "type"
        ],
        "title": "ErrorDetail",
        "type": "object"
      }
    }
  },
  "x-divyam-source-sha256": "3ecc955b6de8584b9be052216d1250af51838c8a0fa4c613eaa841cf57141021"
}
