Class MistralOcrApi
java.lang.Object
org.springframework.ai.mistralai.ocr.MistralOcrApi
Java Client library for the Mistral AI OCR API. Provides access to the OCR
functionality.
The API processes a document and returns a markdown string representation of the text, along with information about extracted images.
- Since:
- 1.1.0
- Author:
- Alexandros Pappas
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordRepresents an extracted image from a page.static enumList of well-known Mistral OCR models.static final recordRepresents OCR information for a single page.static final recordRepresents the dimensions of a PDF page's screenshot image.static final recordRepresents the request for the OCR API.static final recordRepresents the response from the OCR API.static final recordRepresents usage information for the OCR request. -
Constructor Summary
ConstructorsConstructorDescriptionMistralOcrApi(String mistralAiApiKey) Create a new MistralOcrApi instance.MistralOcrApi(String baseUrl, String mistralAiApiKey) Create a new MistralOcrApi instance.MistralOcrApi(String baseUrl, String mistralAiApiKey, org.springframework.web.client.RestClient.Builder restClientBuilder) Create a new MistralOcrApi instance.MistralOcrApi(String baseUrl, String mistralAiApiKey, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new MistralOcrApi instance. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<MistralOcrApi.OCRResponse>ocr(MistralOcrApi.OCRRequest ocrRequest) Performs OCR on a document and returns the extracted information.
-
Constructor Details
-
MistralOcrApi
Create a new MistralOcrApi instance.- Parameters:
mistralAiApiKey- Mistral AI API key.
-
MistralOcrApi
Create a new MistralOcrApi instance.- Parameters:
baseUrl- API base URL.mistralAiApiKey- Mistral AI API key.
-
MistralOcrApi
public MistralOcrApi(String baseUrl, String mistralAiApiKey, org.springframework.web.client.RestClient.Builder restClientBuilder) Create a new MistralOcrApi instance.- Parameters:
baseUrl- API base URL.mistralAiApiKey- Mistral AI API key.restClientBuilder- RestClient builder.
-
MistralOcrApi
public MistralOcrApi(String baseUrl, String mistralAiApiKey, org.springframework.web.client.RestClient.Builder restClientBuilder, org.springframework.web.client.ResponseErrorHandler responseErrorHandler) Create a new MistralOcrApi instance.- Parameters:
baseUrl- API base URL.mistralAiApiKey- Mistral AI API key.restClientBuilder- RestClient builder.responseErrorHandler- Response error handler.
-
-
Method Details
-
ocr
public org.springframework.http.ResponseEntity<MistralOcrApi.OCRResponse> ocr(MistralOcrApi.OCRRequest ocrRequest) Performs OCR on a document and returns the extracted information.- Parameters:
ocrRequest- The OCR request containing document details and processing options.- Returns:
- ResponseEntity containing the OCR response with markdown text and image data.
-