Extracts structured data from documents with predefined schemas.
POST
/v1/ocr
Request Body
Les paramètres suivants peuvent être inclus dans le corps de la requête :
Paramètres
model
string
Required
Default Value:
alphaedge-ocr-3-2512
ID of the OCR model to use.
image
string
Required
Base64 encoded image or image URL.
structured_output
boolean
Required
Default Value:
true
Whether to return structured output. Must be true.
schema
object
JSON schema defining the structure of the output.
Successful Response
Les champs suivants sont retournés dans une réponse réussie :
Champs de réponse
id
string
Required
A unique identifier for the OCR result.
structured_data
object
Required
The structured data extracted according to the schema.
Examples
Exemples de code pour utiliser cet endpoint :
typescript
import { AlphaEdge } from '@alphaedge/alphaedge';
const alphaedge = new AlphaEdge({
apiKey: process.env.ALPHAEDGE_API_KEY,
});
const result = await alphaedge.ocr.create({
model: 'alphaedge-ocr-3-2512',
image: 'data:image/png;base64,...',
structured_output: true,
schema: {
type: 'object',
properties: {
total: { type: 'number' },
items: { type: 'array' }
}
}
});
python
from alphaedge import AlphaEdge
alphaedge = AlphaEdge(api_key="your-api-key")
result = alphaedge.ocr.create(
model="alphaedge-ocr-3-2512",
image="data:image/png;base64,...",
structured_output=True,
schema={
"type": "object",
"properties": {
"total": {"type": "number"},
"items": {"type": "array"}
}
}
)
curl
curl https://api.alphaedge-ai.com/v1/ocr \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ALPHAEDGE_API_KEY" \
-d '{
"model": "alphaedge-ocr-3-2512",
"image": "data:image/png;base64,...",
"structured_output": true,
"schema": {
"type": "object",
"properties": {
"total": {"type": "number"},
"items": {"type": "array"}
}
}
}'
Response
Exemple de réponse de l'API :
json
{
"id": "ocr-abc123",
"object": "ocr.result",
"model": "alphaedge-ocr-3-2512",
"structured_data": {
"total": 100.50,
"items": ["item1", "item2"]
}
}