试用 xAI 的 Grok 4.6 API,通过 Flaq AI 稳定的统一 API,进行图像转文本、视觉问答、OCR、分析和流式多模态响应。帮助理解图像内容并提取重要文字信息。
Grok 4.6 相关模型
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.6-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.6-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.6-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.6 Image to Text 价格
| 参数 | 价格 | 原价 | 折扣 |
|---|
README
Grok 4.6 Image-to-Text API(视觉推理与分析)
Grok 4.6 Image-to-Text API 在 Flaq AI 上将 xAI 面向推理的文本模型与图像理解能力相结合。它让 应用能够将针对性的视觉输入与指令一并发送,然后接收用于说明、提取、比较 或分析图像内容的文本。这项 Grok 视觉 API 集成专为需要将视觉依据 转化为可执行回答、技术观察或结构化后续步骤的工作流而设计。
Grok 4.6 Image-to-Text API 的主要功能
-
基于图像的分析: 针对所提供的图像提出问题,并获得与可见细节、 布局、对象和上下文相关的文本回答。
-
视觉到文本推理: 将图像与自然语言指令相结合,用于说明、比较、 故障排查和分析工作流。
-
专注的图像输入: 为路由提供已配置的图像输入和明确的任务指令,使 图像问答工作流能够直接完成集成。
-
技术检查辅助: 将视觉上下文用于界面审查、屏幕截图解读、图表 说明、产品反馈分类以及类似的文本输出任务。
-
可控的对话请求: 将图像问题与结构化消息上下文配对,使应用能够 提供任务框架、先前要求和后续提示词。
-
以文本为先的结果: 接收可供审查、展示、路由或下游工作流使用的生成文本, 而不是将该路由作为图像生成端点。
如何在 Flaq AI 上使用 Grok 4.6 Image-to-Text API
-
输入: 一张受支持的图像以及用自然语言描述问题、提取目标或 分析任务的请求。
-
输出: 用于描述、说明、比较或分析所提供视觉内容的文本回答。
-
图像传送: 在应用工作流中使用已配置的 Flaq AI 请求格式传入图像。
-
能力: 屏幕截图分析、视觉问答、基于图像的说明、内容审查和 细节提取。
Grok 4.6 Image-to-Text API 集成的最佳用例
-
屏幕截图与 UI 审查: 说明界面、识别可见状态、汇总反馈,或将屏幕截图 转化为可供开发者直接处理的问题描述。
-
产品与目录辅助: 提取可观察到的产品细节、生成属性草稿,并为人工 审查视觉提交内容提供支持。
-
技术支持分类: 帮助团队解读错误屏幕截图、设备照片或设置图像,之后再将 案例转交给运营人员。
-
文档与图表说明: 将图形、图表、幻灯片和视觉参考资料转化为清晰的文本 观察结果和后续问题。
-
内容运营: 支持审核队列、无障碍内容起草和图像描述工作流,同时 保留由人工进行最终审查。
注意 在将图像理解结果用于影响重大、安全关键、法律、医疗或 金融决策之前,应对其进行审查。请勿将生成文本作为专业检查的替代品。
Grok 4.6 Image-to-Text API 与竞品对比:比较分析
-
Grok 4.6 Image-to-Text 与 Grok 4.5 Image-to-Text 对比
Grok 4.5 为视觉 问答工作流提供了成熟选择。Grok 4.6 则是更新一代的模型,适合希望评估更强图像 推理请求能力的团队。 -
Grok 4.6 Image-to-Text 与 Gemini 3.7 Flash Image-to-Text 对比
Gemini 3.7 Flash 提供高效的多模态模型 家族。Grok 4.6 Image-to-Text 则提供专注的 Flaq 路由,适合希望在 视觉输入、文本输出工作流中测试 xAI 视觉推理的团队。 -
Grok 4.6 Image-to-Text 与 GPT 5.6 Terra Image-to-Text 对比
GPT 5.6 Terra 视觉模型常用于通用多模态任务。 如果工作流在视觉分析之外还重视 xAI 面向推理与编程的模型家族, Grok 4.6 便是实用的替代方案。 -
Grok 4.6 Image-to-Text 与 Claude Vision 对比
Claude 视觉模型非常适合说明和 文档类任务。Grok 4.6 Image-to-Text 为开发者提供了另一个 API 选项,可用于基于图像的问题、 审查和运营工作流。 -
Grok 4.6 Image-to-Text 与 Gemini 3.6 Flash Image-to-Text 对比
Gemini 3.6 Flash 兼顾广泛的多模态能力 与高效运行。当视觉请求还需要详细的文本技术 推理时,Grok 4.6 是值得评估的有力候选模型。