4D Blog

Home Product Transform Static Documents into Actionable Knowledge with AIKit

Transform Static Documents into Actionable Knowledge with AIKit

January 22, 2026

Product

Large reports, contracts, or documentation files often contain more information than can be quickly processed. Wouldn’t it be nice if you could simply upload a document PDF from your 4D application and let AI help you summarize it, extract key data, or answer questions about its content?

Thanks to the new OpenAI.files class, this workflow is now very simple. You can seamlessly upload files and use AI to interact with their content in many ways.

Step 1 – Upload your document

The OpenAI.files.create() function lets you upload a file that can later be used across OpenAI endpoints.

Here’s an example that uploads a PDF file and sets its purpose to user_data:

var $file := File("/RESOURCES/MeetingReport.pdf")
var $clientAI : cs.AIKit.OpenAI:=cs.AIManagement.new().clientAI


// Upload the file
// $file: the 4D.File object representing the local document
// "user_data": the intended purpose of the file
// expires_after: optional policy to automatically delete the file after 1 hour
var $result:=$clientAI.files.create($file; "user_data"; {expires_after: {anchor: "created_at"; seconds: 3600}})

//$result.file{
//  "object":"file",
//  "id":"file-8WJG5F9PYR3SCbL2dKJ5b2",
//  "purpose":"user_data",
//  "filename":"2510.07311v1.pdf",
//  "bytes":912072,
//  "created_at":1760433437,
//  "expires_at":1760437037,
//  "status":"processed",
//  "status_details":null
//}

Once uploaded, the result contains detailed information about the file, including its id, which will be used later.

⚠️ Important: Not all file types are supported by every model. Always check the documentation of the model you’re using to ensure your files are compatible.

Step 2 – Link the file to your message

After the file is uploaded, you can associate it with a message using the OpenAIMessage.addFileId() function. This tells the AI model to consider the content of the uploaded file when generating its response.

var $clientAI:=cs.AIManagement.new().clientAI
var $chatHelper:=$clientAI.chat.create("You are an assistant specializing in file analysis and parsing.")

// Create a new OpenAIMessage object with role "user" and a prompt
var $message:=cs.AIKit.OpenAIMessage.new({role: "user"; content: "Could you summarize this document?"})
// Attach the uploaded file to the message by adding its file id
// This tells the AI which document should be summarized
$message.addFileId($result.file.id)

// Send the message to the AI chat helper and store the summarized text
var $summary:=$chatHelper.prompt($message)

The model will analyze the content of the uploaded file and return a concise summary of its main points.

Step 3 – Delete the file from the server

Once the summarization or analysis is done, you may want to delete the uploaded file to free space or maintain privacy. You can do this using the OpenAI.files.delete() function:

// Delete the uploaded file using its ID
var $delete:=$ClientAI.files.delete($result.file.id)

Manage uploaded files

After uploading a file, you can list all files in your organization or retrieve details about a specific file.

List all uploaded files

// List all files uploaded by your organization
var $filesList:=$clientAI.files.list()

Retrieve a specific file

// Get detailed info about a single file using its id
var $fileInfo:=$clientAI.files.retrieve($result.file.id)

Conclusion

By combining OpenAI.files.create() and OpenAIChatHelper.prompt(), you can offer a seamless document analysis feature in your 4D applications. Users simply upload a file, and within seconds, receive a clear and accurate summary powered by AI.

But it doesn’t stop at summarization. The same approach can be used to extract specific information, answer questions, or search for particular details within a document — all without manually reading through it. This opens the door to countless possibilities: automatic meeting minutes, fast onboarding to long technical documents, or quick extraction of key data — all within your 4D environment.

Discuss

Tags 21 R2, 22, 4D AIKit, Artificial Intelligence

Latest related posts

  • February 3, 2026

    4D Write Pro – Adding a margin automatically when bullets are set using standard actions

  • January 22, 2026

    Deploy Fluent UI effortlessly in your 4D applications

  • January 21, 2026

    Searching Across Host Projects and Components in 4D

Fabrice Mainguené
Fabrice Mainguené
• Product Owner •Fabrice Mainguené joined 4D Program team in November, 2016. As a Product Owner, he is in charge of writing the user stories then translating it to functional specifications. His role is also to make sure that the feature implementation delivered is meeting the customer need.After obtaining a Bachelor degree in Computer Science at CNAM, Fabrice joined a small software publishing company as a Windev developer. Then he worked for different companies in industry and trade areas as a Windev and web developer as well as technical advisor on new features.
  • Deutsch
  • Français
  • English
  • Português
  • Čeština
  • Español
  • Italiano
  • 日本語

Categories

Browse categories

  • AI
  • 4D View Pro
  • 4D Write Pro
  • 4D for Mobile
  • Email
  • Development Mode
  • 4D Language
  • ORDA
  • User Interface / GUI
  • Qodly Studio
  • Server
  • Maintenance
  • Deployment
  • 4D Tutorials
  • Generic
  • 4D Summit sessions and other online videos

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor

Tags

4D AIKit 4D for Android 4D for iOS 4D NetKit 4D Qodly Pro 4D View Pro 4D Write Pro 20 R10 21 21 R2 Administration AI Artificial Intelligence Build application CI/CD Class Client/Server Code editor Collections Formula Listbox Logs Mail Microsoft 365 Network Objects OpenAI ORDA PDF Pictures Preemptive Programming REST Scalability Security Session Source control Speed Spreadsheet Tutorial UI User Experience vscode Web Word processor
Subscribe to 4D Newsletter

© 2026 4D SAS - All rights reserved
Terms & Conditions | Legal Notices | Data Policy | Cookie Policy | Contact us | Write for us


Subscribe to 4D Newsletter

* Your privacy is very important to us. Please click here to view our Policy

Contact us

Got a question, suggestion or just want to get in touch with the 4D bloggers? Drop us a line!

* Your privacy is very important to us. Please click here to view our Policy