Skip to content
Docs

Completions

Create a message

The Anthropic Messages format, on the same models and prices. The Anthropic SDKs and Claude Code use it. Errors come in the Anthropic shape.

POST / v1 / messages
POST / v1 / messages

Create a message

The Anthropic Messages format, on the same models and prices. The Anthropic SDKs and Claude Code use it. Errors come in the Anthropic shape.

Authorizations

Authorizationstring<bearer>required

Bearer authentication header of the form Bearer <token>, where <token> is your API key. This endpoint also takes the key in x-api-key, as the Anthropic SDKs send it.

Your key stays in this page and is only sent with this request. Get an API key

Body

application/json

Up to 1,000 characters and 256 output tokens, to try the API. For more, use the API from your code, the Chat or an agent.

Create a message
curl --request POST \
  --url https://api.libremodel.ai/v1/messages \
  --header 'Authorization: Bearer YOUR_API_KEY' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "deepseek-v4.1-flash-1017",
  "max_tokens": 256,
  "messages": [
    {
      "role": "user",
      "content": ""
    }
  ]
}'
{
  "id": "msg_01a22df853e5765ebd8441187ca28e5e",
  "type": "message",
  "role": "assistant",
  "model": "deepseek-v4.1-flash-1017",
  "content": [
    {
      "type": "text",
      "text": "Hello! How can I help you today?"
    }
  ],
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 9,
    "cache_read_input_tokens": 0,
    "output_tokens": 10,
    "cost": 0.0000132
  }
}

Authorizations

Authorizationstringheaderrequired

Bearer authentication header of the form Bearer <token>, where <token> is your API key. This endpoint also takes the key in x-api-key, as the Anthropic SDKs send it.

Body

application/json
  • modelstringrequired

    A Libremodel model ID, from Models or GET /v1/models.

  • messagesobject[]required

    The conversation: role (user or assistant) and content, text or blocks (text, image, document, tool_use, tool_result).

  • max_tokensinteger

    Cap on output tokens, thinking included. The Anthropic SDKs require it.

    Example: 1024

  • systemstring | object[]

    The system prompt.

  • streambooleandefault: false

    Send the answer as Server-Sent Events, as it is generated. See Streaming.

  • thinkingobject

    {"type": "enabled"} or adaptive to get the thinking text in thinking blocks.

  • output_configobject

    effort (the reasoning level) and format (structured outputs).

  • toolsobject[]

    Tools the model can use, with tool_choice. See Tool calling.

  • stop_sequencesstring[]

    Text that ends the answer.

  • temperaturenumber

    Sampling temperature.

  • top_pnumber

    Nucleus sampling.

Response

application/json

The message. With stream, Anthropic’s text/event-stream instead.

  • idstringrequired

    The ID of the message.

  • typestringrequired

    Always "message".

  • contentobject[]required

    Blocks: thinking (with thinking on), text and tool_use. Read the text ones for the answer.

  • stop_reasonstringrequired

    Why it stopped.

    Allowed values:"end_turn""max_tokens""stop_sequence""tool_use"

  • usageobjectrequired

    input_tokens, cache_read_input_tokens, output_tokens and cost.

    Show child attributes
    • costnumberrequired

      What the request cost, in dollars.

      Example: 0.0001605