Integrasikan Mistral OCR ke dalam aplikasi anda dengan REST API kami yang berkuasa. Sokongan untuk pelbagai kaedah muat naik dan pengesahan yang fleksibel.
Log masuk ke akaun anda dan jana kunci API daripada halaman tetapan.
Pergi ke TetapanPilih antara pengekodan Base64 (untuk fail kecil) atau muat naik URL (untuk fail besar).
Hantar imej atau PDF anda ke API OCR kami dan terima data teks berstruktur sebagai respons.
Ekstrak teks daripada imej dan PDF
POST https://www.mistralocr.app/api/ocr/process
{
"image": "base64_encoded_image_data",
"options": {
"format": "text" # json, text, markdown
}
}
{
"imageUrl": "https://img.mistralocr.app/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
}
Sertakan kunci API anda dalam permintaan
Pilihan 1: tajuk x-api-key
x-api-key: mk_your_api_key_here
Pilihan 2: Tajuk Kebenaran
Authorization: Bearer mk_your_api_key_here
Protokol Konteks Model untuk ejen dan alat AI
Titik Akhir HTTP/JSON-RPC:
POST https://www.mistralocr.app/api/mcp
Titik Akhir Penstriman SSE:
GET https://www.mistralocr.app/api/mcp
Ekstrak teks daripada dokumen dan imej menggunakan OCR. Menyokong fail PDF, imej JPEG, PNG, WebP. Menerima kedua-dua data base64 dan URL (pemprosesan segerak)
Gunakan alat MCP dalam Kursor untuk analisis kod dan pengekstrakan dokumentasi daripada imej.
Konfigurasi MCP: cursor_mcp_config.json
{
"mcp": {
"servers": {
"mistral-ocr": {
"url": "https://www.mistralocr.app/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"
]
}
}
Penggunaan dalam Kursor:
@ocr
Bina pelanggan MCP anda sendiri atau berintegrasi dengan alat AI lain menggunakan titik akhir HTTP/SSE kami.
Konfigurasi Pelanggan Generik: mcp_config.json
{
"mcp": {
"servers": {
"mistral-ocr": {
"url": "https://www.mistralocr.app/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"]
}
}
Contoh Pelanggan HTTP:
// Initialize MCP connection
const response = await fetch('https://www.mistralocr.app/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: {} }
}
})
});
Contoh Pelanggan SSE:
// Connect to SSE endpoint
const eventSource = new EventSource(
'https://www.mistralocr.app/api/mcp?' +
'api_key=mk_your_api_key'
);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received:', data);
};
Semua permintaan MCP memerlukan pengesahan kunci API menggunakan salah satu daripada kaedah ini:
x-api-key: mk_your_api_key
(pengepala)Authorization: Bearer mk_your_api_key
(pengepala)FETCH_MCP_SERVER_API_KEY=mk_your_api_key
(pemboleh ubah persekitaran)curl -X POST https://www.mistralocr.app/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.mistralocr.app/api/mcp
Coretan kod sedia untuk digunakan
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.mistralocr.app/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.mistralocr.app/api/ocr/process \
-H "x-api-key: mk_your_api_key" \
-H "Content-Type: application/json" \
-d "{\"image\": \"$IMAGE_DATA\"}"
Mulakan dengan cepat dengan API kami atau hubungi untuk mendapatkan sokongan.