---
title: "Create a Message"
method: POST
path: "/v1/messages"
tags: ["anthropic-messages.openapi_other"]
---

# Create a Message

`POST /v1/messages`

**Anthropic-compatible endpoint.**

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

The Messages API can be used for either single queries or stateless multi-turn conversations.

**Fireworks Quickstarts:**
- [Serverless Quickstart](/getting-started/quickstart)
- [Deployments Quickstart](/getting-started/ondemand-quickstart)

## Request body

- AnthropicCreateMessageParams
  - `model` string, required — The model that will complete your prompt. See the [Fireworks Model Library](https://app.fireworks.ai/models) for available models.
  - `messages` AnthropicInputMessage[], required — Input messages. Models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn. Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages. If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response. Example with a single `user` message: ```json [{"role": "user", "content": "Hello"}] ``` Example with multiple conversational turns: ```json [ {"role": "user", "content": "Hello there."}, {"role": "assistant", "content": "Hi, I'm here to help. How can I help you?"}, {"role": "user", "content": "Can you explain LLMs in plain English?"}, ] ``` Example with a partially-filled response from the model: ```json [ {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"}, {"role": "assistant", "content": "The best answer is ("}, ] ``` Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent: ```json {"role": "user", "content": "Hello"} ``` ```json {"role": "user", "content": [{"type": "text", "text": "Hello"}]} ``` See [input examples](https://docs.claude.com/en/api/messages-examples). Note that if you want to include a [system prompt](/guides/querying-text-models), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API. There is a limit of 100,000 messages in a single request.
    - `content` union, required
      - string
      - AnthropicInputContentBlock[]
        - union
          - object
            - `cache_control` AnthropicCacheControlEphemeral
              - …
            - `citations` union[], nullable
              - …
            - `text` string, required
            - `type` 'text', required
          - object
            - `cache_control` AnthropicCacheControlEphemeral
              - …
            - `source` union, required
              - …
            - `type` 'image', required
          - object
            - `cache_control` AnthropicCacheControlEphemeral
              - …
            - `citations` AnthropicRequestCitationsConfig
              - …
            - `context` string, nullable
            - `source` union, required
              - …
            - `title` string, nullable
            - `type` 'document', required
          - object
            - `signature` string, required
            - `thinking` string, required
            - `type` 'thinking', required
          - object
            - `data` string, required
            - `type` 'redacted_thinking', required
          - object
            - `cache_control` AnthropicCacheControlEphemeral
              - …
            - `id` string, required
            - `input` object, required
            - `name` string, required
            - `type` 'tool_use', required
          - object
            - `cache_control` AnthropicCacheControlEphemeral
              - …
            - `content` union
              - …
            - `is_error` boolean
            - `tool_use_id` string, required
            - `type` 'tool_result', required
    - `role` 'user' | 'assistant', required
  - `max_tokens` integer — The maximum number of tokens to generate before stopping. Note that models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate. Different models have different maximum values for this parameter. See [models](https://app.fireworks.ai/models) for details.
  - `metadata` AnthropicMetadata
    - `user_id` string, nullable — An external identifier for the user who is associated with the request. This should be a uuid, hash value, or other opaque identifier. This id may be used to help detect abuse. Do not include any identifying information such as name, email address, or phone number.
  - `output_config` AnthropicOutputConfig
    - `effort` 'low' | 'medium' | 'high' | 'max' — All possible effort levels.
    - `format` AnthropicJsonOutputFormat
      - `schema` object, required — The JSON schema of the format
      - `type` 'json_schema', required
  - `stop_sequences` string[] — Custom text sequences that will cause the model to stop generating. Models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `"end_turn"`. If you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `"stop_sequence"` and the response `stop_sequence` value will contain the matched stop sequence.
  - `stream` boolean — Whether to incrementally stream the response using server-sent events. See [streaming](/guides/querying-text-models) for details.
  - `system` union — System prompt. A system prompt is a way of providing context and instructions to the model, such as specifying a particular goal or role. See the [guide to system prompts](/guides/querying-text-models).
    - string
    - AnthropicRequestTextBlock[]
      - `cache_control` AnthropicCacheControlEphemeral
        - `ttl` '5m' | '1h' — The time-to-live for the cache control breakpoint. This may be one the following values: - `5m`: 5 minutes - `1h`: 1 hour Defaults to `5m`.
        - `type` 'ephemeral', required
      - `citations` union[], nullable
        - union
          - AnthropicRequestCharLocationCitation
            - `cited_text` string, required
            - `document_index` integer, required
            - `document_title` string, nullable, required
            - `end_char_index` integer, required
            - `start_char_index` integer, required
            - `type` 'char_location', required
          - AnthropicRequestPageLocationCitation
            - `cited_text` string, required
            - `document_index` integer, required
            - `document_title` string, nullable, required
            - `end_page_number` integer, required
            - `start_page_number` integer, required
            - `type` 'page_location', required
          - AnthropicRequestContentBlockLocationCitation
            - `cited_text` string, required
            - `document_index` integer, required
            - `document_title` string, nullable, required
            - `end_block_index` integer, required
            - `start_block_index` integer, required
            - `type` 'content_block_location', required
          - AnthropicRequestWebSearchResultLocationCitation
            - `cited_text` string, required
            - `encrypted_index` string, required
            - `title` string, nullable, required
            - `type` 'web_search_result_location', required
            - `url` string, required
          - AnthropicRequestSearchResultLocationCitation
            - `cited_text` string, required
            - `end_block_index` integer, required
            - `search_result_index` integer, required
            - `source` string, required
            - `start_block_index` integer, required
            - `title` string, nullable, required
            - `type` 'search_result_location', required
      - `text` string, required
      - `type` 'text', required
  - `temperature` number — Amount of randomness injected into the response. Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks. Note that even with `temperature` of `0.0`, the results will not be fully deterministic.
  - `thinking` union — Configuration for enabling the model's extended thinking. When enabled, responses include `thinking` content blocks showing the model's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit. See [reasoning](/guides/reasoning) for details. **Note:** The `adaptive` thinking type is not supported yet.
    - AnthropicThinkingConfigEnabled
      - `budget_tokens` integer, required — Determines how many tokens the model can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality. Must be ≥1024 and less than `max_tokens`. See [reasoning](/guides/reasoning) for details.
      - `type` 'enabled', required
    - AnthropicThinkingConfigDisabled
      - `type` 'disabled', required
    - AnthropicThinkingConfigAdaptive — **Not supported yet.**
      - `type` 'adaptive', required
  - `tool_choice` union — How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.
    - AnthropicToolChoiceAuto — The model will automatically decide whether to use tools.
      - `disable_parallel_tool_use` boolean — Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output at most one tool use.
      - `type` 'auto', required
    - AnthropicToolChoiceAny — The model will use any available tools.
      - `disable_parallel_tool_use` boolean — Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.
      - `type` 'any', required
    - AnthropicToolChoiceTool — The model will use the specified tool with `tool_choice.name`.
      - `disable_parallel_tool_use` boolean — Whether to disable parallel tool use. Defaults to `false`. If set to `true`, the model will output exactly one tool use.
      - `name` string, required — The name of the tool to use.
      - `type` 'tool', required
    - AnthropicToolChoiceNone — The model will not be allowed to use tools.
      - `type` 'none', required
  - `tools` AnthropicTool[] — Definitions of tools that the model may use. If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks. Each tool definition includes: * `name`: Name of the tool. * `description`: Optional, but strongly-recommended description of the tool. * `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks. For example, if you defined `tools` as: ```json [ { "name": "get_stock_price", "description": "Get the current stock price for a given ticker symbol.", "input_schema": { "type": "object", "properties": { "ticker": { "type": "string", "description": "The stock ticker symbol, e.g. AAPL for Apple Inc." } }, "required": ["ticker"] } } ] ``` And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this: ```json [ { "type": "tool_use", "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "name": "get_stock_price", "input": { "ticker": "^GSPC" } } ] ``` You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message: ```json [ { "type": "tool_result", "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV", "content": "259.75 USD" } ] ``` Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output. See the [guide](/guides/function-calling) for more details.
    - `type` 'custom', nullable
    - `description` string — Description of what this tool does. Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.
    - `name` string, required — Name of the tool. This is how the tool will be called by the model and in `tool_use` blocks.
    - `input_schema` AnthropicInputSchema, required
      - `properties` object, nullable
      - `required` string[], nullable
      - `type` 'object', required
    - `strict` boolean — When true, guarantees schema validation on tool names and inputs
  - `top_k` integer — Only sample from the top K options for each subsequent token. Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277). Recommended for advanced use cases only. You usually only need to use `temperature`.
  - `top_p` number — Use nucleus sampling. In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`. You should either alter `temperature` or `top_p`, but not both. Recommended for advanced use cases only. You usually only need to use `temperature`.
  - `raw_output` boolean, nullable — Return raw output from the model.

## Response `200`

Message object.

- AnthropicMessage
  - `id` string, required — Unique object identifier. The format and length of IDs may change over time.
  - `type` 'message', required — Object type. For Messages, this is always `"message"`.
  - `role` 'assistant', required — Conversational role of the generated message. This will always be `"assistant"`.
  - `content` AnthropicContentBlock[], required — Content generated by the model. This is an array of content blocks, each of which has a `type` that determines its shape. Example: ```json [{"type": "text", "text": "Hi, I'm here to help."}] ``` If the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output. For example, if the input `messages` were: ```json [ {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"}, {"role": "assistant", "content": "The best answer is ("} ] ``` Then the response `content` might be: ```json [{"type": "text", "text": "B)"}] ```
    - union
      - AnthropicResponseTextBlock
        - `citations` union[], nullable, required — Citations supporting the text block. The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.
          - union
            - AnthropicResponseCharLocationCitation
              - …
            - AnthropicResponsePageLocationCitation
              - …
            - AnthropicResponseContentBlockLocationCitation
              - …
            - AnthropicResponseWebSearchResultLocationCitation
              - …
            - AnthropicResponseSearchResultLocationCitation
              - …
        - `text` string, required
        - `type` 'text', required
      - AnthropicResponseThinkingBlock
        - `signature` string, required
        - `thinking` string, required
        - `type` 'thinking', required
      - AnthropicResponseRedactedThinkingBlock
        - `data` string, required
        - `type` 'redacted_thinking', required
      - AnthropicResponseToolUseBlock
        - `id` string, required
        - `input` object, required
        - `name` string, required
        - `type` 'tool_use', required
  - `model` string, required — The model that will complete your prompt. See the [Fireworks Model Library](https://app.fireworks.ai/models) for available models.
  - `stop_reason` 'end_turn' | 'max_tokens' | 'stop_sequence' | 'tool_use' | 'pause_turn' | 'refusal', required
  - `stop_sequence` string, nullable, required — Which custom stop sequence was generated, if any. This value will be a non-null string if one of your custom stop sequences was generated.
  - `raw_output` AnthropicRawOutput — Fireworks extension that returns low-level details of what the model sees, including the formatted prompt and function calls.
    - `prompt_fragments` union[], required — Pieces of the prompt (like individual messages) before truncation and concatenation. Depending on prompt_truncate_len some of the messages might be dropped. Contains a mix of strings to be tokenized and individual tokens (if dictated by the conversation template)
      - union
        - string
        - integer
    - `prompt_token_ids` integer[], required — Fully processed prompt as seen by the model
    - `completion` string, required — Raw completion produced by the model before any tool calls are parsed
    - `completion_token_ids` integer[], nullable — Token IDs for the raw completion
    - `images` string[], nullable — Images in the prompt
    - `grammar` string, nullable — Grammar used for constrained decoding, can be either user provided (directly or JSON schema) or inferred by the chat template

## Other responses

- `4XX` — Error response. See the [errors documentation](/guides/inference-error-codes) for more details.

---

[API](https://skmtc.net/fw-ai-external/apis/gateway-rest-api.md) · [All operations](https://skmtc.net/fw-ai-external/apis/gateway-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/fw-ai-external/gateway-rest-api/revisions/29a1e4db152c/schema)
