Anthropic logo

HOSTED MOCK API REFERENCE

Anthropic Messages API mock: content blocks and stream failures

Exercise message and content-block progress independently of text rendering. Test partial-output errors and clean cutoff against a completed Messages stream. Tool-use blocks let your client practise dispatch and validation without executing a tool.

Explore mock APIs

New registration is paused. Explore the public mock APIs; existing users can still sign in.

Existing user? Configure Anthropic Messages API · Workspace pricing and limits · Supported operations and behaviours

What to assert in your client

Samples include the synthetic API-key and request-version headers used by this module. No conversation state is stored and no model or tool runs. An overload response is a selected fixture; partial output and clean EOF do not imply message_stop or successful completion.

Request and selected response examples

Create Message: API overloaded

Documented Synthetic illustrative example from the catalogue, not a live capture. Run only after installing your own receiver. Replace <your-receiver-token> locally; no request is sent from this page.

HTTP 529 · overloaded_error

curl / Bash request

printf '%s' '{"model":"claude-sonnet-5-5","max_tokens":64,"messages":[{"role":"user","content":"Hello"}]}' | \
curl -i -X POST \
  'https://nottherealapi.com/r/<your-receiver-token>/v1/messages' \
  -H 'x-api-key: synthetic-anthropic-key' \
  -H 'anthropic-version: 2023-06-01' \
  -H 'Content-Type: application/json' \
  --data-binary @-

PowerShell request

$body = '{"model":"claude-sonnet-5-5","max_tokens":64,"messages":[{"role":"user","content":"Hello"}]}'
Invoke-WebRequest `
    -UseBasicParsing `
    -Uri 'https://nottherealapi.com/r/<your-receiver-token>/v1/messages' `
    -Method POST `
    -Headers @{
    'x-api-key' = 'synthetic-anthropic-key'
    'anthropic-version' = '2023-06-01'
    } `
    -ContentType 'application/json' `
    -Body ([Text.Encoding]::UTF8.GetBytes($body))

Selected synthetic response

HTTP 529
content-type: application/json

{
  "type": "error",
  "error": {
    "type": "overloaded_error",
    "message": "Overloaded"
  },
  "request_id": "req_example_004"
}

Stream Message: Error after partial output

Documented Synthetic illustrative example from the catalogue, not a live capture. Run only after installing your own receiver. Replace <your-receiver-token> locally; no request is sent from this page.

HTTP 200 · SSE · Stream error after partial output

curl / Bash request

printf '%s' '{"model":"claude-sonnet-5-5","max_tokens":64,"stream":true,"messages":[{"role":"user","content":"Hello"}]}' | \
curl -i --no-buffer -X POST \
  'https://nottherealapi.com/r/<your-receiver-token>/v1/messages' \
  -H 'x-api-key: synthetic-anthropic-key' \
  -H 'anthropic-version: 2023-06-01' \
  -H 'Content-Type: application/json' \
  --data-binary @-

PowerShell request

$body = '{"model":"claude-sonnet-5-5","max_tokens":64,"stream":true,"messages":[{"role":"user","content":"Hello"}]}'
Invoke-WebRequest `
    -UseBasicParsing `
    -Uri 'https://nottherealapi.com/r/<your-receiver-token>/v1/messages' `
    -Method POST `
    -Headers @{
    'x-api-key' = 'synthetic-anthropic-key'
    'anthropic-version' = '2023-06-01'
    } `
    -ContentType 'application/json' `
    -Body ([Text.Encoding]::UTF8.GetBytes($body))

Selected synthetic response

HTTP 200
content-type: text/event-stream; charset=utf-8

event: message_start
data: {"type":"message_start","message":{"id":"msg_example_001","type":"message","role":"assistant","content":[],"model":"claude-sonnet-5-5","stop_reason":null,"stop_sequence":null,"usage":{"input_tokens":12,"output_tokens":0}}}

event: content_block_start
data: {"type":"content_block_start","index":0,"content_block":{"type":"text","text":""}}

event: content_block_delta
data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"Partial"}}

event: error
data: {"type":"error","error":{"type":"overloaded_error","message":"Overloaded"}}

Events above are the fixed fixture sequence. Delivery timing is simulated; see the full behaviour list for completion, error and early EOF choices.

AI Messages API · 2023-06-01

What can I test with this?

Test a Messages API client without calling Anthropic or using a real API key. Reproduce completed messages, the SSE content-block lifecycle and tool-use requests. Exercise validation, model access, rate limits, billing and usage caps, overload, timeouts, partial streams and malformed response bodies.

Messages request version 2023-06-01. Fixed output; tools are returned for client handling. No tool execution or conversation state. Interrupted streams use clean EOF before completion.

Useful for

  • Messages client integration
  • Content-block streaming
  • Tool use
  • Billing and usage handling
  • Partial output and deadlines

Supported operations

3 operations

Create Message

POST /v1/messages

Sends model, max_tokens and conversation messages as JSON. Receives a completed message with content and usage, or the selected failure response.

Request content type: application/json

Request example

{
  "model": "claude-sonnet-5-5",
  "max_tokens": 64,
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}

