使用我们强大的REST API将OLM OCR集成到您的应用程序中。支持多种上传方法和灵活的身份验证。
登录您的帐户,然后从设置页面生成 API 密钥。
转到设置选择 Base64 编码(适用于小文件)或 URL 上传(适用于大文件)。
将您的图像或 PDF 发送到我们的 OCR API,并接收结构化文本数据作为响应。
从图像和PDF中提取文本
POST https://www.freeolmocr.com/api/ocr/process{
"image": "base64_encoded_image_data",
"options": {
"format": "text" # json, text, markdown
}
}{
"imageUrl": "https://img.freeolmocr.com/mistral-ocr/...",
"options": {
"format": "text" # json, text, markdown
}
}{
"success": true,
"userId": "user_123",
"inputSource": "base64",
"extractedText": "Extracted text content...",
"confidence": 0.95,
"processingTime": 1.2,
"creditsUsed": 1
}在请求中包含您的API密钥
选项 1:x-api-key 标头
x-api-key: mk_your_api_key_here选项 2:Authorization 标头
Authorization: Bearer mk_your_api_key_here用于 AI 代理和工具的模型上下文协议
HTTP/JSON-RPC 端点:
POST https://www.freeolmocr.com/api/mcpSSE 流端点:
GET https://www.freeolmocr.com/api/mcp使用 OCR 从文档和图像中提取文本。支持 PDF 文件、JPEG、PNG、WebP 图像。接受 base64 数据和 URL(同步处理)
在 Cursor 中使用 MCP 工具,从图像中进行代码分析和文档提取。
MCP 配置: cursor_mcp_config.json
{
"mcp": {
"servers": {
"mistral-ocr": {
"url": "https://www.freeolmocr.com/api/mcp",
"transport": "http",
"headers": {
"x-api-key": "mk_your_api_key_here",
"Content-Type": "application/json"
},
"capabilities": { "tools": true }
}
}
},
"shortcuts": {
"ocr": "@mistral-ocr extract_text"
},
"workflows": {
"large_file_ocr": [
"extract_text with public_url"
],
"small_file_ocr": [
"extract_text with base64 data"
]
}
}在 Cursor 中使用:
@ocr使用我们的 HTTP/SSE 端点构建您自己的 MCP 客户端或与其他 AI 工具集成。
通用客户端配置: mcp_config.json
{
"mcp": {
"servers": {
"mistral-ocr": {
"url": "https://www.freeolmocr.com/api/mcp",
"transport": "http",
"authentication": {
"type": "api_key",
"header": "x-api-key",
"key": "mk_your_api_key_here"
},
"capabilities": {
"tools": true,
"resources": false,
"prompts": false
},
"metadata": {
"name": "Mistral OCR",
"description": "OCR service for PDF and image text extraction",
"version": "2.0.0"
}
}
}
},
"client": {
"timeout": 30000,
"retries": 3,
"transport_fallback": ["http", "sse"]
}
}HTTP 客户端示例:
// Initialize MCP connection
const response = await fetch('https://www.freeolmocr.com/api/mcp', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'mk_your_api_key'
},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'initialize',
params: {
protocolVersion: '2024-11-05',
capabilities: { tools: {} }
}
})
});SSE 客户端示例:
// Connect to SSE endpoint
const eventSource = new EventSource(
'https://www.freeolmocr.com/api/mcp?' +
'api_key=mk_your_api_key'
);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};所有 MCP 请求都需要使用以下方法之一进行 API 密钥身份验证:
x-api-key: mk_your_api_key (标头)Authorization: Bearer mk_your_api_key (标头)FETCH_MCP_SERVER_API_KEY=mk_your_api_key (环境变量)curl -X POST https://www.freeolmocr.com/api/mcp \
-H "Content-Type: application/json" \
-H "x-api-key: mk_your_api_key" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list"
}'curl -N -H "Accept: text/event-stream" \
-H "x-api-key: mk_your_api_key" \
https://www.freeolmocr.com/api/mcp即用型代码片段
import requests
import base64
# Base64 method
with open('image.jpg', 'rb') as f:
image_data = base64.b64encode(f.read()).decode()
response = requests.post(
'https://www.freeolmocr.com/api/ocr/process',
headers={'x-api-key': 'mk_your_api_key'},
json={'image': image_data}
)
result = response.json()
print(result['extractedText'])# Base64 method
IMAGE_DATA=$(base64 -i image.jpg)
curl -X POST https://www.freeolmocr.com/api/ocr/process \
-H "x-api-key: mk_your_api_key" \
-H "Content-Type: application/json" \
-d "{\"image\": \"$IMAGE_DATA\"}"