Local tool
Claude API Response Lab
Inspect Batch JSONL, tool-use SSE, and PDF citations in your browser, with Message API examples and retry decisions.
Sources checked:
What you can do
Find the next action for a Claude API response
Replay a response locally or download a request fixture. Start with a synthetic sample, then compare it with a redacted response from your integration.
Build your execution checklist
Inputs are processed in this browser only and cleared when you close or refresh the page.
You have independent requests and need a deadline and cost comparison.
Read the full steps
Batch or synchronous?
You have independent requests and need a deadline and cost comparison.
- Choose Batch when the caller can wait up to the documented 24-hour processing window. Choose a synchronous request when a user is waiting on the same interaction.
- Estimate synchronous token cost from model-specific input and output prices. Multiply those token charges by 0.5 for Batch, then account for applicable tools or other separately priced items.
- For example, $20 of equivalent synchronous model token usage is $10 in Batch before separately priced items. Record a results-retrieval deadline and reconcile with the original manifest.
Reconcile a batch and retry selectively
Rows seem missing, expired, or out of order.
- Keep a manifest of unique custom_id values and wait for the batch to end. Paste the manifest IDs and result JSONL above.
- Keep succeeded rows. For expired or canceled rows, resubmit only the work still needed. For invalid requests fix the input first; inspect other errors before retrying.
- An ID absent from the downloaded results calls for checking the expected manifest, completeness of the download, and batch counters before any resubmission.
Request schema-constrained JSON
You need a typed record rather than free-form text.
- Set output_config.format.type to json_schema and supply the schema. Use the separate strict setting on tool definitions to constrain tool arguments.
- Start with the two-field sample and parse the response's text content. Validate required fields and business rules on the application side.
- Handle refusal and token truncation before accepting the payload. The fixture represents a request body, with no key or network call included.
Template preview: claude-structured-output-request.json
{
"model": "claude-haiku-5-5",
"max_tokens": 512,
"messages": [
{
"role": "user",
"content": "Extract the reference and currency. Record: Ref Q-012, EUR 20."
}
],
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"reference": {
"type": "string"
},
"currency": {
"type": "string",
"enum": [
"EUR",
"USD"
]
}
},
"required": [
"reference",
"currency"
],
"additionalProperties": false
}
}
}
}Assemble streamed tool inputs
input_json_delta fragments fail JSON parsing.
- Group input_json_delta fragments by content-block index. Preserve their order and parse the combined string after content_block_stop.
- Load the synthetic SSE above. The two fragments assemble to a single currency argument; an open or malformed block leaves the parsed input absent.
- Before dispatch, require a complete response and validate against the tool schema. Handle stream error events even if the HTTP status was 200.
Act on max_tokens, pause_turn, and tool_use
A successful HTTP response ended unexpectedly.
- On max_tokens, inspect truncation. If it cut a tool-use block, retry the original request with an appropriate larger output budget.
- On pause_turn, append the paused assistant content unchanged and send the same tool context. If a container is returned, pass its ID back.
- On tool_use, complete the client-side tool calls and send their tool_result blocks. For end_turn, handle the answer normally.
Evaluate PDF table extraction
You need normalized rows with totals you can reconcile.
- Prepare one native PDF and one scan with known results, including a split table, a blank field, and a negative number.
- Send the source as a PDF document block and ask for row identifiers, amount, currency, and a missing-data flag. Use structured output for the record shape.
- Compare row by row and reconcile totals separately. Escalate unreadable cells; never infer an amount from the total alone.
Template preview: pdf-table-expected.csv
row_id,amount,currency,missing A-001,14.50,EUR,false A-002,-3.00,EUR,false A-003,,EUR,true
Map PDF citations to page ranges
You need to trace answers back to a page.
- Enable citations in the PDF document block. Read citations attached to response text blocks.
- For page_location, document_index starts at zero. The first page number is one and the end-page number is exclusive. Load the PDF sample above to see the display mapping.
- Use a separate citation request if you also need schema-constrained output. Citations reference extractable text, so test scanned or image-only pages before relying on locations.
Budget web search calls and tokens
You need to price a search-assisted request.
- Use the Claude API web-search tool price of $10 per 1,000 searches and add model token charges. At 25 searches, the tool line item is $0.25.
- Set max_uses for the call and capture server_tool_use.web_search_requests plus usage. Search result text contributes to input tokens.
- Keep result citations and handle tool errors. Budget against actual searches rather than treating every Messages call as one search.
Prepare a custom API Skill
You need a reusable workflow in the Messages API container.
- Create a skill directory with SKILL.md and put supporting files inside it. Validate your organization's eligibility to use the code execution tool.
- Upload the directory's files through the Skills API and retain its skill ID and version. Pass the custom skill ID, type, and intended version in container.skills together with code execution.
- Test with a synthetic input in an isolated account. Check the output file or response against expected fields. API Skills run inside a code-execution container and the documentation marks the feature ineligible for ZDR.
Template preview: SKILL.md
--- name: normalize-office-rows description: Normalize synthetic office expense rows into a documented field shape. --- Return row_id, amount, and currency for each input row. Flag missing fields. Preserve the original row order.
Scope & limits
- The lab parses captured responses and synthetic samples. It does not call Anthropic or run tools.
- PDF extraction accuracy and model performance need an evaluation on your own documents.
Questions & answers
- Why does the batch order differ from my submitted list?
- Join by custom_id. Results stream as JSONL and may arrive in a different order.
- When can I invoke a tool from a streamed tool-use block?
- After the block closes, parse its accumulated JSON and validate its input against your tool schema. Check the completed message's stop reason before the tool loop.
Verified sources
- Message Batches
- Claude API pricing
- Structured outputs
- Streaming Messages
- Handling stop reasons
- PDF support
- Citations
- Web search tool
- Agent Skills in the API
Templates are authored by Kunavo. External product behavior depends on the linked sources and your account settings.