Available behaviours (12)

  • Message completed
    Representative

    Representative Messages API response with content block and usage.

    HTTP 200

    Verify that your client handles a successful response.

  • Invalid API key
    Documented

    Anthropic authentication error envelope.

    HTTP 401 · authentication_error

    Test credential refresh and authentication recovery.

  • Malformed Messages request
    Documented

    Missing or invalid request field.

    HTTP 400 · invalid_request_error

    Test field mapping and useful validation feedback.

  • Rate limit exceeded
    Documented

    Transient rate-limit response; reset headers are representative and values vary.

    HTTP 429 · rate_limit_error · Retry-After: 10

    Verify bounded backoff and retry handling.

    • Wait until the documented reset time before retrying.
  • API overloaded
    Documented

    Anthropic documents overloaded_error with HTTP 529.

    HTTP 529 · overloaded_error

    Test recovery and error reporting during simulated service failures.

  • Model access denied
    Representative

    Representative authorization failure for an unavailable model or key scope.

    HTTP 403 · permission_error

    Check how your integration reports missing access or permissions.

  • Gateway deadline
    Documented

    Messages API documents 504 timeout errors.

    HTTP 504 · timeout_error

    Exercise client deadlines and timeout recovery.

  • Billing error
    Documented

    Anthropic distinguishes billing errors from transient rate limiting.

    HTTP 402 · billing_error

    Check that persistent allocation or billing limits do not cause endless retries.

    • Resolve billing before retrying.
  • Usage tier cap reached
    Documented

    A usage cap can return 429 without Retry-After and persist until account access resumes.

    HTTP 429 · rate_limit_error

    Check that persistent allocation or billing limits do not cause endless retries.

    • Do not retry as though this were a transient per-minute rate limit.
  • Internal API error
    Documented

    Anthropic documents api_error for unexpected server errors.

    HTTP 500 · api_error

    Test recovery and error reporting during simulated service failures.

  • Delayed Messages response
    Synthetic

    Synthetic slow success for exercising the client's deadline.

    HTTP 200 · 1800 ms delay

    Exercise client deadlines and timeout recovery.

  • Malformed response body
    Synthetic

    Synthetic invalid JSON despite JSON content type.

    HTTP 200

    Verify that response parsing fails safely.

Stream Message

POST /v1/messages

Sends a Messages request with stream: true. Receives text/event-stream events for message and content-block progress, with completion, an in-stream error or a synthetic cutoff.

Request content type: application/json

Request example

{
  "model": "claude-sonnet-5-5",
  "max_tokens": 64,
  "stream": true,
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ]
}

Available behaviours (3)

  • Messages SSE lifecycle
    Documented

    message_start, content block deltas, block stop, message_delta and message_stop.

    HTTP 200 · SSE · Stream completes

    Check stream progress, completion and partial-output handling.

  • Error after partial output
    Documented

    A valid partial content block precedes an overload error.

    HTTP 200 · SSE · Stream error after partial output

    Check stream progress, completion and partial-output handling.

  • Interrupted stream
    Synthetic

    Synthetic clean EOF after a partial content block; not a TCP reset.

    HTTP 200 · SSE · Interrupted before completion

    Check stream progress, completion and partial-output handling.

Tool Use

POST /v1/messages

Sends a Messages request and receives a tool_use content block with example input. Your client handles the tool request; the mock does not execute it.

Request content type: application/json

Request example

{
  "model": "claude-sonnet-5-5",
  "max_tokens": 64,
  "messages": [
    {
      "role": "user",
      "content": "Look up order"
    }
  ],
  "tools": [
    {
      "name": "lookup_order",
      "description": "Look up an order",
      "input_schema": {
        "type": "object",
        "properties": {
          "order_id": {
            "type": "string"
          }
        },
        "required": [
          "order_id"
        ]
      }
    }
  ],
  "tool_choice": {
    "type": "tool",
    "name": "lookup_order"
  }
}

Available behaviours (1)

  • Tool use requested
    Documented

    The message contains a tool_use content block for the client to execute.

    HTTP 200

    Verify that your client understands this provider-specific outcome.

What NotTheRealAPI controls

NotTheRealAPI does not call Anthropic. No real provider account is required. Your integration sends the request to a NotTheRealAPI receiver and receives the selected provider-shaped response.

The receiver stays under NotTheRealAPI at /r/<receiver-token> followed by the operation path. Selecting a behaviour controls the simulated response on that same receiver.

Scope and safe testing

This independent simulation has no live Anthropic connection or endorsement and does not claim complete API compatibility. No real provider credentials are required. Outcomes remain selected until you change them; these provider fixtures do not persist business records or transition autonomously.

Use synthetic data only. Receiver URLs are secrets. Captured headers and bounded bodies are visible to authorised workspace members without automatic redaction; see privacy and retention.

NotTheRealAPI independently simulates third-party APIs for testing. All provider names and logos are the property of their respective owners. NotTheRealAPI is not affiliated with, sponsored by or endorsed by those providers, and these modules do not connect to their live services. Twilio and all related logos are trademarks of Twilio Inc. or its affiliates.

Browse the full mock API catalogue · OpenAI Responses API mock: completion and partial output · Compare workspace limits and pricing · Sign in

Anthropic Messages API Mock: Test Stream Failures | NotTheRealAPI