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

# Entity extraction

Extracts an entity from the document with the specified fields and types.

# 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": {
      "ExtractEntitySuccess": {
        "type": "object",
        "properties": {
          "entity": {
            "type": "object",
            "additionalProperties": {
              "anyOf": [
                {
                  "type": "boolean"
                },
                {
                  "type": "number"
                },
                {
                  "type": "string"
                }
              ]
            }
          }
        },
        "required": [
          "entity"
        ]
      },
      "ExtractEntityError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string",
            "minLength": 1
          }
        },
        "required": [
          "message"
        ]
      },
      "ExtractEntityBodyParams": {
        "type": "object",
        "properties": {
          "document": {
            "type": "string",
            "minLength": 1,
            "description": "The document from which to extract data."
          },
          "schema": {
            "type": "object",
            "additionalProperties": {
              "type": "object",
              "properties": {
                "required": {
                  "type": "boolean",
                  "nullable": true,
                  "default": false
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "boolean",
                    "number",
                    "string"
                  ]
                }
              },
              "required": [
                "type"
              ]
            },
            "description": "The expected schema of the entity result."
          }
        },
        "required": [
          "document",
          "schema"
        ]
      }
    }
  },
  "paths": {
    "/blocks/extract": {
      "post": {
        "description": "Extracts an entity from the document with the specified fields and types.",
        "operationId": "ExtractEntity",
        "summary": "Entity extraction",
        "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/ExtractEntityBodyParams"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractEntitySuccess"
                }
              }
            }
          },
          "4XX": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ExtractEntityError"
                }
              }
            }
          }
        }
      }
    }
  },
  "_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
    }
  }
}
```