---
title: "Create Anthropic Message"
method: POST
path: "/v3/v1/messages"
tags: ["Anthropic Messages"]
---

# Create Anthropic Message

`POST /v3/v1/messages`

## Request

- Base URL: `https://api.edenai.run`
- URL: `https://api.edenai.run/v3/v1/messages`
- Auth: HTTP bearer

Anthropic Messages API, native pass-through.

## Request body

- AnthropicMessagesBody
  - `tags` unknown
  - `routing` ProviderRoutingPreferences: How to choose between SELLERS of one model — and, with ``@edenai``, how far to trade quality for cost when the platform chooses the model. ``order``, ``allowed_providers``, ``ignored_providers`` and ``max_price`` shape WHICH sellers and in what order; ``sort`` ranks the rest. The seller fields are only meaningful when `model` is a canonical name (`gpt-5.5`) rather than a concrete `provider/model` — with a concrete id there is nothing to choose between. For choosing the MODEL itself see ``router_candidates`` and ``model="@edenai"``, which is a different router; ``quality_cost`` below is the one field here that speaks to it.
    - `sort` 'cost' | 'speed' | 'latency' | 'exact', nullable: What to optimise for when several providers serve the requested model. 'cost' (default) picks the cheapest for this request's shape; 'speed' the highest tokens/second; 'latency' the fastest to first token; 'exact' the most reliable at producing well-formed tool calls / structured output. Health is always a filter first — no mode will route you to a failing provider. Can also be written as a model suffix, e.g. 'gpt-5.5:speed'.
    - `sticky` boolean, nullable: Keep a conversation on the provider holding its prompt cache. On by default, and only ever active for models whose providers discount cache reads. Set false to route every request independently on price instead. Naming an explicit `sort` or an `order` also takes priority over cache affinity.
    - `allow_fallbacks` boolean, nullable: Whether other providers of the same model may be tried when the chosen one fails. On by default. Set false to pin the request to the single best provider: it then fails rather than silently moving to another seller, useful when a cache-warm prompt would cold-miss elsewhere. This governs PROVIDERS of the requested model only; models you list in `fallbacks` are your own choice and are always kept.
    - `quality_cost` integer, nullable: Only with model='@edenai': how far to trade answer quality for cost when the platform chooses the MODEL. 0 asks for the best model for the request, 10 for the cheapest model that can still handle it, values in between blend the two; omit it to leave the choice to the platform (quality first). This is the one `routing` field that steers the model rather than the provider — `sort` never changes which model is chosen.
    - `allowed_providers` string[], nullable: Restrict routing to these providers, e.g. ['openai', 'anthropic']. Only providers that serve the requested model are considered, so an entry that does not sell it is simply inert. If none of them do, the request fails rather than falling back to a provider you excluded. Case-insensitive. Applies to routed providers only. a concrete 'provider/model' you named in `fallbacks` is your own choice and is kept.
    - `zero_data_retention` boolean, nullable: Serve this request only from providers that keep no prompts or outputs, and save neither its content nor its response. Applies to every model in the request, including a concrete 'provider/model' and your `fallbacks`: one that is not zero data retention fails the request. It can only add the restriction. When your organization requires zero data retention, `false` does not lift it.
    - `ignored_providers` string[], nullable: Never route to these providers, e.g. ['deepinfra']. The mirror of `allowed_providers`: an entry that does not sell the requested model is inert, and if the list removes every seller the request fails rather than falling back to one you excluded. Case-insensitive. A provider named in both lists is a validation error. A concrete 'provider/model' you named in `fallbacks` is your own choice and is kept.
    - `order` string[], nullable: Providers to try first, in this order, e.g. ['azure', 'openai']. They become the head of the fallback chain; the remaining providers of the model follow, ranked by `sort` (or load-balanced on price when no `sort` is given). An entry that does not sell the model is inert. A provider our health data marks as down is moved to the end of the chain whatever its position here. Naming an `order` turns cache affinity off, as naming a `sort` does. Case-insensitive.
    - `max_price` MaxPrice: A price ceiling in USD per MILLION tokens, one bar per direction, either one optional. Unknown keys are refused: a typo on one side (``ouput``) must not silently remove that bar.
      - `input` number, nullable: Highest input rate accepted, in USD per million tokens.
      - `output` number, nullable: Highest output rate accepted, in USD per million tokens.
  - `fallbacks` string[], nullable: List of fallback model IDs to try if the primary model fails. Models are tried in order. Example: ['anthropic/claude-3-opus', 'openai/gpt-4o']
  - `session_id` string, nullable: Identifies a conversation, so its requests keep reaching the provider that holds its prompt cache. Any stable string you choose — a thread id, a ticket number, an agent run. Also accepted as the `x-session-id` header, for clients that cannot add body fields, and read from the headers coding agents already send (`x-claude-code-session-id`, `x-session-affinity`, `session-id`, `session_id`, and `x-client-request-id` from pi and Codex); the body field wins if both are sent. Without one, a conversation is recognised from its opening messages instead.
  - `router_candidates` string[], nullable: Models the '@edenai' router may choose BETWEEN — it picks the model, whereas `routing` picks the provider for a model you already named. Used only when model='@edenai'. Each entry is a bare model name (e.g. 'gpt-5.5' — the winner's provider is then picked like any provider-less request) or a 'provider/model' id (e.g. 'openai/gpt-5-nano' — the winner is served by that exact provider). Entries the router cannot rank are skipped and listed under `edenai_metadata.routing.auto.dropped`; entries naming a model already in the list collapse into its earliest spelling, which decides how the winner is returned. The request fails only when no entry is left. If not provided, the router chooses from a default pool of eligible catalog models. At most 64 entries of up to 128 characters each.
  - `pre_hooks` object[], nullable: List of hooks to run before the LLM provider call. Each entry must have an 'action' key and optional 'params'. Example: [{'action': 'pdf_text_extract', 'params': {'method': 'default'}}]
  - `post_hooks` object[], nullable: List of hooks to run after the LLM provider call. Each entry must have an 'action' key and optional 'params'. Example: [{'action': 'json_heal', 'params': {'json_schema': {...}}}]
  - `model` string, required
  - `messages` AnthropicMessage[], required
    - `role` 'user' | 'assistant' | 'system', required
    - `content` union, required
      - string
      - AnthropicContentBlock[]
        - `type` string, required
        - `text` string, nullable
        - `id` string, nullable
        - `name` string, nullable
        - `input` object, nullable
        - `tool_use_id` string, nullable
        - `content` union
          - string
          - unknown[]
            - unknown
        - `is_error` boolean, nullable
        - `source` object, nullable
        - `thinking` string, nullable
        - `signature` string, nullable
    - `cache_control` CacheControl: Prompt-cache marker. Marks a message (or content part) as a cache boundary so that the prefix up to that point is stored and reused on subsequent requests, reducing latency and cost. Only a single contiguous cache-marked block is stored per request, and providers enforce a minimum token count below which caching is silently skipped. Silently ignored by providers that don't support prompt caching.
      - `type` 'ephemeral', required: Cache type. Currently only 'ephemeral' is supported.
      - `ttl` string, nullable: Optional cache time-to-live, e.g. '3600s'. Provider-dependent.
  - `max_tokens` integer, nullable
  - `system` union
    - string
    - object[]
  - `temperature` number, nullable
  - `top_p` number, nullable
  - `top_k` integer, nullable
  - `stream` boolean, nullable
  - `stop_sequences` string[], nullable
  - `tools` object[], nullable
  - `tool_choice` object, nullable
  - `metadata` object, nullable
  - `thinking` object, nullable
  - `extra_headers` object, nullable

## Response `200`

Successful Response

- AnthropicMessagesResponse: Response body for POST /v1/messages (non-streaming).
  - `id` string, required: Unique identifier for the message.
  - `type` 'message': Object type. Always 'message' for this endpoint.
  - `role` 'assistant': Conversational role of the response.
  - `model` string, required: Model that generated the message.
  - `content` AnthropicContentBlock[], required: Ordered list of content blocks produced by the model.
    - `type` string, required
    - `text` string, nullable
    - `id` string, nullable
    - `name` string, nullable
    - `input` object, nullable
    - `tool_use_id` string, nullable
    - `content` union
      - string
      - unknown[]
        - unknown
    - `is_error` boolean, nullable
    - `source` object, nullable
    - `thinking` string, nullable
    - `signature` string, nullable
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use', nullable: Reason generation stopped, if known.
  - `stop_sequence` string, nullable: Custom stop sequence that triggered the stop, if any.
  - `usage` AnthropicUsage, required: Token usage block returned by the Anthropic Messages API.
    - `input_tokens` integer, required: Number of input tokens consumed.
    - `output_tokens` integer, required: Number of output tokens generated.
    - `cache_creation_input_tokens` integer, nullable: Tokens written to the prompt cache (when prompt caching is used).
    - `cache_read_input_tokens` integer, nullable: Tokens read from the prompt cache (when prompt caching is used).

## Other responses

- `422`: Validation Error

---

[API](https://skmtc.dev/edenai/apis/eden-ai-api-v3.md) - [All operations](https://skmtc.dev/edenai/apis/eden-ai-api-v3/llms.txt) - [OpenAPI document](https://skmtc.dev/edenai/apis/eden-ai-api-v3/revisions/20ddfd49a3f4?raw)
