Claude Code 指南
設定 Flaq AI Claude 模型並探索 Claude Code 技能
透過 Flaq AI 免費試用由 X-AI 提供支援的 Grok 4.5 Image-to-Text API,適用於視覺問答、OCR、圖片分析及多模態推理。可將圖片內容轉為文字,協助辨識圖片中的文字與資訊,適合整合至視覺理解、圖片問答及多模態分析的應用程式與工作流程,透過 API 串接使用。
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: 'Bearer YOUR_API_KEY',
Accept: 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'grok-4.5-image-to-text',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Describe the image and extract any visible text.' },
{
type: 'image_url',
image_url: {
url: 'https://example.com/sample-image.jpg'
}
}
]
}
],
stream: true,
max_tokens: 2048
})
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
let buffer = '';
let assistantText = '';
while (true) {
const { done, value } = await reader.read();
if (done) break;
buffer += decoder.decode(value, { stream: true });
const frames = buffer.split('\n\n');
buffer = frames.pop() || '';
for (const frame of frames) {
const lines = frame.split('\n').filter(Boolean);
let eventName = 'message';
const dataLines = [];
for (const line of lines) {
if (line.startsWith('event:')) {
eventName = line.slice(6).trim();
} else if (line.startsWith('data:')) {
dataLines.push(line.replace(/^data:\s*/, ''));
}
}
const raw = dataLines.join('\n').trim();
if (raw === '[DONE]') {
console.log('\nFinal text:', assistantText);
continue;
}
let payload;
try {
payload = JSON.parse(raw);
} catch {
continue;
}
if (eventName === 'error' || payload.error) {
const msg = payload.error?.message ?? payload.message ?? 'Chat request failed';
throw new Error(msg);
}
const delta = payload.choices?.[0]?.delta;
if (delta?.content) {
assistantText += delta.content;
console.log(assistantText);
}
}
}
import json
import requests
response = requests.post(
'https://api.flaq.ai/api/v1/chat/completions',
headers={
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json',
},
json={
'model': 'grok-4.5-image-to-text',
'messages': [
{
'role': 'user',
'content': [
{'type': 'text', 'text': 'Describe the image and extract any visible text.'},
{
'type': 'image_url',
'image_url': {
'url': 'https://example.com/sample-image.jpg'
}
},
],
}
],
'stream': True,
'max_tokens': 2048,
},
stream=True,
)
response.raise_for_status()
event_name = 'message'
assistant_text = ''
for raw_line in response.iter_lines(decode_unicode=True):
if not raw_line:
event_name = 'message'
continue
if raw_line.startswith('event:'):
event_name = raw_line.replace('event:', '', 1).strip()
continue
if raw_line.startswith('data:'):
raw_data = raw_line.replace('data:', '', 1).strip()
if raw_data == '[DONE]':
print('\nFinal text:', assistant_text)
continue
payload = json.loads(raw_data)
if event_name == 'error' or payload.get('error'):
error = payload.get('error') or payload
raise RuntimeError(error.get('message', 'Chat request failed'))
choices = payload.get('choices') or []
if choices:
delta = choices[0].get('delta') or {}
content = delta.get('content')
if content:
assistant_text += content
print(content, end='', flush=True)
curl -N -X POST "https://api.flaq.ai/api/v1/chat/completions" \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Accept: text/event-stream" \
-H "Content-Type: application/json" \
-d '{
"model": "grok-4.5-image-to-text",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Describe the image and extract any visible text." },
{
"type": "image_url",
"image_url": {
"url": "https://example.com/sample-image.jpg"
}
}
]
}
],
"stream": true,
"max_tokens": 2048
}'
| 參數 | 價格 | 原價 | 折扣 |
|---|
Grok 4.5 圖片轉文字 API 提供一種專用方式,讓您能透過 Flaq AI 使用 xAI 的多模態 Grok 4.5 模型理解圖片。提交一張支援的圖片及選用的文字指示,即可收到根據視覺上下文產生的文字回應。目前的 Flaq AI 路由專為單張圖片分析、視覺問答和以圖片為基礎的對話而設計,並不代表支援一般檔案附件或圖片生成。
注意 圖片解讀和可見文字擷取可能不完整或不準確,尤其是遇到較小的文字、含義模糊的場景、低畫質圖片或專業內容時。使用前請審查重要結果。此路由支援一張圖片,不提供一般檔案輸入或圖片生成。
Grok 4.5 圖片轉文字與 Grok 4.5 文字轉文字比較 圖片轉文字接受視覺上下文並傳回文字,而對於不含圖片的請求,文字轉文字是更直接的選擇。
Grok 4.5 圖片轉文字與專用 OCR 比較 專用 OCR 系統專為確定性文字擷取和文件處理流程而建置。Grok 4.5 可以結合上下文討論可見內容和文字,但不應將其視為對準確度要求較高的 OCR 的可靠替代方案。
Grok 4.5 圖片轉文字與圖片描述模型比較 圖片描述模型通常著重於簡短描述。多模態聊天工作流程還可以回答使用者提供的問題,但輸出品質仍取決於圖片和指示。
Grok 4.5 圖片轉文字與其他多模態 LLM API 比較 主流多模態 API 在輸入限制、模型行為、延遲和平台功能方面各不相同。選擇供應商前,請使用具代表性的圖片和特定任務的驗收標準進行評估。
Grok 4.5 圖片轉文字與自行託管的視覺模型比較 自行託管的視覺模型能提供部署控制權,但會增加基礎架構和維護工作。對於偏好以託管方式存取 Grok 4.5 的團隊,Flaq AI 提供代管式單張圖片聊天路由。