---
agentTools:
  projectIndex: https://preemo.readme.io/llms.txt
---

# Document question & answer

Answers questions using the provided context.

# OpenAPI definition

```json
{
  "externalDocs": {
    "description": "Gradient AI documentation",
    "url": "https://docs.gradient.ai"
  },
  "info": {
    "contact": {
      "email": "support@gradient.ai",
      "name": "Gradient AI Support",
      "url": "https://docs.gradient.ai/discuss"
    },
    "description": "Interface for interacting with Gradient AI.",
    "title": "Gradient AI API",
    "version": "1.0.0"
  },
  "openapi": "3.0.3",
  "security": [
    {
      "AccessToken": []
    }
  ],
  "servers": [
    {
      "description": "Production endpoint",
      "url": "https://api.gradient.ai/api"
    },
    {
      "url": "http://localhost:3026/api"
    }
  ],
  "x-readme": {
    "samples-languages": [
      "curl",
      "python",
      "node"
    ],
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "components": {
    "securitySchemes": {
      "AccessToken": {
        "scheme": "bearer",
        "type": "http"
      }
    },
    "schemas": {
      "GenerateAnswerSuccess": {
        "type": "object",
        "properties": {
          "answer": {
            "type": "string",
            "minLength": 1
          },
          "ragContext": {
            "type": "object",
            "properties": {
              "documents": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "content": {
                      "type": "string",
                      "minLength": 1
                    },
                    "fileName": {
                      "type": "string",
                      "minLength": 1
                    }
                  },
                  "required": [
                    "content",
                    "fileName"
                  ]
                }
              }
            },
            "required": [
              "documents"
            ]
          }
        },
        "required": [
          "answer"
        ]
      },
      "GenerateAnswerError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "message"
        ]
      },
      "GenerateAnswerBodyParams": {
        "type": "object",
        "properties": {
          "question": {
            "type": "string",
            "minLength": 1
          },
          "source": {
            "oneOf": [
              {
                "type": "object",
                "properties": {
                  "collectionId": {
                    "type": "string",
                    "minLength": 1
                  },
                  "type": {
                    "type": "string",
                    "enum": [
                      "rag"
                    ]
                  }
                },
                "required": [
                  "collectionId",
                  "type"
                ],
                "description": "The reference RAG that must be used to answer the question."
              },
              {
                "type": "object",
                "properties": {
                  "type": {
                    "type": "string",
                    "enum": [
                      "document"
                    ]
                  },
                  "value": {
                    "type": "string",
                    "minLength": 1
                  }
                },
                "required": [
                  "type",
                  "value"
                ],
                "description": "The document that must be used to answer the question."
              }
            ]
          }
        },
        "required": [
          "question",
          "source"
        ]
      }
    }
  },
  "paths": {
    "/blocks/answer": {
      "post": {
        "description": "Answers questions using the provided context.",
        "operationId": "GenerateAnswer",
        "summary": "Document question & answer",
        "tags": [
          "Blocks"
        ],
        "parameters": [
          {
            "schema": {
              "type": "string",
              "minLength": 1
            },
            "required": true,
            "name": "x-gradient-workspace-id",
            "in": "header"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/GenerateAnswerBodyParams"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateAnswerSuccess"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/GenerateAnswerError"
                }
              }
            }
          }
        }
      }
    }
  },
  "_id": {
    "buffer": {
      "0": 100,
      "1": 201,
      "2": 83,
      "3": 144,
      "4": 228,
      "5": 32,
      "6": 103,
      "7": 0,
      "8": 117,
      "9": 236,
      "10": 84,
      "11": 142
    }
  }
}
```