Anthropic Compatible

Messages (Anthropic-compatible)

Changed on

Anthropic Messages API format, non-streaming text only. Code written for the Anthropic SDK runs with base_url and api_key changed. Streaming, images, documents, tools, thinking, assistant prefill and any other field not listed here are rejected with a 400.

post/v1/messages

Request

  • Base URL
    https://api.swarms.world
  • URL
    https://api.swarms.world/v1/messages
  • Auth
    none declared. Required headers: x-api-key

Headers

x-api-keystring required

Request body

modelstring required

Model to use

max_tokensinteger required

Maximum tokens to generate

temperaturenumber nullable

Sampling temperature

top_pnumber nullable

Nucleus sampling cutoff

Response

Successful Response

idstring required

Unique id, prefixed msg_

type'message'
role'assistant'
modelstring required

The model that answered

stop_reason'end_turn' | 'max_tokens' required

end_turn when the model finished, max_tokens when it hit the max_tokens limit

stop_sequencestring nullable

Always null; stop sequences are not supported

Changes

    • breaking

      the response's body type changed from no type to object for status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the non-success response with the status

    • info

      added the optional property to the response with the status

    • info

      added the optional property to the response with the status

    • info

      added the optional property to the response with the status

    • info

      added the required property to the response with the status

    • info

      added the required property to the response with the status

    • info

      added the required property to the response with the status

    • info

      added the required property to the response with the status

    • info

      added the required property to the response with the status

    • info

      endpoint added