Skip to content

get_document_content

Operation

get_document_content

get_document_content(request: GetDocumentContentInput | GetDocumentContentInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[GetDocumentContentInputDict]) -> GetDocumentContentOutput

Retrieves the content of an ingested document from a knowledge base, or of an image embedded in the document. Returns a pre-signed URL for downloading the content. Use this operation to display the source of a Retrieve result.

Parameters:

Name Type Description Default
request GetDocumentContentInput | GetDocumentContentInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[GetDocumentContentInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
GetDocumentContentOutput

An instance of GetDocumentContentOutput.

get_document_content async

get_document_content(request: GetDocumentContentInput | GetDocumentContentInputDict | None = None, /, *, plugins: list[Plugin] | None = None, **kwargs: Unpack[GetDocumentContentInputDict]) -> GetDocumentContentOutput

Retrieves the content of an ingested document from a knowledge base, or of an image embedded in the document. Returns a pre-signed URL for downloading the content. Use this operation to display the source of a Retrieve result.

Parameters:

Name Type Description Default
request GetDocumentContentInput | GetDocumentContentInputDict | None

The input as a model or dictionary. Pass this or keyword arguments, not both.

None
plugins list[Plugin] | None

A list of callables that modify the configuration dynamically. Changes made by these plugins only apply for the duration of the operation execution and will not affect any other operation invocations.

None
**kwargs Unpack[GetDocumentContentInputDict]

The input fields as keyword arguments.

{}

Returns:

Type Description
GetDocumentContentOutput

An instance of GetDocumentContentOutput.

Input

Pass the input as keyword arguments, a positional dictionary, or a positional model object. Pass plugins separately as a keyword argument.

GetDocumentContentInputDict

Bases: TypedDict

Dictionary form of GetDocumentContentInput.

Attributes

data_source_id instance-attribute
data_source_id: Required[str]

The unique identifier of the data source that contains the document.

document_id instance-attribute
document_id: Required[str]

The unique identifier of the document to retrieve content for.

knowledge_base_id instance-attribute
knowledge_base_id: Required[str]

The unique identifier of the knowledge base that contains the document.

media_id instance-attribute
media_id: str | None

The unique identifier (in UUID format) of an image embedded in the specified document. Set this parameter to the _media_id value in the metadata of the corresponding Retrieve result. If you specify this parameter, the response contains a pre-signed URL for the image instead of the document, and you must omit outputFormat or set it to RAW.

output_format instance-attribute
output_format: str | None

The output format for the content. You can specify one of the following values:

RAW

Returns the original document, or the selected image if you specify mediaId.

EXTRACTED

Returns parsed document text as JSON.

If you omit this parameter, the default is RAW. You can't use EXTRACTED with mediaId.

user_context instance-attribute
user_context: UserContext | UserContextDict | None

Contains information about the user making the request. This is used for access control filtering to ensure that results only include documents the user is authorized to access.

GetDocumentContentInput dataclass

Bases: _SerdeShape

Dataclass for GetDocumentContentInput structure.

Attributes

data_source_id class-attribute instance-attribute
data_source_id: str | None = ...

The unique identifier of the data source that contains the document.

document_id class-attribute instance-attribute
document_id: str | None = ...

The unique identifier of the document to retrieve content for.

knowledge_base_id class-attribute instance-attribute
knowledge_base_id: str | None = ...

The unique identifier of the knowledge base that contains the document.

media_id class-attribute instance-attribute
media_id: str | None = ...

The unique identifier (in UUID format) of an image embedded in the specified document. Set this parameter to the _media_id value in the metadata of the corresponding Retrieve result. If you specify this parameter, the response contains a pre-signed URL for the image instead of the document, and you must omit outputFormat or set it to RAW.

output_format class-attribute instance-attribute
output_format: str | None = ...

The output format for the content. You can specify one of the following values:

RAW

Returns the original document, or the selected image if you specify mediaId.

EXTRACTED

Returns parsed document text as JSON.

If you omit this parameter, the default is RAW. You can't use EXTRACTED with mediaId.

user_context class-attribute instance-attribute
user_context: UserContext | None = ...

Contains information about the user making the request. This is used for access control filtering to ensure that results only include documents the user is authorized to access.

Output

GetDocumentContentOutput dataclass

Bases: _SerdeShape

Dataclass for GetDocumentContentOutput structure.

Attributes

document_content_length class-attribute instance-attribute
document_content_length: int | None = ...

The size, in bytes, of the content available at the pre-signed URL.

mime_type instance-attribute
mime_type: str

The MIME type of the returned content. For RAW format, this is the original file type (for example, application/pdf), or the image type (for example, image/png) if you specify mediaId. For EXTRACTED format, this is always application/json.

presigned_url instance-attribute
presigned_url: str

A pre-signed URL for downloading the document content, or the selected image if you specify mediaId. The URL expires after 5 minutes.

response_metadata class-attribute instance-attribute
response_metadata: ResponseMetadata = ...

Metadata about the response that produced this output. Use this to recover the request identifiers a service's support team needs in order to investigate a call. Members of the metadata are individually optional.