Skip to Main Content

AI Services

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help needed with troubleshooting Document Understanding Text Extraction Python API

Abasu-OracleSep 9 2025

This may not be the appropriate forum (if not, please guide to the correct one) - need help trooubleshooting an issue where I am trying to use the Text Extraction python API as follows (pretty much a copy of the sample provided):

===========

import oci
import base64
import pprint

compartment_id = "ocid1.tenancy.oc1..XXX"
CONFIG_PROFILE = "DEFAULT"
config = oci.config.from_file('~/.oci/config', CONFIG_PROFILE)

endpoint = "https://inference.generativeai.us-ashburn-1.oci.oraclecloud.com"

ai_document_client = oci.ai_document.AIServiceDocumentClient(config)

with open("<file-name>.pdf","rb") as source_pdf:
enc_pdf = base64.b64encode(source_pdf.read())

oci.base_client.is_http_log_enabled(True)

analyze_document_response = ai_document_client.analyze_document(
analyze_document_details=oci.ai_document.models.AnalyzeDocumentDetails(
features=[
oci.ai_document.models.DocumentTextExtractionFeature(
feature_type="TEXT_EXTRACTION",
generate_searchable_pdf=False,
model_id="ocid1.generativeaimodel.oc1.iad.amaaaaaask7dceyaldmhg25is4nouena4oa2pj4nvwgfeempo4syiaazukia"
)],
document=oci.ai_document.models.InlineDocumentDetails(
source="INLINE",
data=str(enc_pdf),
),
compartment_id=compartment_id
)
)

print(analyze_document_response.data)

========

But I am getting the following error and unable to determine which is the inalid parameter.

oci.exceptions.ServiceError: {'target_service': 'ai_service_document', 'status': 400, 'code': 'InvalidParameter', 'opc-request-id': '60C74695CFD24711906F4410F5277504/2D72A4907C37017056D7E28C5F0B36EB/6AA9579703F2000038725C63192D24E0', 'message': 'Unable to process JSON input', 'operation_name': 'analyze_document', 'timestamp': '2025-09-09T02:15:30.609656+00:00', 'client_version': 'Oracle-PythonSDK/2.159.1', 'request_endpoint': 'POST https://document.aiservice.us-ashburn-1.oci.oraclecloud.com/20221109/actions/analyzeDocument', 'logging_tips': 'To get more info on the failing request, refer to https://docs.oracle.com/en-us/iaas/tools/python/latest/logging.html for ways to log the request/response details.', 'troubleshooting_tips': "See https://docs.oracle.com/iaas/Content/API/References/apierrors.htm#apierrors_400__400_invalidparameter for more information about resolving this error. Also see https://docs.oracle.com/iaas/api/#/en/document-understanding/20221109/AnalyzeDocumentResult/AnalyzeDocument for details on this operation's requirements. If you are unable to resolve this ai_service_document issue, please contact Oracle support and provide them this full error message."}

Any idea to help troubleshoot this would be vry helpful.

Thank you!

Comments
Post Details
Added on Sep 9 2025
2 comments
65 views