Usage > V2 > Anthropic-compatible

Create message

Anthropic (Claude) compatible endpoint to create a message, see the Claude documentation. <br><br> List of models available on this endpoint could be retrieve with GET /2/ai/{product_id}/anthropic/v1/models. <br><br> Some models are in beta and may being subject to changes, use GET /1/ai/models to check what model are in beta and see our General Terms and Conditions.

post/2/ai/{product_id}/anthropic/v1/messages

Path parameters

product_idinteger required

AI Tools product identifier: use GET /1/ai to retrieve your product identifier.

Request body

max_tokensinteger required

The maximum number of tokens to generate before stopping.<br><br>Note that our models may stop <i>before</i> reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.

modelstring required

Model name to use<br>You can use the endpoint GET /2/ai/{product_id}/anthropic/v1/models to see all our available models with various information.

stop_sequencesstring[]

Custom text sequences that will cause the model to stop generating.<br><br>Our models will normally stop when they have naturally completed their turn, which will result in a response <code>stop_reason</code> of <code>"end_turn"</code>.

streamboolean

Whether to incrementally stream the response using server-sent events.<br><br>Defaults to <code>false</code>

systemstring nullable

System prompt.<br>A system prompt is a way of providing context and instructions to the model, such as specifying a particular goal or role. May be a single string or an array of text blocks.

temperaturenumber double

Amount of randomness injected into the response.<br><br>Defaults to <code>1.0</code><br>Ranges from <code>0.0</code> to <code>1.0</code>. Use <code>temperature</code> closer to <code>0.0</code> for analytical / multiple choice, and closer to <code>1.0</code> for creative and generative tasks.<br><br>Note that even with <code>temperature</code> of <code>0.0</code>, the results will not be fully deterministic.

Example request

{
  "messages": [
    {
      "content": "Hello, Claude",
      "role": "user"
    }
  ],
  "metadata": {
    "user_id": "12345"
  },
  "model": "glm-5.2",
  "stop_sequences": [
    "\\n\\nHuman:"
  ],
  "system": "You are a helpful assistant.",
  "thinking": {
    "type": "enabled"
  },
  "tools": [
    {
      "description": "Get the current stock price for a given ticker symbol.",
      "name": "get_stock_price"
    }
  ]
}

Response

OK

idstring required

Unique object identifier.

typestring required

The object type, which is always message.

rolestring required

The conversational role of the generated message, which is always assistant.

modelstring required

The model that handled the request.

stop_reasonstring nullable required

The reason the model stopped generating.

stop_sequencestring nullable required

The custom stop sequence that caused the model to stop, if applicable.

Example response

{
  "id": "msg_1nZdL29xx5MUA1yADyHTEsnR8uuvGzszyY",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Hello!",
      "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
      "name": "get_stock_price",
      "input": "{\"ticker\":\"AAPL\"}",
      "thinking": "I need to find the GCD of 1071 and 462.",
      "signature": "EqQBCgIYAhIM1gbcDa9GJwZA2b3hGgxBdjrkzLoky3dl1pkiMOYds"
    }
  ],
  "model": "claude-sonnet-4-5",
  "stop_reason": "end_turn",
  "stop_sequence": "\\n\\nHuman:",
  "usage": {
    "input_tokens": 25,
    "output_tokens": 15
  }
}

Changes

Changed in 1 of the 15 revisions of this API.1