SurgeAI
  1. openai-format
SurgeAI
  • SurgeAI
    • SurgeAI核心优势
    • 快速开始
    • 认证
    • 如何使用
      • OpenClaw
      • Codex
      • 聊天应用
      • Claude Code
      • Dify
    • API参考
      • OpenAI
        • gpt-5
          • official-format
            • gpt-5 (网络搜索 (Response))
            • gpt-5 (文本转文本)
            • gpt-5 (文本转文本)
            • gpt-5 (图像转文本 (Chat))
            • gpt-5 (图像转文本 (Response))
            • gpt-5 (文件分析)
        • gpt-4o
          • official-format
            • gpt-4o (网络搜索 (Response))
            • gpt-4o (文本转文本 (Response))
            • gpt-4o (文本转文本 (Chat))
            • gpt-4o (图像转文本 (Chat))
            • gpt-4o (图像转文本 (Response))
            • gpt-4o (文件分析 (Response))
        • gpt-4.1
          • official-format
            • gpt-4.1 (联网搜索)
            • gpt-4.1 (文本转文本)
            • gpt-4.1 (文本转文本)
            • gpt-4.1 (图像分析)
            • gpt-4.1 (图像分析)
            • gpt-4.1 (文件分析)
      • Vidu
        • viduq3-pro
          • gptproto-format
            • viduq3-pro (Image To Video)
            • viduq3-pro (Text To Video)
        • viduq2-pro
          • gptproto-format
            • viduq2-pro (Image To Video)
            • viduq2-pro (Text To Video)
      • Suno
        • suno-music
          • official-format
            • official-format (查询任务)
            • official-format (文本转音频)
      • Midjourney
        • Midjourney
          • task-submission
            • midjourney (imagine)
          • task-query
            • midjourney (fetchfromtask)
      • Grok
        • grok-3
          • openai-format
            • grok-3 (文本转文本 (聊天))
        • grok-4
          • openai-format
            • grok-4 (文本转文本 (聊天))
      • DeepSeek
        • deepseek-v3.2
          • openai-format
            • deepseek-v3.2 (文本转文本)
      • Alibaba
        • qwen-plus
          • openai-format
            • qwen-plus (文本转文本)
        • qwen3-max
          • openai-format
            • qwen3-max (文本转文本)
        • wan-2.5-preview
          • gptproto-format
            • wan-2.5-preview (图片编辑)
            • wan-2.5-preview (查询任务)
            • wan-2.5-preview (图生视频)
            • wan-2.5-preview (文生图)
            • wan-2.5-preview (文生视频)
        • qwen-turbo
          • openai-format
            • qwen-turbo (文本转文本)
      • MiniMax
        • hailuo-02-pro
          • gptproto-format
            • hailuo-02-pro (图生视频)
            • hailuo-02-pro (文生视频)
      • Kling
        • kling-v2.1-pro
          • gptproto-format
            • kling-v2.1-pro (图生视频)
            • kling-v2.1-pro (文生视频)
        • kling-v3.0-pro
          • gptproto-format
            • kling-v3.0-pro (图生视频)
            • kling-v3.0-pro (文生视频)
      • Claude
        • claude-haiku-4-5-20251001
          • official-format
            • claude-haiku-4-5-20251001 (联网搜索)
            • claude-haiku-4-5-20251001 (文件分析)
            • claude-haiku-4-5-20251001 (文本生成)
          • openai-format
            • claude-haiku-4-5-20251001 (联网搜索)
            • claude-haiku-4-5-20251001 (文件分析)
            • claude-haiku-4-5-20251001 (文本生成)
      • Google
        • gemini-2.5-flash
          • official-format
            • gemini-2.5-flash (联网搜索)
            • gemini-2.5-flash (文件分析)
            • gemini-2.5-flash (文本生成)
            • gemini-2.5-flash (图像理解)
        • gemini-2.5-pro
          • official-format
            • gemini-2.5-pro (联网搜索)
            • gemini-2.5-pro (文件分析)
            • gemini-2.5-pro (文本生成)
            • gemini-2.5-pro (图像理解)
      • Runway
        • runwayml-gen3a_turbo-5
          • official-format
            • official-format (提交视频生成任务)
            • official-format (查询任务)
  1. openai-format

claude-haiku-4-5-20251001 (文件分析)

来源: https://docs.surgeai.one/docs/allapi/Claude/claude-haiku-4-5-20251001/openai-format/file-analysis
使用 Claude 3.5 Haiku 分析和提取各种文件类型的信息,包括文档、电子表格和 PDF

Claude 文件分析 API 的 OpenAI 格式。

身份验证#

1.
在 https://surgeai.one 注册 SurgeAI 账户
2.
在控制台中导航到 API Keys 部分
3.
生成一个新的 API 密钥 (sk-xxxxx)
4.
复制并安全存储您的 API 密钥

