Uses OCR and chat completion to answer questions about document content.
POST
/v1/chat/completions
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 model to use.
document
string
Required
Base64 encoded document or document URL.
question
string
Required
The question to ask about the document.
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 completion.
choices
array<Choice>
Required
The list of completion choices with answers.
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 answer = await alphaedge.chat.completions.create({
model: 'alphaedge-ocr-3-2512',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'What is the total amount?' },
{ type: 'image_url', image_url: { url: 'data:image/png;base64,...' } }
]
}
]
});
python
from alphaedge import AlphaEdge
alphaedge = AlphaEdge(api_key="your-api-key")
answer = alphaedge.chat.completions.create(
model="alphaedge-ocr-3-2512",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What is the total amount?"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
]
}
]
)
curl
curl https://api.alphaedge-ai.com/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $ALPHAEDGE_API_KEY" \
-d '{
"model": "alphaedge-ocr-3-2512",
"messages": [{
"role": "user",
"content": [
{"type": "text", "text": "What is the total amount?"},
{"type": "image_url", "image_url": {"url": "data:image/png;base64,..."}}
]
}]
}'
Response
Exemple de réponse de l'API :
json
{
"id": "chat-abc123",
"object": "chat.completion",
"model": "alphaedge-ocr-3-2512",
"choices": [
{
"message": {
"role": "assistant",
"content": "The total amount is $100.50"
}
}
]
}