Claude Code 指南
配置 Flaq AI Claude 模型并探索 Claude Code 技能
免费试用 Claude Sonnet 5 文件分析 API,适用于 PDF 审查、图像感知文档推理、提取、摘要和稳定的生产工作流。
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: 'claude-sonnet-5-file-analysis',
messages: [
{
role: 'user',
content: [
{ type: 'text', text: 'Summarize the key points of this PDF.' },
{
type: 'file',
file: {
filename: 'gptproto.pdf',
file_data: 'https://tos.gptproto.com/resource/gptproto.pdf'
}
}
]
}
],
stream: true,
max_tokens: 1000,
top_p: 0.5,
top_k: 50
})
});
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': 'claude-sonnet-5-file-analysis',
'messages': [
{
'role': 'user',
'content': [
{'type': 'text', 'text': 'Summarize the key points of this PDF.'},
{
'type': 'file',
'file': {
'filename': 'gptproto.pdf',
'file_data': 'https://tos.gptproto.com/resource/gptproto.pdf'
}
},
],
}
],
'stream': True,
'max_tokens': 1000,
'top_p': 0.5,
'top_k': 50,
},
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": "claude-sonnet-5-file-analysis",
"messages": [
{
"role": "user",
"content": [
{ "type": "text", "text": "Summarize the key points of this PDF." },
{
"type": "file",
"file": {
"filename": "gptproto.pdf",
"file_data": "https://tos.gptproto.com/resource/gptproto.pdf"
}
}
]
}
],
"stream": true,
"max_tokens": 1000,
"top_p": 0.5,
"top_k": 50
}'
| 参数 | 价格 | 原价 | 折扣 |
|---|
Flaq AI 上的 Claude Sonnet 5 文件分析 API 将 Anthropic 的高级推理、编程和知识工作能力带入以文档为中心的应用。这项可用于生产环境的 Claude API 集成让开发者能够将自然语言指令与受支持的文件和图像结合,用于摘要、提取、比较和详细分析。借助多文件输入、对话式追问、流式响应和灵活的生成控制,团队无需构建单独的文档处理基础设施,即可将复杂的源材料转化为实用答案。
注意 请确保您的提示词、上传文件和应用工作流符合 Anthropic 的安全与使用准则。如果发生错误,请检查输入中是否包含受限或不受支持的内容,简化请求后重试。
Claude Sonnet 5 与 Claude Sonnet 4.6 文件分析对比
Claude Sonnet 4.6 支持可靠的文档推理和专业分析。Claude Sonnet 5 在此基础上进一步增强了任务执行、推理、编程和知识工作表现,适合要求较高的文件工作流。
Claude Sonnet 5 与 Claude Opus 4.8 文件分析对比
Claude Opus 4.8 面向优先采用 Anthropic 最高能力层级的工作负载。Claude Sonnet 5 为可扩展的文件分析提供了 Sonnet 级别的选择,具备更均衡的成本效益表现。
Claude Sonnet 5 与 GPT 5.5 文件分析对比
GPT 5.5 提供先进的 OpenAI 文档和多模态工作流。对于重视 Claude 细致的指令遵循、持续分析能力和 Anthropic 生态系统的团队,Claude Sonnet 5 是一个强有力的替代选择。
Claude Sonnet 5 与 Gemini 文件分析对比
Gemini 模型自然适配以 Google 为中心的多模态和生产力工作流。Claude Sonnet 5 非常适合重视详细推理、结构化整合和对话式审查的文档密集型应用。
Claude Sonnet 5 与开放模型文档处理流程对比
开放模型可以提供部署控制和自定义能力,但需要额外的模型服务与处理基础设施。Claude Sonnet 5 通过 Flaq AI 上面向生产环境的 API 提供托管式文件分析。