响应示例#

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1699896916,
  "model": "claude-haiku-4-5-20251001",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "# Document Analysis Summary\n\n## Key Information:\n- Document Type: Technical API Documentation\n- Total Pages: 35\n- Version: 2.0\n\n## Main Topics:\n1. **Authentication**: The API uses Bearer token authentication with API keys\n2. **Endpoints**: Contains 12 main API endpoints for different operations\n3. **Rate Limiting**: Implements tiered rate limiting based on subscription level\n4. **Error Handling**: Comprehensive error codes and handling strategies\n\n## Key Sections:\n\n### Getting Started\n- Quick start guide for new developers\n- Authentication setup instructions\n- First API call examples in multiple languages\n\n### API Reference\n- Detailed endpoint documentation\n- Request/response formats\n- Parameter descriptions and constraints\n\n### Best Practices\n- Recommended usage patterns\n- Performance optimization tips\n- Security considerations\n\n### Code Examples\n- Python, JavaScript, Go, and cURL examples\n- Common use case implementations\n- Error handling patterns\n\n## Important Notes:\n- All requests must include valid API key\n- Rate limits: 100 requests/minute for free tier, 1000/minute for premium\n- Support for both JSON and XML response formats\n- Webhook notifications available for asynchronous operations"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 3500,
    "completion_tokens": 285,
    "total_tokens": 3785
  }
}

核心参数#

参数类型必填默认值范围描述
modelstring是claude-haiku-4-5-20251001-模型标识符。此模型使用 claude-haiku-4-5-20251001
messagesarray是--对话的输入消息。每条消息必须包含 role(user/assistant/system)和 content。内容可以包含文本块或文件块。支持的格式:PDF、DOCX、XLSX、TXT、CSV、JSON、XML、HTML。最大文件大小:20MB。
max_tokensinteger否10241-64000生成的最大 token 数量。模型可能会在此限制之前停止
temperaturenumber否1.00.0-2.0控制输出的随机性。对于分析任务使用较低的值(接近 0.0),对于创意任务使用较高的值
top_pnumber否1.00.0-1.0核采样阈值。通过仅考虑累积概率达到 top_p 的 token 来控制多样性。
streamboolean否false-是否使用服务器发送事件逐步流式传输响应
stopstring/array否null最多 4 个序列最多 4 个序列,API 将在遇到这些序列时停止生成更多 token
presence_penaltynumber否0-2.0-2.0根据 token 是否出现在当前文本中来对其进行惩罚。正值增加模型谈论新话题的可能性
frequency_penaltynumber否0-2.0-2.0根据 token 在当前文本中的出现频率来对其进行惩罚。正值降低模型重复相同内容的可能性

消息结构#

带文件的基本结构(URL):#

{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Please analyze this document"
    },
    {
      "type": "file",
      "file": {
        "filename": "document.pdf",
        "file_data": "https://example.com/document.pdf"
      }
    }
  ]
}

使用 Base64:#

{
  "type": "file",
  "file": {
    "filename": "document.pdf",
    "file_data": "data:application/pdf;base64,JVBERi0xLjQK..."
  }
}

Messages 数组结构#

字段类型必填描述
rolestring是消息的角色。可以是:user、assistant 或 system
contentarray/string是消息的内容。可以是字符串或内容块数组

内容块结构#

文本内容块#

字段类型必填描述
typestring是必须是 text
textstring是文本内容

文件内容块#

字段类型必填描述
typestring是必须是 file
fileobject是包含 filename 和 file_data 的文件对象

文件对象结构#

字段类型必填描述
filenamestring是文件名称(例如:document.pdf)
file_datastring是文件的 URL 或使用 data URI 方案的 base64 编码数据(例如:data:application/pdf;base64,<base64_data>)

支持的文档格式#

格式MIME 类型扩展名
PDFapplication/pdf.pdf
Wordapplication/vnd.openxmlformats-officedocument.wordprocessingml.document.docx
Excelapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet.xlsx
纯文本text/plain.txt
CSVtext/csv.csv
JSONapplication/json.json
XMLapplication/xml 或 text/xml.xml
HTMLtext/html.html
注意:最大文件大小为 20MB。

错误码#

错误码错误名称描述
401UnauthorizedAPI 密钥缺失或无效
403Forbidden您的 API 密钥没有访问此资源的权限,或请求操作的余额不足
429Too Many Requests您已超出速率限制
500Internal server error发生内部服务器错误
503Content policy violation内容因安全问题被阻止(实际状态码为 400)
修改于 2026-03-11 06:24:05
上一页
claude-haiku-4-5-20251001 (联网搜索)
下一页
claude-haiku-4-5-20251001 (文本生成)
Built with