Document Parsing Service Guide

Our document parsing service uses advanced models such as claude-3-7-sonnet-latest and deepseek-r1 to extract and analyze content from multiple document formats through XAI XAPI. The service can process single or multiple files and return relevant results based on user prompts.

Supported File Formats

We support the following 7 file types:

  • PDF (.pdf)
  • Text files (.txt, .sh, .py, .js, etc.)
  • Word documents (.doc, .docx)
  • Excel spreadsheets (.xls, .xlsx)
  • CSV files (.csv)
  • Markdown files (.md, .markdown)
  • HTML files (.html, .htm)

Usage Limits

  • A single PDF must be no larger than 4.5MB.
  • Up to 5 files can be processed in one conversation.

API Endpoints

Two main endpoints are available (Claude/OpenAI compatible):

  1. ${BASE_URL}/v1/messages (Claude format)
  2. ${BASE_URL}/v1/chat/completions (OpenAI format)

Recommended setup:

export BASE_URL="https://api.xaicontrol.com"

Usage Examples

Example 1: Process one document (Claude format)

API_KEY="YOUR_XAI_API_KEY"

curl ${BASE_URL}/v1/messages \
   -H "content-type: application/json" \
   -H "x-api-key: $API_KEY" \
   -H "anthropic-version: 2023-06-01" \
   -d '{
     "model": "claude-3-7-sonnet-latest",
     "max_tokens": 1024,
     "messages": [{
         "role": "user",
         "content": [{
             "type": "document",
             "source": {
                 "type": "url",
                 "url": "https://cfbed.1314883.xyz/file/1744972227336_test-1.pdf"
             }
         },
         {
             "type": "text",
             "text": "Extract key information from this document."
         }]
     }]
 }'

Example 2: Process one document (OpenAI format)

API_KEY="YOUR_XAI_API_KEY"

curl -X POST "${BASE_URL}/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "claude-3-7-sonnet-latest",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "url",
              "url": "https://cfbed.1314883.xyz/file/1744972223519_test.docx"
            }
          },
          {
            "type": "text",
            "text": "Summarize the main content of this document."
          }
        ]
      }
    ],
    "max_tokens": 1000
  }'

Example 3: Process multiple documents

API_KEY="YOUR_XAI_API_KEY"

curl -X POST "${BASE_URL}/v1/chat/completions" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "claude-3-7-sonnet-latest",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "document",
            "source": {
              "type": "url",
              "url": "https://cfbed.1314883.xyz/file/1744972223519_test.xlsx"
            }
          },
          {
            "type": "document",
            "source": {
              "type": "url",
              "url": "https://cfbed.1314883.xyz/file/1744972227336_test.pdf"
            }
          },
          {
            "type": "text",
            "text": "Compare the data differences between these two documents."
          }
        ]
      }
    ],
    "max_tokens": 1000
  }'
Please make sure all files comply with size limits and each request includes no more than 5 files.