---
title: "Create an Anthropic-compatible message"
method: POST
path: "/v1/messages"
---

# Create an Anthropic-compatible message

`POST /v1/messages`

## Request

- Base URL: `https://infer.flow7.org`
- URL: `https://infer.flow7.org/v1/messages`
- Auth: one of:
  - API key in header `x-api-key`
  - HTTP bearer

Anthropic Messages-compatible skin over the same Infer routing, wallet, privacy, cache, media, tool, and receipt engine. Accepts the Anthropic SDK x-api-key header or Infer Bearer auth. With stream=true, message_start, thinking/text/tool content_block deltas, message_delta, and message_stop are forwarded incrementally; terminal message_delta includes settled usage and relay receipt metadata. Infer emits ping events during quiet periods and does not impose a generation wall-clock timeout while the connection remains alive.

## Headers

- `Idempotency-Key` string
- `X-Session-Affinity` string
- `anthropic-version` string

## Request body

- AnthropicMessageRequest: Anthropic Messages compatibility request. x-api-key and Bearer authentication are both accepted. Custom function tools, images, documents/PDFs, prompt-cache blocks, tool_use/tool_result history, and real-time Anthropic SSE are supported; MCP/container features are not currently exposed.
  - `model` string, required
  - `max_tokens` integer, required: Requested output ceiling. Capacity is limited by the selected Infer model/price option and its eligible routes, not by a global Infer token cap.
  - `messages` AnthropicInputMessage[], required
    - `role` 'user' | 'assistant', required
    - `content` union, required
      - string
      - AnthropicContentBlock[]
        - `type` string, required
  - `system` union
    - string
    - AnthropicContentBlock[]
      - `type` string, required
  - `stream` boolean
  - `temperature` number
  - `top_p` number
  - `top_k` integer
  - `stop_sequences` string[]
  - `tools` object[]
  - `tool_choice` object
  - `thinking` object
  - `relay` RelayRequestOptions
    - `session_id` string
    - `privacy` 'standard' | 'no-training' | 'zero-retention'

## Response `200`

Anthropic message or SSE stream

- AnthropicMessageResponse
  - `id` string, required
  - `type` 'message', required
  - `role` 'assistant', required
  - `model` string, required
  - `content` AnthropicContentBlock[], required
    - `type` string, required
  - `stop_reason` string, nullable, required
  - `stop_sequence` string, nullable, required
  - `usage` object, required
  - `relay` RelayResponseMetadata, required
    - `receipt_id` string, required
    - `price_version` string, required: Opaque reference (pv_…) to the immutable price version that priced this request. It matches the catalog option and the usage receipt and reveals no supplier or cost information.
    - `tier` 'low-cost' | 'balanced' | 'stable' | 'official', required
    - `resolved_model_class` string, required
    - `cache_status` 'hit' | 'partial' | 'miss', required
    - `environment` 'live', required
    - `provider_disclosed` false, required
    - `customer_cost_usd` number, required
    - `idempotent_replay` boolean

## Other responses

- `400`: Error
- `401`: Error
- `403`: Error
- `413`: Error
- `422`: Error
- `429`: Error
- `500`: Error
- `503`: Error

---

[API](https://skmtc.dev/flow7/apis/infer-by-flow7-public-api.md) · [All operations](https://skmtc.dev/flow7/apis/infer-by-flow7-public-api/llms.txt) · [OpenAPI document](https://skmtc.dev/flow7/apis/infer-by-flow7-public-api/revisions/e73ecffd3cf3?raw)
